backend

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 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
	KeepAliveTime = time.Second * 5
)
View Source
const (
	ServicePrefix    = "service"
	ServiceOpsPrefix = "ops"
	ServiceNodeIDKey = "node_id"
)
View Source
const (
	ConfigPrefix = "config"
)
View Source
const (
	DefaultChanLen = 1000
)

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 {
	// Type returns the provider type.
	Type() string

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

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

	// Incr invokes an atomic value increase for 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, error)

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

	// Close the provider connection.
	Close() error
}

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