dconfigclient

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: MIT Imports: 4 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// AddHandlers register all the handler for the dynamic config values
	AddHandlers(handlerMap map[string]Handler)

	// AddVerifiers register all the handler for the dynamic config values
	AddVerifiers(verifierMap map[string]Verifier)

	// Refresh the dynamic config client
	Refresh()

	// StartBackGroundRefresh start the back fround refresh for dynamic config
	StartBackGroundRefresh()

	GetOrDefault(fieldName string, defaultValue interface{}) interface{}
}

Client is the interface used to manager dynamic config

func NewDconfigClient

func NewDconfigClient(scfg configure.CommonServiceConfig, serviceName string) Client

NewDconfigClient return the dconfig client for the service

type DconfigClient

type DconfigClient struct {
	// contains filtered or unexported fields
}

DconfigClient is the struct which implements the ClientInt interface

func (*DconfigClient) AddHandlers

func (uf *DconfigClient) AddHandlers(handlerMap map[string]Handler)

AddHandlers register all the handler for the dynamic config values

func (*DconfigClient) AddVerifiers

func (uf *DconfigClient) AddVerifiers(verifierMap map[string]Verifier)

AddVerifiers register all the handler for the dynamic config values

func (*DconfigClient) GetClient

func (uf *DconfigClient) GetClient() interface{}

GetClient return the config client

func (*DconfigClient) GetOrDefault

func (uf *DconfigClient) GetOrDefault(fieldName string, defaultValue interface{}) interface{}

GetOrDefault implements the corresponding method

func (*DconfigClient) Refresh

func (uf *DconfigClient) Refresh()

Refresh refresh the dynamic config client

func (*DconfigClient) StartBackGroundRefresh

func (uf *DconfigClient) StartBackGroundRefresh()

StartBackGroundRefresh start the automatical refresh for dynamic config

type GetterInt

type GetterInt func() int

GetterInt is the function interface for handler dconfig value

type GetterString

type GetterString func() string

GetterString is the function interface for handler dconfig value

type Handler

type Handler func(newConfig interface{})

Handler is user supplied handler functions, which will be called back when the dynamic config updates.

func GenerateIntHandler

func GenerateIntHandler(dconfigKey string, setter SetterInt, getter GetterInt) Handler

GenerateIntHandler return a dconfig Handler for the dconfigKey

func GenerateStringHandler

func GenerateStringHandler(dconfigKey string, setter SetterString, getter GetterString) Handler

GenerateStringHandler return a dconfig Handler for the dconfigKey

type SetterInt

type SetterInt func(value int32)

SetterInt is the setter function to generate the handler function

type SetterString

type SetterString func(value string)

SetterString is the setter function to generate the handler function

type Verifier

type Verifier func(oldValue interface{}, newValue interface{}) bool

Verifier interface user supplied verifier functions to verify the value when updates

func GenerateIntMaxMinVerifier

func GenerateIntMaxMinVerifier(dconfigKey string, minV int, maxV int) Verifier

GenerateIntMaxMinVerifier return a dconfig Verifier for the dconfigKey

func GenerateStringRegexpVerifier added in v1.26.0

func GenerateStringRegexpVerifier(dconfigKey string, r *regexp.Regexp) Verifier

GenerateStringRegexpVerifier return a dconfig Verifier for the dconfigKey

Jump to

Keyboard shortcuts

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