etcd

package
v0.0.0-...-07e2703 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigStructureAppKeyAsRoot - etcd config structure is as follows: "app-key/env/entry-key" or "app-key/entry-key" if ServerEnvironmentNone is specified.
	ConfigStructureAppKeyAsRoot = ConfigStructureType(iota)

	// ConfigStructureEnvKeyAsRoot - etcd config structure is as follows: "env/app-key/entry-key"
	ConfigStructureEnvKeyAsRoot
)
View Source
const (
	// ServerEnvironmentDev - indicates dev environment
	ServerEnvironmentDev = ServerEnvironmentType(iota)

	// ServerEnvironmentQA - indicates qa environment
	ServerEnvironmentQA

	// ServerEnvironmentStage - indicates stage environment
	ServerEnvironmentStage

	// ServerEnvironmentProduction - indicates production environment
	ServerEnvironmentProduction

	// ServerEnvironmentNone - indicates no environment level in config structure
	ServerEnvironmentNone
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigChangeHandler

type ConfigChangeHandler interface {
	ReloadConfigChange(entryKey string, newVal string, prevVal string)
}

ConfigChangeHandler interface for config change handlers.

type ConfigClient

type ConfigClient struct {
	Endpoints []string
	AppKey    string
	Env       ServerEnvironmentType
	Org       ConfigStructureType
	// contains filtered or unexported fields
}

ConfigClient observes config changes on etcd and executes app specific code associated these changes. It also allows the app to retrieve entries on demand.

func CreateNewConfigClient

func CreateNewConfigClient(endpoints []string, appKey string, env ServerEnvironmentType, org ConfigStructureType) (*ConfigClient, error)

CreateNewConfigClient creates a new ConfigWatcher.

func (*ConfigClient) AddStringKvHandler

func (cc *ConfigClient) AddStringKvHandler(key string, prefix bool, handler ConfigChangeHandler) error

AddStringKvHandler adds a new config handler method to be executed when the specified entry changes. Handles all keys and values as strings.

func (*ConfigClient) Close

func (cc *ConfigClient) Close()

Close closes all connections to etcd and shutdown any running go routines. Renders the instance of ConfigWatcher unusable.

func (*ConfigClient) ReadEntries

func (cc *ConfigClient) ReadEntries(entryKeyPrefix string) (map[string]string, error)

ReadEntries reads config entries from etcd based on a prefix

func (*ConfigClient) ReadEntry

func (cc *ConfigClient) ReadEntry(entryKey string, defaultVal string) (string, error)

ReadEntry reads a config entry from etcd

func (*ConfigClient) RemoveHandler

func (cc *ConfigClient) RemoveHandler(key string) error

RemoveHandler removes all associated config change handlers for the specified key

type ConfigStructureType

type ConfigStructureType int

ConfigStructureType specifies how the config entries are stored in etcd. Either with app-key as the root or environment.

type ServerEnvironmentType

type ServerEnvironmentType int

ServerEnvironmentType - used to indicate qa, stage or production environments

func (ServerEnvironmentType) String

func (s ServerEnvironmentType) String() string

Jump to

Keyboard shortcuts

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