client

package
v0.2.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

README

about r_<service> files, implement basic calls to service and do not provide advanced functions

Documentation

Index

Constants

View Source
const DefaultWatchBufSize uint32 = 4

Variables

View Source
var (
	ErrWatcherClosed = errors.New("watcher has closed")
)

Functions

func LockID

func LockID() string

func Namespace

func Namespace(s string) *string

Types

type Client

type Client struct {
	InternalClient
	KvClient
	LockerClient
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, endpoints []string, syncConn bool) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

type Conn

type Conn interface {
	ReadOnly() (*grpc.ClientConn, error)
	WriteOnly() (*grpc.ClientConn, error)
	Close() error
}

func NewClientConn

func NewClientConn(ctx context.Context, endpoints []string, syncConn bool) (Conn, error)

type InternalClient

type InternalClient interface {
	AppendCluster(ctx context.Context, serverID string, peerAddr string, voter bool) error
	LeaderMonitor(ctx context.Context, recv *chan bool) error
}

type KvClient

type KvClient interface {
	Set(ctx context.Context, key, value []byte, ttl uint32, namespace *string) error
	Get(ctx context.Context, key []byte, namespace *string) (*Value, error)
	Delete(ctx context.Context, key []byte, namespace *string) error
	Watch(ctx context.Context, watcher *Watcher) error
}

type LockerClient

type LockerClient interface {
	Lock(ctx context.Context, lockID string, ttl int64) error
	Unlock(ctx context.Context, lockID string) error
	TryLock(ctx context.Context, lockID string, ttl, deadline int64) error
}

type Value

type Value struct {
	Data []byte
	TTL  *uint32
}

type WatchValue

type WatchValue struct {
	Timestamp int64
	Data      []byte
	// contains filtered or unexported fields
}

type Watcher

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

func NewWatcher

func NewWatcher(key []byte, ignoreErrors bool, opts ...WatcherOption) *Watcher

func (*Watcher) Close

func (w *Watcher) Close() error

func (*Watcher) Notify

func (w *Watcher) Notify() (chan *WatchValue, error)

type WatcherOption

type WatcherOption func(*Watcher)

func WatchWithBufSize

func WatchWithBufSize(bufSize uint32) WatcherOption

func WatchWithNamespace

func WatchWithNamespace(namespace *string) WatcherOption

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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