client

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: GPL-3.0 Imports: 14 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 = 8

Variables

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

Functions

func BString

func BString(b []byte) string

func LockID

func LockID() string

func MaxOpenConn

func MaxOpenConn() int64

func Namespace

func Namespace(s string) *string

func NewLeaderMonitorReceiver

func NewLeaderMonitorReceiver() *chan bool

func SetBalancer

func SetBalancer(balancer Balancer)

func SetMaxOpenConn

func SetMaxOpenConn(size int64)

Types

type Balancer

type Balancer int32
const (
	RoundRobin Balancer = iota
	RoundRand
)

type BalancerConn

type BalancerConn struct {
	ID string
	*grpc.ClientConn
}

func (*BalancerConn) Key

func (c *BalancerConn) Key() string

func (*BalancerConn) Value

func (c *BalancerConn) Value() *grpc.ClientConn

type Client

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

func New

func New(ctx context.Context, endpoints []string, opts ...grpc.DialOption) (*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, opts ...grpc.DialOption) (Conn, error)

type ConnectionManager

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

func NewConnectionManager

func NewConnectionManager(ctx context.Context, endpoint string, maxConn int, opts ...grpc.DialOption) (*ConnectionManager, error)

func (*ConnectionManager) Alloc

func (m *ConnectionManager) Alloc() (*grpc.ClientConn, error)

func (*ConnectionManager) Close

func (m *ConnectionManager) Close() error

func (*ConnectionManager) Target

func (m *ConnectionManager) Target() string

type InternalClient

type InternalClient interface {
	AppendCluster(ctx context.Context, serverID string, peerAddr string, voter bool) error
	LeaderMonitor(ctx context.Context, recv *chan bool) error
	Snapshot(ctx context.Context, serverPath *string) 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)
	PrefixScan(ctx context.Context, prefix []byte, offset, limit uint64, reg, namespace *string) ([]*Value, error)
	TrySet(ctx context.Context, key, value []byte, ttl uint32, namespace *string) error
	Delete(ctx context.Context, key []byte, namespace *string) error
	Watch(ctx context.Context, watcher *Watcher) error
	WatchPrefix(ctx context.Context, watcher *Watcher) error
}

type LockerClient

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

type MutexLock

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

func NewMutexLock

func NewMutexLock(ctx context.Context, client LockerClient, ttl int32, assetID string) *MutexLock

func (*MutexLock) AssetID

func (l *MutexLock) AssetID(assetID string)

func (*MutexLock) Lock

func (l *MutexLock) Lock() error

func (*MutexLock) TryLock

func (l *MutexLock) TryLock(deadline time.Time) error

func (*MutexLock) Unlock

func (l *MutexLock) Unlock() error

type Value

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

type WatchValue

type WatchValue struct {
	Timestamp int64
	TTL       uint32
	Key       []byte
	Value     []byte
	// contains filtered or unexported fields
}

type Watcher

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

func NewWatcher

func NewWatcher(key []byte, 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 WatchWithIgnoreErrors

func WatchWithIgnoreErrors() WatcherOption

func WatchWithNamespace

func WatchWithNamespace(namespace *string) WatcherOption

func WatchWithPrefix

func WatchWithPrefix() WatcherOption

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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