backend

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Memory = "memory" // For debug or test usage.
	Etcd   = "etcd"
)
View Source
const (
	DialTimeout  = time.Second * 3
	RetryTimeout = time.Second * 3
	ReadTimeout  = time.Second * 3
	WriteTimeout = time.Second * 3
)
View Source
const (
	ServicePrefix    = "service"
	ServiceOpsPrefix = "ops"
	ServiceNodeIDKey = "node_id"
)
View Source
const (
	ConfigPrefix = "config"
)
View Source
const (
	DefaultChanLen = 100
)

Variables

This section is empty.

Functions

func ServiceConfigKey

func ServiceConfigKey(path, service string) string

func ServiceDiscoveryKey

func ServiceDiscoveryKey(path, service, node string) string

func ServiceDiscoveryPrefixKey

func ServiceDiscoveryPrefixKey(path string) string

func ServiceNodeIDIncrKey

func ServiceNodeIDIncrKey(path, service string) string

func ServiceOpsKey

func ServiceOpsKey(path, service, node string) string

Types

type ConfigItem

type ConfigItem struct {
	Type    string `json:"type"`
	Hint    string `json:"hint"`
	Value   string `json:"value"`
	Comment string `json:"comment"`
}

func (ConfigItem) String

func (c ConfigItem) String() string

type ConfigItems

type ConfigItems map[string]*ConfigItem

func (ConfigItems) Add

func (c ConfigItems) Add(items ConfigItems)

func (ConfigItems) KVs

func (c ConfigItems) KVs(servicePath string) map[string]string

type EventChan

type EventChan chan *WatchEvent

type EventType

type EventType string
const (
	Put    EventType = "put"
	Delete EventType = "delete"
	Reset  EventType = "reset"
)

type KVPair

type KVPair struct {
	Key   string
	Value string
}

type KVPairs

type KVPairs []*KVPair

type Provider

type Provider interface {
	// Return provider type
	Type() string

	// Set value with the specified key
	Set(key, value string, ttl time.Duration) error

	// Get value of the specified key or directory
	Get(key string, dir bool) (KVPairs, error)

	// Atomic increase the specified key
	Incr(key string) (int64, error)

	// Delete the specified key or directory
	Delete(key string, dir bool) error

	// Watch for changes of the specified key or directory
	Watch(key string, dir bool) EventChan

	// Set and update ttl for the specified key
	KeepAlive(key, value string, ttl time.Duration) error

	// Close the provider connection
	Close() error
}

Backend provider interface

type WatchEvent

type WatchEvent struct {
	KVPair
	Type EventType
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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