Documentation ¶
Index ¶
- Constants
- Variables
- func GetHostOrHostname(host string) (string, error)
- func LoadBalancerCfg(cfgPath string) error
- func LoadCoordinatorCfg(cfgPath string) error
- func LoadRouterCfg(cfgPath string) error
- func ValueOrDefaultDuration(value time.Duration, def time.Duration) time.Duration
- func ValueOrDefaultInt(value int, def int) int
- type AuthBackendCfg
- type AuthCfg
- type AuthMethod
- type BackendRule
- type Balancer
- type Coordinator
- type DatatransferConnections
- type DefaultRouteBehaviour
- type FrontendRule
- type GssCfg
- type Host
- type LDAPAuthMode
- type LDAPCfg
- func (l *LDAPCfg) CheckSearchResult(entries []*ldap.Entry) error
- func (l *LDAPCfg) DoSearchRequest(conn *ldap.Conn, searchFilter string) (*ldap.SearchResult, error)
- func (l *LDAPCfg) ModifySearchAttribute() string
- func (l *LDAPCfg) ModifySearchFilter(searchAttribute string, username string) string
- func (l *LDAPCfg) SearchBind(conn *ldap.Conn) error
- func (l *LDAPCfg) ServerConn() (*ldap.Conn, error)
- func (l *LDAPCfg) SimpleBind(conn *ldap.Conn, username string, password string) error
- type LDAPConnCfg
- type LDAPConnMode
- type LDAPTLSCfg
- type LDAPTLSVerifyMode
- type PoolMode
- type QRouter
- type Router
- type RouterMode
- type Shard
- type ShardConnect
- type ShardType
- type TLSConfig
Constants ¶
const ( AuthOK = AuthMethod("ok") AuthNotOK = AuthMethod("notok") AuthClearText = AuthMethod("clear_text") AuthMD5 = AuthMethod("md5") AuthSCRAM = AuthMethod("scram") AuthLDAP = AuthMethod("ldap") AuthGSS = AuthMethod("gss") )
const ( SimpleBindMode = LDAPAuthMode("simple_bind") SearchAndBindMode = LDAPAuthMode("search_and_bind") UnencryptedMode = LDAPConnMode("unencrypted") SchemeMode = LDAPConnMode("scheme") StartTLSMode = LDAPConnMode("start_tls") OneWayMode = LDAPTLSVerifyMode("one_way") TwoWayMode = LDAPTLSVerifyMode("two_way") )
const ( PoolModeSession = PoolMode("SESSION") PoolModeTransaction = PoolMode("TRANSACTION") DataShard = ShardType("DATA") WorldShard = ShardType("WORLD") LocalMode = RouterMode("LOCAL") ProxyMode = RouterMode("PROXY") DefaultRouteBehaviourBlock = DefaultRouteBehaviour("BLOCK") DefaultRouteBehaviourAllow = DefaultRouteBehaviour("ALLOW") )
const ( TargetSessionAttrsRW = "read-write" TargetSessionAttrsRO = "read-only" TargetSessionAttrsPS = "prefer-standby" TargetSessionAttrsAny = "any" )
const (
UnixSocketDirectory = "/var/run/postgresql"
)
Variables ¶
var ( ErrServerConn = errors.New("there are no ldap servers available or such servers don't exist") ErrSearchResult = errors.New("too many entries returned or user doesn't exist") )
Functions ¶
func GetHostOrHostname ¶
func LoadBalancerCfg ¶
LoadBalancerCfg loads the balancer configuration from the specified file path.
Parameters:
- cfgPath (string): The path of the configuration file.
Returns:
- error: an error if any occurred during the loading process.
func LoadCoordinatorCfg ¶
LoadCoordinatorCfg loads the coordinator configuration from the specified file path.
Parameters:
- cfgPath (string): The path of the configuration file.
Returns:
- error: An error if any occurred during the loading process.
func LoadRouterCfg ¶
LoadRouterCfg loads the router configuration from the specified file path.
Parameters:
- cfgPath (string): The path of the configuration file.
Returns:
- error: An error if any occurred during the loading process.
func ValueOrDefaultDuration ¶
func ValueOrDefaultInt ¶
Types ¶
type AuthBackendCfg ¶
type AuthCfg ¶
type AuthCfg struct { Method AuthMethod `json:"auth_method" yaml:"auth_method" toml:"auth_method"` Password string `json:"password" yaml:"password" toml:"password"` LDAPConfig *LDAPCfg `json:"ldap_config" yaml:"ldap_config" toml:"ldap_config"` GssConfig *GssCfg `json:"gss_config" yaml:"gss_config" toml:"gss_config"` }
type AuthMethod ¶
type AuthMethod string
type BackendRule ¶
type BackendRule struct { DB string `json:"db" yaml:"db" toml:"db"` Usr string `json:"usr" yaml:"usr" toml:"usr"` AuthRules map[string]*AuthBackendCfg `json:"auth_rules" yaml:"auth_rules" toml:"auth_rules"` // TODO validate DefaultAuthRule *AuthBackendCfg `json:"auth_rule" yaml:"auth_rule" toml:"auth_rule"` PoolDefault bool `json:"pool_default" yaml:"pool_default" toml:"pool_default"` ConnectionLimit int `json:"connection_limit" yaml:"connection_limit" toml:"connection_limit"` ConnectionRetries int `json:"connection_retries" yaml:"connection_retries" toml:"connection_retries"` ConnectionTimeout time.Duration `json:"connection_timeout" yaml:"connection_timeout" toml:"connection_timeout"` KeepAlive time.Duration `json:"keep_alive" yaml:"keep_alive" toml:"keep_alive"` TcpUserTimeout time.Duration `json:"tcp_user_timeout" yaml:"tcp_user_timeout" toml:"tcp_user_timeout"` }
type Balancer ¶
type Balancer struct { LogLevel string `json:"log_level" toml:"log_level" yaml:"log_level"` // TODO usage CoordinatorAddress string `json:"coordinator_address" toml:"coordinator_address" yaml:"coordinator_address"` ShardsConfig string `json:"shards_config" yaml:"shards_config" toml:"shards_config"` // TODO set default values (probably the type needs to be de-exported) CpuThreshold float64 `json:"cpu_threshold" yaml:"cpu_threshold" toml:"cpu_threshold"` SpaceThreshold float64 `json:"space_threshold" yaml:"space_threshold" toml:"space_threshold"` StatIntervalSec int `json:"stat_interval_sec" yaml:"stat_interval_sec" toml:"stat_interval_sec"` MaxMoveCount int `json:"max_move_count" yaml:"max_move_count" toml:"max_move_count"` KeysPerMove int `json:"keys_per_move" yaml:"keys_per_move" toml:"keys_per_move"` TimeoutSec int `json:"timeout" yaml:"timeout" toml:"timeout"` }
func BalancerConfig ¶
func BalancerConfig() *Balancer
BalancerConfig returns a pointer to the Balancer configuration.
Returns:
- *Balancer: a pointer to the Balancer configuration.
type Coordinator ¶
type Coordinator struct { LogLevel string `json:"log_level" toml:"log_level" yaml:"log_level"` QdbAddr string `json:"qdb_addr" toml:"qdb_addr" yaml:"qdb_addr"` CoordinatorPort string `json:"coordinator_port" toml:"coordinator_port" yaml:"coordinator_port"` GrpcApiPort string `json:"grpc_api_port" toml:"grpc_api_port" yaml:"grpc_api_port"` Host string `json:"host" toml:"host" yaml:"host"` Auth *AuthCfg `json:"auth" toml:"auth" yaml:"auth"` FrontendTLS *TLSConfig `json:"frontend_tls" yaml:"frontend_tls" toml:"frontend_tls"` ShardDataCfg string `json:"shard_data" toml:"shard_data" yaml:"shard_data"` UseSystemdNotifier bool `json:"use_systemd_notifier" toml:"use_systemd_notifier" yaml:"use_systemd_notifier"` SystemdNotifierDebug bool `json:"systemd_notifier_debug" toml:"systemd_notifier_debug" yaml:"systemd_notifier_debug"` }
func CoordinatorConfig ¶
func CoordinatorConfig() *Coordinator
CoordinatorConfig returns a pointer to the Coordinator configuration.
Returns:
- *Coordinator: a pointer to the Coordinator configuration.
type DatatransferConnections ¶
type DatatransferConnections struct {
ShardsData map[string]*ShardConnect `json:"shards" toml:"shards" yaml:"shards"`
}
func LoadShardDataCfg ¶
func LoadShardDataCfg(cfgPath string) (*DatatransferConnections, error)
LoadShardDataCfg loads the shard data configuration from the given file path.
Parameters: - cfgPath (string): The path to the configuration file.
Returns: - *DatatransferConnections: A pointer to the loaded DatatransferConnections struct. - error: An error if the file cannot be opened or the configuration cannot be initialized.
type DefaultRouteBehaviour ¶
type DefaultRouteBehaviour string
type FrontendRule ¶
type FrontendRule struct { DB string `json:"db" yaml:"db" toml:"db"` Usr string `json:"usr" yaml:"usr" toml:"usr"` SearchPath string `json:"search_path" yaml:"search_path" toml:"search_path"` AuthRule *AuthCfg `json:"auth_rule" yaml:"auth_rule" toml:"auth_rule"` // TODO validate PoolMode PoolMode `json:"pool_mode" yaml:"pool_mode" toml:"pool_mode"` PoolDiscard bool `json:"pool_discard" yaml:"pool_discard" toml:"pool_discard"` PoolRollback bool `json:"pool_rollback" yaml:"pool_rollback" toml:"pool_rollback"` PoolPreparedStatement bool `json:"pool_prepared_statement" yaml:"pool_prepared_statement" toml:"pool_prepared_statement"` PoolDefault bool `json:"pool_default" yaml:"pool_default" toml:"pool_default"` }
type LDAPAuthMode ¶
type LDAPAuthMode string
type LDAPCfg ¶
type LDAPCfg struct { AuthMode LDAPAuthMode `json:"ldap_auth_mode" yaml:"ldap_auth_mode" toml:"ldap_auth_mode"` ConnConfig *LDAPConnCfg `json:"ldap_conn_config" yaml:"ldap_conn_config" toml:"ldap_conn_config"` Servers []string `json:"servers" yaml:"servers" toml:"servers"` Prefix string `json:"prefix" yaml:"prefix" toml:"prefix"` Suffix string `json:"suffix" yaml:"suffix" toml:"suffix"` BindDN string `json:"bind_dn" yaml:"bind_dn" toml:"bind_dn"` BindPassword string `json:"bind_password" yaml:"bind_password" toml:"bind_password"` BaseDN string `json:"base_dn" yaml:"base_dn" toml:"base_dn"` SearchAttribute string `json:"search_attribute" yaml:"search_attribute" toml:"search_attribute"` SearchFilter string `json:"search_filter" yaml:"search_filter" toml:"search_filter"` }
func (*LDAPCfg) CheckSearchResult ¶
func (*LDAPCfg) DoSearchRequest ¶
func (*LDAPCfg) ModifySearchAttribute ¶
func (*LDAPCfg) ModifySearchFilter ¶
func (*LDAPCfg) SearchBind ¶
func (*LDAPCfg) ServerConn ¶
type LDAPConnCfg ¶
type LDAPConnCfg struct { ConnMode LDAPConnMode `json:"ldap_conn_mode" yaml:"ldap_conn_mode" toml:"ldap_conn_mode"` Scheme string `json:"scheme" yaml:"scheme" toml:"scheme"` Port string `json:"port" yaml:"port" toml:"port"` TLSConfig *LDAPTLSCfg `json:"ldap_tls_config" yaml:"ldap_tls_config" toml:"ldap_tls_config"` }
type LDAPConnMode ¶
type LDAPConnMode string
type LDAPTLSCfg ¶
type LDAPTLSCfg struct { TLSVerifyMode LDAPTLSVerifyMode `json:"tls_verify_mode" yaml:"tls_verify_mode" toml:"tls_verify_mode"` RootCertFile string `json:"root_cert_file" toml:"root_cert_file" yaml:"root_cert_file"` CertFile string `json:"cert_file" toml:"cert_file" yaml:"cert_file"` KeyFile string `json:"key_file" toml:"key_file" yaml:"key_file"` }
type LDAPTLSVerifyMode ¶
type LDAPTLSVerifyMode string
type QRouter ¶
type QRouter struct { DefaultRouteBehaviour DefaultRouteBehaviour `json:"default_route_behaviour" toml:"default_route_behaviour" yaml:"default_route_behaviour"` EnhancedMultiShardProcessing bool `json:"enhanced_multishard_processing" toml:"enhanced_multishard_processing" yaml:"enhanced_multishard_processing"` }
type Router ¶
type Router struct { LogLevel string `json:"log_level" toml:"log_level" yaml:"log_level"` TimeQuantiles []float64 `json:"time_quantiles" toml:"time_quantiles" yaml:"time_quantiles"` Daemonize bool `json:"daemonize" toml:"daemonize" yaml:"daemonize"` MaintainParams bool `json:"maintain_params" toml:"maintain_params" yaml:"maintain_params"` WithJaeger bool `json:"with_jaeger" toml:"with_jaeger" yaml:"with_jaeger"` PgprotoDebug bool `json:"pgproto_debug" toml:"pgproto_debug" yaml:"pgproto_debug"` PidFileName string `json:"pid_filename" toml:"pid_filename" yaml:"pid_filename"` LogFileName string `json:"log_filename" toml:"log_filename" yaml:"log_filename"` AvailabilityZone string `json:"availability_zone" toml:"availability_zone" yaml:"availability_zone"` PreferSameAvailabilityZone bool `json:"prefer_same_availability_zone" toml:"prefer_same_availability_zone" yaml:"prefer_same_availability_zone"` Host string `json:"host" toml:"host" yaml:"host"` RouterPort string `json:"router_port" toml:"router_port" yaml:"router_port"` RouterROPort string `json:"router_ro_port" toml:"router_ro_port" yaml:"router_ro_port"` AdminConsolePort string `json:"admin_console_port" toml:"admin_console_port" yaml:"admin_console_port"` GrpcApiPort string `json:"grpc_api_port" toml:"grpc_api_port" yaml:"grpc_api_port"` WorldShardFallback bool `json:"world_shard_fallback" toml:"world_shard_fallback" yaml:"world_shard_fallback"` ShowNoticeMessages bool `json:"show_notice_messages" toml:"show_notice_messages" yaml:"show_notice_messages"` InitSQL string `json:"init_sql" toml:"init_sql" yaml:"init_sql"` UseInitSQL bool `json:"use_init_sql" toml:"use_init_sql" yaml:"use_init_sql"` UseCoordinatorInit bool `json:"use_coordinator_init" toml:"use_coordinator_init" yaml:"use_coordinator_init"` /* default */ DefaultTSA string `json:"default_target_session_attrs" toml:"default_target_session_attrs" yaml:"default_target_session_attrs"` MemqdbBackupPath string `json:"memqdb_backup_path" toml:"memqdb_backup_path" yaml:"memqdb_backup_path"` MemqdbPersistent bool `json:"memqdb_persistent" toml:"memqdb_persistent" yaml:"memqdb_persistent"` RouterMode string `json:"router_mode" toml:"router_mode" yaml:"router_mode"` JaegerUrl string `json:"jaeger_url" toml:"jaeger_url" yaml:"jaeger_url"` FrontendRules []*FrontendRule `json:"frontend_rules" toml:"frontend_rules" yaml:"frontend_rules"` Qr QRouter `json:"query_routing" toml:"query_routing" yaml:"query_routing"` FrontendTLS *TLSConfig `json:"frontend_tls" yaml:"frontend_tls" toml:"frontend_tls"` BackendRules []*BackendRule `json:"backend_rules" toml:"backend_rules" yaml:"backend_rules"` ShardMapping map[string]*Shard `json:"shards" toml:"shards" yaml:"shards"` SchemaCacheBackendRule *BackendRule `json:"schema_cache_backend_rule" toml:"schema_cache_backend_rule" yaml:"schema_cache_backend_rule"` WorkloadFile string `json:"workload_file" toml:"workload_file" yaml:"workload_file"` WorkloadBatchSize int `json:"workload_batch_size" toml:"workload_batch_size" yaml:"workload_batch_size"` ReusePort bool `json:"reuse_port" toml:"reuse_port" yaml:"reuse_port"` WithCoordinator bool `json:"with_coordinator" toml:"with_coordinator" yaml:"with_coordinator"` UseSystemdNotifier bool `json:"use_systemd_notifier" toml:"use_systemd_notifier" yaml:"use_systemd_notifier"` SystemdNotifierDebug bool `json:"systemd_notifier_debug" toml:"systemd_notifier_debug" yaml:"systemd_notifier_debug"` }
func RouterConfig ¶
func RouterConfig() *Router
RouterConfig returns the router configuration.
Parameters: - None.
Returns: - *Router: a pointer to the router configuration struct.
type RouterMode ¶
type RouterMode string
type Shard ¶
type ShardConnect ¶
type TLSConfig ¶
type TLSConfig struct { SslMode string `json:"sslmode" toml:"sslmode" yaml:"sslmode"` KeyFile string `json:"key_file" toml:"key_file" yaml:"key_file"` CertFile string `json:"cert_file" toml:"cert_file" yaml:"cert_file"` RootCertFile string `json:"root_cert_file" toml:"root_cert_file" yaml:"root_cert_file"` }
https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION
func (*TLSConfig) Init ¶
Init initializes the TLS configuration based on the provided host and TLSConfig struct.
Parameters: - host (string): The host to connect to. - c (*TLSConfig): A pointer to the TLSConfig struct.
Returns: - (*tls.Config, error): The initialized TLS configuration and an error if any occurred.