configclient

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MPL-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchEnvironmentVariable                = errors.New("no such environment variable")
	ErrHasDuplicatedKeysWithDifferentCaseFormat = errors.New("duplicated keys with different case format")
)
View Source
var (
	ErrWaitStartupLoadedTimeout = errors.New("wait startup loaded timeout")
)

Functions

func GetConfigurationKeyFromCfg

func GetConfigurationKeyFromCfg(c configapi.Configuration) string

func GetConfigurationSync

func GetConfigurationSync()

func Must added in v0.11.0

func Must[T any](val T, err error) T

func MustDefault added in v0.11.0

func MustDefault[T any](dv T) defaultVal[T]

Types

type Client

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

func NewClient

func NewClient(serverList []string, opt ClientOptions) *Client

func (*Client) AddConfigurationRequirement

func (c *Client) AddConfigurationRequirement(req RequiredConfig)

func (*Client) StartClient

func (c *Client) StartClient() error

func (*Client) StopClient

func (c *Client) StopClient() error

func (*Client) WaitStartupConfigureLoaded added in v0.0.9

func (c *Client) WaitStartupConfigureLoaded(ctx context.Context) error

type ClientAdv

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

func NewClientAdv

func NewClientAdv(c *Client) *ClientAdv

func (*ClientAdv) Register

func (c *ClientAdv) Register(group, key string, unmarshaler Unmarshaler, container any) (*atomic.Value, error)

Register will register auto updated configure container with the same type as the container provided Note that any further update has to be accessed via responded container rather than the container provided in the parameter

func (*ClientAdv) RegisterJsonContainer

func (c *ClientAdv) RegisterJsonContainer(group, key string, container any) (*atomic.Value, error)

RegisterJsonContainer will register auto updated configure container with json configure support Note: the behavior is the same as Register method

type ClientOptions

type ClientOptions struct {
	SelectorEnvironment string
	SelectorDatacenter  string
	SelectorNamespace   string
	SelectorApp         string
	SelectorCluster     string

	SelectorHostName string
	SelectorBeta     string

	OverrideSelectors         *configapi.Selectors // used for overriding detail selector config
	OverrideOptionalSelectors *configapi.Selectors // used for overriding detail selector config

	Auth string

	LocalFallbackDataPath             string
	AllowedLocalFallbackDataTTL       int64 // In seconds. Compare to last retrieved time rather than configuration timestamp.
	AcquireFullConfigurationsInterval int64 // Effective > 0 (in seconds). Used for 1. refresh data, 2. keep fallback data fresh
}

func (*ClientOptions) ToOptSelectors

func (c *ClientOptions) ToOptSelectors() configapi.Selectors

func (*ClientOptions) ToSelectors

func (c *ClientOptions) ToSelectors() configapi.Selectors

type ConfigContainer added in v0.10.10

type ConfigContainer[T any] struct {

	// OnChange is called when any update on the configuration
	OnChange func(cfg configapi.Configuration, container T)
	// contains filtered or unexported fields
}

ConfigContainer contains the configuration retrieved from the server with auto refresh support

func (*ConfigContainer[T]) Get added in v0.10.10

func (cc *ConfigContainer[T]) Get() T

func (*ConfigContainer[T]) Register added in v0.10.10

func (cc *ConfigContainer[T]) Register(c *ClientAdv, group, key string, unmarshaler Unmarshaler) error

Register will register auto updated configure container with the same type as the container provided Note that any further update has to be accessed via responded container rather than the container provided in the parameter

func (*ConfigContainer[T]) RegisterJsonContainer added in v0.10.10

func (cc *ConfigContainer[T]) RegisterJsonContainer(c *ClientAdv, group, key string) error

RegisterJsonContainer will register auto updated configure container with json configure support Note: the behavior is the same as Register method

type EnvClient added in v0.11.0

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

func NewEnvClient added in v0.11.0

func NewEnvClient() *EnvClient

func (*EnvClient) CaseInsensitive added in v0.11.0

func (c *EnvClient) CaseInsensitive() *EnvClient

func (*EnvClient) GetBool added in v0.11.0

func (c *EnvClient) GetBool(key string) (bool, error)

func (*EnvClient) GetFloat added in v0.11.0

func (c *EnvClient) GetFloat(key string) (float64, error)

func (*EnvClient) GetInt added in v0.11.0

func (c *EnvClient) GetInt(key string) (int, error)

func (*EnvClient) GetInt64 added in v0.11.0

func (c *EnvClient) GetInt64(key string) (int64, error)

func (*EnvClient) GetString added in v0.11.0

func (c *EnvClient) GetString(key string) (string, error)

func (*EnvClient) ParserWarning added in v0.11.0

func (e *EnvClient) ParserWarning() error

type RequiredConfig

type RequiredConfig struct {
	Required configapi.RequestedConfigurationKey
	Callback func(cfg configapi.Configuration)
}

type Unmarshaler

type Unmarshaler func([]byte, interface{}) error

Jump to

Keyboard shortcuts

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