etcd

package
v0.0.50-alpha.76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 19 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, etcdServers []string, etcdRoot string, createIfNotExist bool, options ...ZkOption) error

Check verifies if etcd is running by checking the existence of the root node and optionally creates it with a lease

Types

type SvcDiscoveryRegistryImpl

type SvcDiscoveryRegistryImpl struct {
	// contains filtered or unexported fields
}

SvcDiscoveryRegistryImpl implementation

func NewSvcDiscoveryRegistry

func NewSvcDiscoveryRegistry(rootDirectory string, endpoints []string, watchNames []string, options ...ZkOption) (*SvcDiscoveryRegistryImpl, error)

NewSvcDiscoveryRegistry creates a new service discovery registry implementation

func (*SvcDiscoveryRegistryImpl) AddOption

func (r *SvcDiscoveryRegistryImpl) AddOption(opts ...grpc.DialOption)

AddOption appends gRPC dial options to the existing options

func (*SvcDiscoveryRegistryImpl) Close

func (r *SvcDiscoveryRegistryImpl) Close()

Close closes the etcd client connection

func (*SvcDiscoveryRegistryImpl) DelData

func (r *SvcDiscoveryRegistryImpl) DelData(ctx context.Context, key string) error

func (*SvcDiscoveryRegistryImpl) GetClient

func (r *SvcDiscoveryRegistryImpl) GetClient() *clientv3.Client

func (*SvcDiscoveryRegistryImpl) GetConn

func (r *SvcDiscoveryRegistryImpl) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (grpc.ClientConnInterface, error)

GetConn returns a single gRPC client connection for a given service name

func (*SvcDiscoveryRegistryImpl) GetConns

func (r *SvcDiscoveryRegistryImpl) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]grpc.ClientConnInterface, error)

GetConns returns gRPC client connections for a given service name

func (*SvcDiscoveryRegistryImpl) GetKey

func (r *SvcDiscoveryRegistryImpl) GetKey(ctx context.Context, key string) ([]byte, error)

func (*SvcDiscoveryRegistryImpl) GetSelfConnTarget

func (r *SvcDiscoveryRegistryImpl) GetSelfConnTarget() string

GetSelfConnTarget returns the connection target for the current service

func (*SvcDiscoveryRegistryImpl) GetUserIdHashGatewayHost

func (r *SvcDiscoveryRegistryImpl) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error)

GetUserIdHashGatewayHost returns the gateway host for a given user ID hash

func (*SvcDiscoveryRegistryImpl) IsSelfNode

func (*SvcDiscoveryRegistryImpl) Register

func (r *SvcDiscoveryRegistryImpl) Register(ctx context.Context, serviceName, host string, port int, opts ...grpc.DialOption) error

Register registers a new service endpoint with etcd

func (*SvcDiscoveryRegistryImpl) SetKey

func (r *SvcDiscoveryRegistryImpl) SetKey(ctx context.Context, key string, data []byte) error

func (*SvcDiscoveryRegistryImpl) UnRegister

func (r *SvcDiscoveryRegistryImpl) UnRegister() error

UnRegister removes the service endpoint from etcd

func (*SvcDiscoveryRegistryImpl) WatchKey

type ZkOption

type ZkOption func(*clientv3.Config)

ZkOption defines a function type for modifying clientv3.Config

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) ZkOption

WithDialTimeout sets a custom dial timeout for the etcd client

func WithMaxCallSendMsgSize

func WithMaxCallSendMsgSize(size int) ZkOption

WithMaxCallSendMsgSize sets a custom max call send message size for the etcd client

func WithUsernameAndPassword

func WithUsernameAndPassword(username, password string) ZkOption

WithUsernameAndPassword sets a username and password for the etcd client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL