Documentation
¶
Index ¶
- Constants
- Variables
- func CreateTLSConfig(rootCAFile, certFile, keyFile string) (*tls.Config, error)
- func GetTLSDialer(dialer *net.Dialer, tlsConfig *tls.Config) (zk.Dialer, error)
- func JoinPath(parts ...string) string
- type DCS
- type ExtendedLockDCS
- type LockOwner
- type RandomHostProvider
- type RandomHostProviderConfig
- type ZookeeperConfig
Constants ¶
View Source
const (
PathHANodesPrefix = "ha_nodes"
)
Variables ¶
View Source
var ( // ErrExists means that node being created already exists ErrExists = errors.New("key already exists") // ErrNotFound means that requested not does not exist ErrNotFound = errors.New("key was not found in DCS") // ErrMalformed means that we failed to unmarshall received data ErrMalformed = errors.New("failed to parse DCS value, possibly data format changed") )
Functions ¶
func CreateTLSConfig ¶
Types ¶
type DCS ¶
type DCS interface {
IsConnected() bool
WaitConnected(timeout time.Duration) bool
Initialize() // Create initial data structure if not exists
SetDisconnectCallback(callback func() error)
AcquireLock(path string) bool
ReleaseLock(path string)
Create(path string, value any) error
CreateEphemeral(path string, value any) error
Set(path string, value any) error
SetEphemeral(path string, value any) error
Get(path string, dest any) error
Delete(path string) error
GetTree(path string) (any, error)
GetChildren(path string) ([]string, error)
Close()
}
DCS is the main interface representing data store DCS implementation should maintain connection to a server, track connection status changes (connected/disconnected) and perform basic operations
func NewZookeeper ¶
NewZookeeper returns Zookeeper based DCS storage
type ExtendedLockDCS ¶
type RandomHostProvider ¶
type RandomHostProvider struct {
// contains filtered or unexported fields
}
func NewRandomHostProvider ¶
func NewRandomHostProvider(ctx context.Context, config *RandomHostProviderConfig, useAddrs bool, logger *slog.Logger) *RandomHostProvider
func (*RandomHostProvider) Connected ¶
func (rhp *RandomHostProvider) Connected()
func (*RandomHostProvider) Init ¶
func (rhp *RandomHostProvider) Init(servers []string) error
func (*RandomHostProvider) Len ¶
func (rhp *RandomHostProvider) Len() int
func (*RandomHostProvider) Next ¶
func (rhp *RandomHostProvider) Next() (server string, retryStart bool)
type RandomHostProviderConfig ¶
type RandomHostProviderConfig struct {
LookupTimeout time.Duration `config:"lookup_timeout" yaml:"lookup_timeout"`
LookupTTL time.Duration `config:"lookup_ttl" yaml:"lookup_ttl"`
LookupTickInterval time.Duration `config:"lookup_tick_interval" yaml:"lookup_tick_interval"`
ConnectivityCheckTimeout time.Duration `config:"connectivity_check_timeout" yaml:"connectivity_check_timeout"`
RetryJitter time.Duration `config:"retry_jitter" yaml:"retry_jitter"`
}
func DefaultRandomHostProviderConfig ¶
func DefaultRandomHostProviderConfig() RandomHostProviderConfig
type ZookeeperConfig ¶
type ZookeeperConfig struct {
CACert string `config:"ca_cert" yaml:"ca_cert"`
Namespace string `config:"namespace,required" yaml:"namespace"`
Hostname string `config:"hostname" yaml:"hostname"`
CertFile string `config:"certfile" yaml:"certfile"`
KeyFile string `config:"keyfile" yaml:"keyfile"`
Password string `config:"password" yaml:"password"`
Username string `config:"username" yaml:"username"`
Hosts []string `config:"hosts,required" yaml:"hosts"`
RandomHostProvider RandomHostProviderConfig `config:"random_host_provider" yaml:"random_host_provider"`
BackoffInterval time.Duration `config:"backoff_interval" yaml:"backoff_interval"`
BackoffMaxRetries uint64 `config:"backoff_max_retries" yaml:"backoff_max_retries"`
BackoffMaxElapsedTime time.Duration `config:"backoff_max_elapsed_time" yaml:"backoff_max_elapsed_time"`
BackoffMaxInterval time.Duration `config:"backoff_max_interval" yaml:"backoff_max_interval"`
BackoffMultiplier float64 `config:"backoff_multiplier" yaml:"backoff_multiplier"`
BackoffRandFactor float64 `config:"backoff_rand_factor" yaml:"backoff_rand_factor"`
SessionTimeout time.Duration `config:"session_timeout" yaml:"session_timeout"`
Auth bool `config:"auth" yaml:"auth"`
UseSSL bool `config:"use_ssl" yaml:"use_ssl"`
VerifyCerts bool `config:"verify_certs" yaml:"verify_certs"`
}
ZookeeperConfig contains Zookeeper connection info
func DefaultZookeeperConfig ¶
func DefaultZookeeperConfig() (ZookeeperConfig, error)
DefaultZookeeperConfig returns default Zookeeper connection configuration
Click to show internal directories.
Click to hide internal directories.