Documentation ¶
Overview ¶
Package etcdregistry provides a library for registering and retrieving service nodes from etcd.
Index ¶
- type EtcdRegistry
- func (r *EtcdRegistry) Close() error
- func (r *EtcdRegistry) CreateOrJoinServiceGroup(ctx context.Context, groupName string) (*types.ServiceGroup, error)
- func (r *EtcdRegistry) DeleteNode(ctx context.Context, groupName string, node types.Node) error
- func (r *EtcdRegistry) GetClient() *clientv3.Client
- func (r *EtcdRegistry) GetEtcdBasePath() string
- func (r *EtcdRegistry) GetNodes(ctx context.Context, servicePath string) ([]types.Node, error)
- func (r *EtcdRegistry) GetServiceGroup(ctx context.Context, groupName string) (*types.ServiceGroup, error)
- func (r *EtcdRegistry) GetServiceGroups(ctx context.Context) ([]string, error)
- func (r *EtcdRegistry) NodePath(groupName string, node types.Node) string
- func (r *EtcdRegistry) RegisterNodeWithRetry(ctx context.Context, groupName string, node types.Node, ttl time.Duration, ...)
- func (r *EtcdRegistry) ServicePath(groupName string) string
- func (r *EtcdRegistry) UpdateServiceGroupConfig(ctx context.Context, groupName string, ...) error
- func (r *EtcdRegistry) WatchGroup(ctx context.Context, groupName string) (<-chan types.WatchEvent, error)
- func (r *EtcdRegistry) WatchGroupNodes(ctx context.Context, groupName string) (<-chan types.WatchEvent, error)
- func (r *EtcdRegistry) WatchServices(ctx context.Context) (<-chan types.WatchEvent, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EtcdRegistry ¶
type EtcdRegistry struct {
// contains filtered or unexported fields
}
func NewEtcdRegistry ¶
func NewEtcdRegistry(etcdEndpoints []string, etcdBasePath string, etcdUsername string, etcdPassword string, defaultTimeout time.Duration, maxRetries int) (*EtcdRegistry, error)
NewEtcdRegistry creates a new EtcdRegistry instance.
Args:
etcdEndpoints ([]string): The endpoints for the etcd cluster. etcdBasePath (string): The base path for all etcd operations. etcdUsername (string): The username for etcd authentication. etcdPassword (string): The password for etcd authentication. defaultTimeout (time.Duration): The default timeout for etcd operations.
Returns:
*EtcdRegistry: A new EtcdRegistry instance. error: An error if the instance could not be created.
func (*EtcdRegistry) Close ¶
func (r *EtcdRegistry) Close() error
Close gracefully shuts down the registry and cleans up resources
func (*EtcdRegistry) CreateOrJoinServiceGroup ¶
func (r *EtcdRegistry) CreateOrJoinServiceGroup(ctx context.Context, groupName string) (*types.ServiceGroup, error)
CreateOrJoinServiceGroup ensures a group exists and returns a ServiceGroup instance
func (*EtcdRegistry) DeleteNode ¶
DeleteNode removes a node from etcd
func (*EtcdRegistry) GetClient ¶
func (r *EtcdRegistry) GetClient() *clientv3.Client
GetClient returns the etcd client instance
func (*EtcdRegistry) GetEtcdBasePath ¶
func (r *EtcdRegistry) GetEtcdBasePath() string
GetEtcdBasePath returns the base path for etcd operations
func (*EtcdRegistry) GetServiceGroup ¶
func (r *EtcdRegistry) GetServiceGroup(ctx context.Context, groupName string) (*types.ServiceGroup, error)
GetServiceGroup retrieves group configuration
func (*EtcdRegistry) GetServiceGroups ¶
func (r *EtcdRegistry) GetServiceGroups(ctx context.Context) ([]string, error)
GetServiceGroups returns a list of all service group names under the base path
func (*EtcdRegistry) NodePath ¶
func (r *EtcdRegistry) NodePath(groupName string, node types.Node) string
NodePath returns the path for a specific exporter node
func (*EtcdRegistry) RegisterNodeWithRetry ¶
func (r *EtcdRegistry) RegisterNodeWithRetry(ctx context.Context, groupName string, node types.Node, ttl time.Duration, done chan<- struct{}, errChan chan error)
RegisterNodeWithRetry handles the node registration retry loop
func (*EtcdRegistry) ServicePath ¶
func (r *EtcdRegistry) ServicePath(groupName string) string
ServicePath returns the path for a service group's nodes
func (*EtcdRegistry) UpdateServiceGroupConfig ¶
func (r *EtcdRegistry) UpdateServiceGroupConfig(ctx context.Context, groupName string, updateFn func(*types.ServiceGroup) error) error
UpdateServiceGroupConfig updates group configuration using CAS operations
func (*EtcdRegistry) WatchGroup ¶
func (r *EtcdRegistry) WatchGroup(ctx context.Context, groupName string) (<-chan types.WatchEvent, error)
WatchGroup watches for changes in a specific service group
func (*EtcdRegistry) WatchGroupNodes ¶
func (r *EtcdRegistry) WatchGroupNodes(ctx context.Context, groupName string) (<-chan types.WatchEvent, error)
WatchGroupNodes watches for node changes in a specific service group
func (*EtcdRegistry) WatchServices ¶
func (r *EtcdRegistry) WatchServices(ctx context.Context) (<-chan types.WatchEvent, error)
WatchServices watches for all service and node changes