etcd

package
v0.0.0-...-5915c45 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEtcdOption

func WithEtcdOption(ctx context.Context, opts ...clientv3.OpOption) context.Context

Types

type EtcdConfiger

type EtcdConfiger struct {
	config.BaseConfiger
	// contains filtered or unexported fields
}

func (*EtcdConfiger) DIY

func (e *EtcdConfiger) DIY(ctx context.Context, key string) (interface{}, error)

DIY return the original response from etcd be careful when you decide to use this

func (*EtcdConfiger) GetSection

func (e *EtcdConfiger) GetSection(ctx context.Context, section string) (map[string]string, error)

GetSection in this implementation, we use section as prefix

func (*EtcdConfiger) OnChange

func (e *EtcdConfiger) OnChange(ctx context.Context, key string, fn func(value string))

TODO remove this before release v2.0.0

func (*EtcdConfiger) SaveConfigFile

func (e *EtcdConfiger) SaveConfigFile(ctx context.Context, filename string) error

func (*EtcdConfiger) Set

func (e *EtcdConfiger) Set(ctx context.Context, key, val string) error

Set do nothing and return an error I think write data to remote config center is not a good practice

func (*EtcdConfiger) Sub

func (e *EtcdConfiger) Sub(ctx context.Context, key string) (config.Configer, error)

Sub return an sub configer.

func (*EtcdConfiger) Unmarshaler

func (e *EtcdConfiger) Unmarshaler(ctx context.Context, prefix string, obj interface{}, opt ...config.DecodeOption) error

Unmarshaler is not very powerful because we lost the type information when we get configuration from etcd for example, when we got "5", we are not sure whether it's int 5, or it's string "5" TODO(support more complicated decoder)

type EtcdConfigerProvider

type EtcdConfigerProvider struct {
}

func (*EtcdConfigerProvider) Parse

func (provider *EtcdConfigerProvider) Parse(key string) (config.Configer, error)

Parse = ParseData([]byte(key)) key must be json

func (*EtcdConfigerProvider) ParseData

func (provider *EtcdConfigerProvider) ParseData(data []byte) (config.Configer, error)

ParseData try to parse key as clientv3.Config, using this to build etcdClient

Jump to

Keyboard shortcuts

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