client

package
v0.0.0-...-500d50b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WatchLockOk      = 1
	WatchLockTimeout = 0
)

Variables

This section is empty.

Functions

func GetCtxTimeout

func GetCtxTimeout(second int) (context.Context, context.CancelFunc)

Types

type Client

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

func (*Client) DeleteKey

func (c *Client) DeleteKey(key string, opts ...v3.OpOption) (*v3.DeleteResponse, error)

func (*Client) GetKey

func (c *Client) GetKey(key string, opts ...v3.OpOption) (*v3.GetResponse, error)

func (*Client) GetRespFrom

func (c *Client) GetRespFrom()

func (*Client) GetSessionKey

func (c *Client) GetSessionKey(key string) *concurrency.Mutex

func (*Client) KeyClock

func (c *Client) KeyClock(l *concurrency.Mutex, excute func()) chan *EctdResp

KeyClock waiting key free until ctx timeout, it will return err or key

func (*Client) PutKey

func (c *Client) PutKey(key, val string, opts ...v3.OpOption) (*v3.PutResponse, error)

func (*Client) WatchKey

func (c *Client) WatchKey(key string, ctx context.Context, opts ...v3.OpOption) chan *v3.Event

WatchKey return event when key was change, input is could be context timeout or call cancel func when stop watch

type Connection

type Connection interface {
	WatchKey(key string, ctx context.Context, opts ...v3.OpOption) chan *v3.Event
	PutKey(key, val string, opts ...v3.OpOption) (*v3.PutResponse, error)
	GetKey(key string, opts ...v3.OpOption) (*v3.GetResponse, error)
	DeleteKey(key string, opts ...v3.OpOption) (*v3.DeleteResponse, error)
	GetSessionKey(key string) *concurrency.Mutex
	KeyClock(l *concurrency.Mutex, excute func()) chan *EctdResp
}

func Connect

func Connect(url string, cfg *EtcdCfg) (Connection, error)

type EctdResp

type EctdResp struct {
	Data interface{}
	Err  error
}

type EtcdCfg

type EtcdCfg struct {
	DialTimeout    time.Duration
	RequestTimeout time.Duration
	SessionTTL     int
}

Jump to

Keyboard shortcuts

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