Documentation ¶
Index ¶
- Constants
- func Module() fx.Option
- type Client
- func (etcdClient *Client) AddElectionWatcher(electionWatcher ElectionWatcher)
- func (etcdClient *Client) Delete(key string, opts ...clientv3.OpOption)
- func (etcdClient *Client) DeletePrefix(prefix string, opts ...clientv3.OpOption)
- func (etcdClient *Client) DeleteSync(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
- func (etcdClient *Client) ETCDClient() *clientv3.Client
- func (etcdClient *Client) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
- func (etcdClient *Client) IsLeader() bool
- func (etcdClient *Client) Put(key, val string, opts ...clientv3.OpOption)
- func (etcdClient *Client) PutSync(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
- func (etcdClient *Client) PutWithExpiry(key, val string, leaseTTL int, opts ...clientv3.OpOption)
- func (etcdClient *Client) RemoveElectionWatcher(electionWatcher ElectionWatcher)
- func (etcdClient *Client) Txn(ctx context.Context) (clientv3.Txn, error)
- func (etcdClient *Client) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) (clientv3.WatchChan, error)
- type ClientIn
- type ConfigOverride
- type ElectionWatcher
Constants ¶
const ( // ElectionPathFxTag is the fx tag for the election path. ElectionPathFxTag = "etcd.election-path" // EnforceLeaderOnlyFxTag is the fx tag for the enforce leader only flag. EnforceLeaderOnlyFxTag = "etcd.enforce-leader-only" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around etcd client.
func ProvideClient ¶
ProvideClient creates a new etcd Client and provides it via Fx.
func (*Client) AddElectionWatcher ¶ added in v2.22.0
func (etcdClient *Client) AddElectionWatcher(electionWatcher ElectionWatcher)
AddElectionWatcher adds a watcher for election changes.
func (*Client) DeletePrefix ¶ added in v2.22.0
DeletePrefix deletes all keys with the given prefix.
func (*Client) DeleteSync ¶ added in v2.22.0
func (etcdClient *Client) DeleteSync(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
DeleteSync deletes the given key.
func (*Client) ETCDClient ¶ added in v2.22.0
ETCDClient returns the underlying ETCD client.
func (*Client) Get ¶ added in v2.22.0
func (etcdClient *Client) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
Get gets the value for the given key.
func (*Client) PutSync ¶ added in v2.22.0
func (etcdClient *Client) PutSync(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
PutSync puts the given value for the given key.
func (*Client) PutWithExpiry ¶ added in v2.22.0
PutWithExpiry puts the given value for the given key and lease duration.
func (*Client) RemoveElectionWatcher ¶ added in v2.22.0
func (etcdClient *Client) RemoveElectionWatcher(electionWatcher ElectionWatcher)
RemoveElectionWatcher removes a watcher for election changes.
type ClientIn ¶
type ClientIn struct { fx.In Unmarshaller config.Unmarshaller Lifecycle fx.Lifecycle Shutdowner fx.Shutdowner Logger *log.Logger ConfigOverride *ConfigOverride `optional:"true"` ElectionPath string `name:"etcd.election-path" optional:"true"` EnforceLeaderOnly bool `name:"etcd.enforce-leader-only" optional:"true"` }
ClientIn holds parameters for ProvideClient.
type ConfigOverride ¶ added in v2.8.0
type ConfigOverride struct { PerRPCCredentials credentials.PerRPCCredentials // optional Namespace string // required OverriderName string // who is providing the override, for logs Endpoints []string // required }
ConfigOverride can be provided by an extension to provide parts of etcd client config directly.
type ElectionWatcher ¶ added in v2.22.0
type ElectionWatcher interface { OnLeaderStart() OnLeaderStop() }
ElectionWatcher is used for tracking changes to election.