themisclient

package
v0.0.0-...-e82ecba Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceMark        = "service"
	DefaultClusterName = "/"
)

Variables

View Source
var DefaultConfigration = func() *Config {
	return &Config{
		LoadBalancerName: loadbalance.DefaultName,
		CodecType:        codec.Json,
		RetryNum:         3,
	}
}
View Source
var ErrorServerNameAddressNil = errors.New("server name or address nil")

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config) (*Client, error)

func (*Client) Delete

func (c *Client) Delete(key string) error

func (*Client) DiscoveryService

func (c *Client) DiscoveryService(serviceName string) ([]*Instance, error)

func (*Client) Get

func (c *Client) Get(key string) (*themis.KV, error)

func (*Client) Heartbeat

func (c *Client) Heartbeat(instance *Instance) error

func (*Client) ListAllKV

func (c *Client) ListAllKV() ([]*themis.KV, error)

func (*Client) RegisterInstance

func (c *Client) RegisterInstance(instance *Instance) error

func (*Client) RegisterInstanceWithHeartbeat

func (c *Client) RegisterInstanceWithHeartbeat(instance *Instance, heartbeatTimeout time.Duration) error

func (*Client) RegisterInstanceWithIP

func (c *Client) RegisterInstanceWithIP(serviceName, ip string, port int) error

func (*Client) RegisterInstanceWithIPCluster

func (c *Client) RegisterInstanceWithIPCluster(serviceName, clusterName, ip string, port int) error

func (*Client) SearchByPrefix

func (c *Client) SearchByPrefix(prefix string) ([]*themis.KV, error)

func (*Client) Set

func (c *Client) Set(key string, value interface{}) error

func (*Client) SetWithExpireTime

func (c *Client) SetWithExpireTime(key string, value interface{}, ttl time.Duration) error

func (*Client) Watch

func (c *Client) Watch(key string, op OperateType, callback WatchCallback) error

func (*Client) WatchStream

func (c *Client) WatchStream(key string, op OperateType, callback WatchCallback) error

type Config

type Config struct {
	ServerName    string
	ServerAddress string

	LoadBalancerName string
	CodecType        string

	RetryNum int
}

func NewConfigration

func NewConfigration(opts ...Option) *Config

type Info

type Info struct {
	LeaderName string
	Term       int32
	Servers    map[string]string
}

type Instance

type Instance struct {
	ServiceName string
	ClusterName string
	IP          string
	Port        int
	IsHealthy   bool
	TTL         time.Duration
	MetaData    []byte
}

type OperateType

type OperateType int32
const (
	ALL    OperateType = 0
	Set    OperateType = 1
	Get    OperateType = 2
	Delete OperateType = 3
	Write  OperateType = 4
	Expire OperateType = 5
)

type Option

type Option func(*Config)

func WithCodecType

func WithCodecType(t string) Option

func WithLoadBalancerName

func WithLoadBalancerName(name string) Option

func WithRetryNum

func WithRetryNum(num int) Option

func WithServerAddress

func WithServerAddress(addr string) Option

func WithServerName

func WithServerName(name string) Option

type WatchCallback

type WatchCallback func(preKV, kv *themis.KV, t OperateType) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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