center

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultApolloMiddlewareService = "middleware"

	DefaultApolloMQNamespace    = "infra.mq"
	DefaultApolloCacheNamespace = "infra.cache"
	DefaultApolloMysqlNamespace = "infra.mysql"
	DefaultApolloTraceNamespace = "infra.trace"
)

Variables

This section is empty.

Functions

func GetBool

func GetBool(ctx context.Context, key string) (bool, bool)

func GetBoolWithNamespace

func GetBoolWithNamespace(ctx context.Context, namespace, key string) (bool, bool)

func GetInt

func GetInt(ctx context.Context, key string) (int, bool)

func GetIntWithNamespace

func GetIntWithNamespace(ctx context.Context, namespace, key string) (int, bool)

func GetString

func GetString(ctx context.Context, key string) (string, bool)

func GetStringWithNamespace

func GetStringWithNamespace(ctx context.Context, namespace, key string) (string, bool)

func Init

func Init(ctx context.Context, serviceName string, namespaceNames []string) error

func RegisterObserver

func RegisterObserver(ctx context.Context, observer ConfigObserver) (recall func())

func StartWatchUpdate

func StartWatchUpdate(ctx context.Context)

func Stop

func Stop(ctx context.Context) error

func SubscribeNamespaces

func SubscribeNamespaces(ctx context.Context, namespaceNames []string) error

func Unmarshal

func Unmarshal(ctx context.Context, v interface{}) error

func UnmarshalKey

func UnmarshalKey(ctx context.Context, key string, v interface{}) error

func UnmarshalKeyWithNamespace

func UnmarshalKeyWithNamespace(ctx context.Context, namespace, key string, v interface{}) error

func UnmarshalWithNamespace

func UnmarshalWithNamespace(ctx context.Context, namespace string, v interface{}) error

Types

type Change

type Change struct {
	OldValue   string
	NewValue   string
	ChangeType ChangeType
}

type ChangeEvent

type ChangeEvent struct {
	Source ChangeEventSource
	// Namespace means
	//   Namespace in Apollo
	//   Path in Etcd
	Namespace string
	Changes   map[string]*Change
}

type ChangeEventSource

type ChangeEventSource int
const (
	Etcd ChangeEventSource = iota
	Apollo
)

type ChangeType

type ChangeType int
const (
	ADD ChangeType = iota
	MODIFY
	DELETE
)

func (ChangeType) String

func (c ChangeType) String() string

type ConfigCenter

type ConfigCenter interface {
	Init(ctx context.Context, serviceName string, namespaceNames []string) error
	Stop(ctx context.Context) error

	SubscribeNamespaces(ctx context.Context, namespaceNames []string) error

	GetString(ctx context.Context, key string) (string, bool)
	GetStringWithNamespace(ctx context.Context, namespace, key string) (string, bool)
	GetBool(ctx context.Context, key string) (bool, bool)
	GetBoolWithNamespace(ctx context.Context, namespace, key string) (bool, bool)
	GetInt(ctx context.Context, key string) (int, bool)
	GetIntWithNamespace(ctx context.Context, namespace, key string) (int, bool)
	GetAllKeys(ctx context.Context) []string
	GetAllKeysWithNamespace(ctx context.Context, namespace string) []string

	Unmarshal(ctx context.Context, v interface{}) error
	UnmarshalWithNamespace(ctx context.Context, namespace string, v interface{}) error
	UnmarshalKey(ctx context.Context, key string, v interface{}) error
	UnmarshalKeyWithNamespace(ctx context.Context, namespace string, key string, v interface{}) error

	StartWatchUpdate(ctx context.Context)
	RegisterObserver(ctx context.Context, observer ConfigObserver) (recall func())
}

func NewConfigCenter

func NewConfigCenter(t ConfigCenterType) (ConfigCenter, error)

type ConfigCenterType

type ConfigCenterType int
const (
	ApolloConfigCenter ConfigCenterType = iota
)

func (ConfigCenterType) String

func (c ConfigCenterType) String() string

type ConfigObserver

type ConfigObserver interface {
	HandleChangeEvent(event *ChangeEvent)
}

Jump to

Keyboard shortcuts

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