remote

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Overview

Package remote created on 2017/6/22.

Index

Constants

View Source
const (
	LabelService     = "serviceName"
	LabelVersion     = "version"
	LabelEnvironment = "environment"
	LabelApp         = "app"
)

const

View Source
const (
	//Name variable of type string
	Name = "ConfigCenterSource"

	ModeInterval = 1
)

const

Variables

This section is empty.

Functions

func InstallConfigClientPlugin added in v1.0.0

func InstallConfigClientPlugin(name string, f func(options Options) (Client, error))

InstallConfigClientPlugin install a config client plugin

func NewConfigCenterSource

func NewConfigCenterSource(cc Client, refreshMode, refreshInterval int) source.ConfigSource

NewConfigCenterSource initializes all components of configuration center

Types

type Client added in v1.0.0

type Client interface {
	//PullConfigs pull all configs from remote
	PullConfigs(labels ...map[string]string) (map[string]interface{}, error)
	//PullConfig pull one config from remote
	PullConfig(key, contentType string, labels map[string]string) (interface{}, error)
	// PushConfigs push config to cc
	PushConfigs(data map[string]interface{}, labels map[string]string) (map[string]interface{}, error)
	// DeleteConfigsByKeys delete config for cc by keys
	DeleteConfigsByKeys(keys []string, labels map[string]string) (map[string]interface{}, error)
	//Watch get kv change results, you can compare them with local kv cache and refresh local cache
	Watch(f func(map[string]interface{}), errHandler func(err error), labels map[string]string) error
	Options() Options
}

Client is the interface of config server client, it has basic func to interact with config server

var DefaultClient Client

DefaultClient is config server's client

func NewClient added in v1.0.0

func NewClient(name string, options Options) (Client, error)

NewClient create config client implementation

type Options added in v1.0.0

type Options struct {
	ServerURI     string
	Endpoint      string
	TLSConfig     *tls.Config
	TenantName    string
	EnableSSL     bool
	APIVersion    string
	AutoDiscovery bool
	RefreshPort   string

	Labels map[string]string
}

Options is client option

type Source

type Source struct {
	sync.RWMutex

	RefreshMode     int
	RefreshInterval time.Duration
	// contains filtered or unexported fields
}

Source handles configs from config center

func (*Source) AddDimensionInfo

func (rs *Source) AddDimensionInfo(labels map[string]string) error

AddDimensionInfo adds dimension info for a configuration

func (*Source) Cleanup

func (rs *Source) Cleanup() error

Cleanup cleans the particular configuration up

func (*Source) Delete

func (rs *Source) Delete(key string) error

Delete no use

func (*Source) GetConfigurationByKey

func (rs *Source) GetConfigurationByKey(key string) (interface{}, error)

GetConfigurationByKey gets required configuration for a particular key

func (*Source) GetConfigurations

func (rs *Source) GetConfigurations() (map[string]interface{}, error)

GetConfigurations pull config from remote and start refresh configs interval write a new map and return, internal map can not be operated outside struct

func (*Source) GetPriority

func (rs *Source) GetPriority() int

GetPriority returns priority of a configuration

func (*Source) GetSourceName

func (*Source) GetSourceName() string

GetSourceName returns name of the configuration

func (*Source) Set

func (rs *Source) Set(key string, value interface{}) error

Set no use

func (*Source) SetPriority

func (rs *Source) SetPriority(priority int)

SetPriority custom priority

func (*Source) Watch

func (rs *Source) Watch(callback source.EventHandler) error

Watch dynamically handles a configuration

Directories

Path Synopsis
Package configcenter created on 2017/6/20.
Package configcenter created on 2017/6/20.

Jump to

Keyboard shortcuts

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