registry

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// grpc does not allow to transport a large body more then 4MB in a request
	DefaultPageCount = 4096

	DefaultClusterName = "default"
)

Variables

This section is empty.

Functions

func ReportBackendInstance

func ReportBackendInstance(c int)

func ReportBackendOperationCompleted

func ReportBackendOperationCompleted(operation string, err error, start time.Time)

func WithTimeout

func WithTimeout(ctx context.Context) (context.Context, context.CancelFunc)

Types

type ActionType

type ActionType int
const (
	Get ActionType = iota
	Put
	Delete
)

func (ActionType) String

func (at ActionType) String() string

type CacheMode

type CacheMode int
const (
	ModeBoth CacheMode = iota
	ModeCache
	ModeNoCache
)

func (CacheMode) String

func (cm CacheMode) String() string

type CompareOp

type CompareOp struct {
	Key    []byte
	Type   CompareType
	Result CompareResult
	Value  interface{}
}

func OpCmp

func OpCmp(opt CompareOperation, result CompareResult, v interface{}) (cmp CompareOp)

func (CompareOp) String

func (op CompareOp) String() string

type CompareOperation

type CompareOperation func(op *CompareOp)

func CmpCreateRev

func CmpCreateRev(key []byte) CompareOperation

func CmpModRev

func CmpModRev(key []byte) CompareOperation

func CmpStrCreateRev

func CmpStrCreateRev(key string) CompareOperation

func CmpStrModRev

func CmpStrModRev(key string) CompareOperation

func CmpStrVal

func CmpStrVal(key string) CompareOperation

func CmpStrVer

func CmpStrVer(key string) CompareOperation

func CmpVal

func CmpVal(key []byte) CompareOperation

func CmpVer

func CmpVer(key []byte) CompareOperation

type CompareResult

type CompareResult int
const (
	CmpEqual CompareResult = iota
	CmpGreater
	CmpLess
	CmpNotEqual
)

func (CompareResult) String

func (cr CompareResult) String() string

type CompareType

type CompareType int
const (
	CmpVersion CompareType = iota
	CmpCreate
	CmpMod
	CmpValue
)

func (CompareType) String

func (ct CompareType) String() string

type Config

type Config struct {
	SslEnabled       bool           `json:"-"`
	ManagerAddress   string         `json:"manageAddress,omitempty"`
	ClusterName      string         `json:"manageName,omitempty"`
	ClusterAddresses string         `json:"manageClusters,omitempty"` // the raw string of cluster configuration
	Clusters         types.Clusters `json:"-"`                        // parsed from ClusterAddresses
	DialTimeout      time.Duration  `json:"connectTimeout"`
	RequestTimeOut   time.Duration  `json:"registryTimeout"`
	AutoSyncInterval time.Duration  `json:"autoSyncInterval"`
}

func Configuration

func Configuration() *Config

func (*Config) InitClusterInfo

func (c *Config) InitClusterInfo()

InitClusterInfo re-org address info with node name

func (*Config) RegistryAddresses

func (c *Config) RegistryAddresses() []string

RegistryAddresses return the address of current SC's registry backend

type Operation

type Operation func(...PluginOpOption) (op PluginOp)

type PluginOp

type PluginOp struct {
	Action        ActionType
	Key           []byte
	EndKey        []byte
	Value         []byte
	Prefix        bool
	PrevKV        bool
	Lease         int64
	KeyOnly       bool
	CountOnly     bool
	SortOrder     SortOrder
	Revision      int64
	IgnoreLease   bool
	Mode          CacheMode
	WatchCallback WatchCallback
	Offset        int64
	Limit         int64
	Global        bool
}

func OpDel

func OpDel(opts ...PluginOpOption) (op PluginOp)

func OpGet

func OpGet(opts ...PluginOpOption) (op PluginOp)

func OpPut

func OpPut(opts ...PluginOpOption) (op PluginOp)

func OptionsToOp

func OptionsToOp(opts ...PluginOpOption) (op PluginOp)

func (PluginOp) CacheOnly

func (op PluginOp) CacheOnly() bool

func (PluginOp) FormatURLParams

func (op PluginOp) FormatURLParams() string

func (PluginOp) NoCache

func (op PluginOp) NoCache() bool

func (PluginOp) String

func (op PluginOp) String() string

type PluginOpOption

type PluginOpOption func(*PluginOp)
var DEL PluginOpOption = func(op *PluginOp) { op.Action = Delete }
var GET PluginOpOption = func(op *PluginOp) { op.Action = Get }
var PUT PluginOpOption = func(op *PluginOp) { op.Action = Put }

func WatchPrefixOpOptions

func WatchPrefixOpOptions(key string) []PluginOpOption

func WithAscendOrder

func WithAscendOrder() PluginOpOption

func WithCacheOnly

func WithCacheOnly() PluginOpOption

func WithCountOnly

func WithCountOnly() PluginOpOption

func WithDescendOrder

func WithDescendOrder() PluginOpOption

func WithEndKey

func WithEndKey(key []byte) PluginOpOption

func WithGlobal

func WithGlobal() PluginOpOption

func WithIgnoreLease

func WithIgnoreLease() PluginOpOption

func WithKey

func WithKey(key []byte) PluginOpOption

func WithKeyOnly

func WithKeyOnly() PluginOpOption

func WithLease

func WithLease(leaseID int64) PluginOpOption

func WithLimit

func WithLimit(i int64) PluginOpOption

func WithNoCache

func WithNoCache() PluginOpOption

func WithNoneOrder

func WithNoneOrder() PluginOpOption

func WithOffset

func WithOffset(i int64) PluginOpOption

func WithPrefix

func WithPrefix() PluginOpOption

func WithPrevKv

func WithPrevKv() PluginOpOption

func WithRev

func WithRev(revision int64) PluginOpOption

func WithStrEndKey

func WithStrEndKey(key string) PluginOpOption

func WithStrKey

func WithStrKey(key string) PluginOpOption

func WithStrValue

func WithStrValue(value string) PluginOpOption

func WithValue

func WithValue(value []byte) PluginOpOption

func WithWatchCallback

func WithWatchCallback(f WatchCallback) PluginOpOption

type PluginResponse

type PluginResponse struct {
	Action    ActionType
	Kvs       []*mvccpb.KeyValue
	Count     int64
	Revision  int64
	Succeeded bool
}

func (*PluginResponse) MaxModRevision

func (pr *PluginResponse) MaxModRevision() (max int64)

func (*PluginResponse) String

func (pr *PluginResponse) String() string

type Registry

type Registry interface {
	Err() <-chan error
	Ready() <-chan struct{}
	PutNoOverride(ctx context.Context, opts ...PluginOpOption) (bool, error)
	Do(ctx context.Context, opts ...PluginOpOption) (*PluginResponse, error)
	Txn(ctx context.Context, ops []PluginOp) (*PluginResponse, error)
	TxnWithCmp(ctx context.Context, success []PluginOp, cmp []CompareOp, fail []PluginOp) (*PluginResponse, error)
	LeaseGrant(ctx context.Context, TTL int64) (leaseID int64, err error)
	LeaseRenew(ctx context.Context, leaseID int64) (TTL int64, err error)
	LeaseRevoke(ctx context.Context, leaseID int64) error
	// this function block util:
	// 1. connection error
	// 2. call send function failed
	// 3. response.Err()
	// 4. time out to watch, but return nil
	Watch(ctx context.Context, opts ...PluginOpOption) error
	Compact(ctx context.Context, reserve int64) error
	Close()
}

type SortOrder

type SortOrder int
const (
	SortNone SortOrder = iota
	SortAscend
	SortDescend
)

func (SortOrder) String

func (so SortOrder) String() string

type WatchCallback

type WatchCallback func(message string, evt *PluginResponse) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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