themisclient

package module
v0.0.0-...-4b3ae3a Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 12 Imported by: 2

README

themisclient

Documentation

Index

Constants

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

Variables

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

Functions

This section is empty.

Types

type Client

type Client struct {
	// 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) Info

func (c *Client) Info() Info

func (*Client) ListAllKV

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

func (*Client) NodeInfo

func (c *Client) NodeInfo(name string) (NodeInfo, 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) SearchKVListFromNodeName

func (c *Client) SearchKVListFromNodeName(name 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

	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
	CreateTime  time.Time
	TTL         time.Duration
	MetaData    []byte
}

type NodeInfo

type NodeInfo struct {
	Name        string
	Address     string
	RaftAddress string
	Term        int32
	Role        string
	LogTerm     int32
	LogIndex    int32
}

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 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