Documentation ¶
Overview ¶
Package etcd provides an implementation of the Storage interface defined in the Rigel project. It uses the etcd.
Index ¶
- type EtcdStorage
- func (e *EtcdStorage) Get(ctx context.Context, key string) (string, error)
- func (e *EtcdStorage) GetWithPrefix(ctx context.Context, prefix string) (map[string]string, error)
- func (e *EtcdStorage) Put(ctx context.Context, key string, value string) error
- func (e *EtcdStorage) StatusCheck(ctx context.Context) error
- func (e *EtcdStorage) Watch(ctx context.Context, key string, events chan<- types.Event) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EtcdStorage ¶
EtcdStorage is implements Rigel's Storage interface using etcd v3 client.
func NewEtcdStorage ¶
func NewEtcdStorage(endpoints []string, config ...clientv3.Config) (*EtcdStorage, error)
NewEtcdStorage creates a new instance of EtcdStorage using the provided endpoints with default settings from the package. If an optional clientv3.Config is supplied, it is used to configure the etcd client, overriding the default settings.
func (*EtcdStorage) Get ¶
Get retrieves a value from etcd based on the provided key. The function returns the corresponding value as a string. If the key does not exist in etcd, the function returns an empty string and no error. If an error occurs during the operation, it is returned by the function.
func (*EtcdStorage) GetWithPrefix ¶ added in v0.12.0
GetWithPrefix retrieves all key-value pairs from etcd where the keys start with the provided prefix.
func (*EtcdStorage) Put ¶
Put stores a value in etcd at the specified key. The value is also stored as a string. If the key already exists in etcd, its value is updated with the new value. If the key does not exist, a new key-value pair is created in etcd. If an error occurs during the operation, it is returned by the function.
func (*EtcdStorage) StatusCheck ¶ added in v0.8.0
func (e *EtcdStorage) StatusCheck(ctx context.Context) error
StatusCheck checks the status of the etcd client. If the function succeeds, we can assume that the connection to the etcd server is working.
func (*EtcdStorage) Watch ¶ added in v0.9.0
Watch starts watching for changes to a key or a range of keys in etcd and sends the events to the provided channel. If the key is a prefix that matches multiple keys, it watches all those keys. key: The key to watch for changes events is the channel to send events when the key's value changes