etcd

package
v0.0.49-alpha.39 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 14 Imported by: 9

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, 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) CloseConn

func (r *SvcDiscoveryRegistryImpl) CloseConn(conn *grpc.ClientConn)

CloseConn closes a given gRPC client connection

func (*SvcDiscoveryRegistryImpl) GetConn

func (r *SvcDiscoveryRegistryImpl) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, 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.ClientConn, error)

GetConns returns gRPC client connections for a given service name

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) Register

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

Register registers a new service endpoint with etcd

func (*SvcDiscoveryRegistryImpl) UnRegister

func (r *SvcDiscoveryRegistryImpl) UnRegister() error

UnRegister removes the service endpoint from etcd

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