50
50
#define MIN_RECONNECT_INTERVAL_USEC 1000
51
51
#define MAX_RECONNECT_INTERVAL_USEC 1000000
52
52
53
+
54
+ enum NeonEndpointType {
55
+ EP_TYPE_PRIMARY = 0 ,
56
+ EP_TYPE_REPLICA ,
57
+ EP_TYPE_STATIC
58
+ };
59
+
60
+ static const struct config_enum_entry neon_endpoint_types [] = {
61
+ {"primary" , EP_TYPE_PRIMARY , false},
62
+ {"replica" , EP_TYPE_REPLICA , false},
63
+ {"static" , EP_TYPE_STATIC , false},
64
+ {NULL , 0 , false}
65
+ };
66
+
53
67
/* GUCs */
54
68
char * neon_timeline ;
55
69
char * neon_tenant ;
@@ -62,6 +76,8 @@ int flush_every_n_requests = 8;
62
76
63
77
int neon_protocol_version = 2 ;
64
78
79
+ static int neon_endpoint_type = 0 ;
80
+
65
81
static int max_reconnect_attempts = 60 ;
66
82
static int stripe_size ;
67
83
@@ -390,9 +406,10 @@ pageserver_connect(shardno_t shard_no, int elevel)
390
406
{
391
407
case PS_Disconnected :
392
408
{
393
- const char * keywords [4 ];
394
- const char * values [4 ];
409
+ const char * keywords [5 ];
410
+ const char * values [5 ];
395
411
char pid_str [16 ];
412
+ char endpoint_str [36 ];
396
413
int n_pgsql_params ;
397
414
TimestampTz now ;
398
415
int64 us_since_last_attempt ;
@@ -464,6 +481,34 @@ pageserver_connect(shardno_t shard_no, int elevel)
464
481
n_pgsql_params ++ ;
465
482
}
466
483
484
+ {
485
+ int ret = 0 ;
486
+ bool param_set = false;
487
+ switch (neon_endpoint_type )
488
+ {
489
+ case EP_TYPE_PRIMARY :
490
+ ret = snprintf (endpoint_str , sizeof (endpoint_str ), "-c neon.endpoint_type=primary" );
491
+ param_set = true;
492
+ break ;
493
+ case EP_TYPE_REPLICA :
494
+ ret = snprintf (endpoint_str , sizeof (endpoint_str ), "-c neon.endpoint_type=replica" );
495
+ param_set = true;
496
+ break ;
497
+ case EP_TYPE_STATIC :
498
+ ret = snprintf (endpoint_str , sizeof (endpoint_str ), "-c neon.endpoint_type=static" );
499
+ param_set = true;
500
+ break ;
501
+ }
502
+ if (ret < 0 || ret >= (int )(sizeof (endpoint_str )))
503
+ elog (FATAL , "stack-allocated buffer too small to hold endpoint type" );
504
+ if (param_set )
505
+ {
506
+ keywords [n_pgsql_params ] = "options" ;
507
+ values [n_pgsql_params ] = endpoint_str ;
508
+ n_pgsql_params ++ ;
509
+ }
510
+ }
511
+
467
512
keywords [n_pgsql_params ] = NULL ;
468
513
values [n_pgsql_params ] = NULL ;
469
514
@@ -1370,6 +1415,17 @@ pg_init_libpagestore(void)
1370
1415
GUC_UNIT_MS ,
1371
1416
NULL , NULL , NULL );
1372
1417
1418
+ DefineCustomEnumVariable (
1419
+ "neon.endpoint_type" ,
1420
+ "The compute endpoint node type" ,
1421
+ NULL ,
1422
+ & neon_endpoint_type ,
1423
+ EP_TYPE_PRIMARY ,
1424
+ neon_endpoint_types ,
1425
+ PGC_POSTMASTER ,
1426
+ 0 ,
1427
+ NULL , NULL , NULL );
1428
+
1373
1429
relsize_hash_init ();
1374
1430
1375
1431
if (page_server != NULL )
0 commit comments