config

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 16 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EtcdDefaultDailTimeout          = time.Second
	EtcdDefaultDialKeepAliveTime    = 3 * time.Second
	EtcdDefaultDialKeepAliveTimeout = 3 * time.Second
)
View Source
var RegistryImplementationTypeNameEtcd = "etcd"
View Source
var RegistryImplementationTypeNameNacos = "nacos"

Functions

func Close added in v0.2.0

func Close() error

func Exist added in v0.2.0

func Exist(ctx context.Context, key string) (bool, error)

func InitDefaultClient added in v0.2.0

func InitDefaultClient(ctx context.Context, config *Config) error

func NewConfigCenterPlugin added in v0.2.0

func NewConfigCenterPlugin(_ context.Context) application.Plugin

NewConfigCenterPlugin 配置中心组件

func RegistryImplementation added in v0.2.0

func RegistryImplementation(typeName string, fn RegistryImplementationFunc)

func Set added in v0.2.0

func Set(ctx context.Context, key, value string) error

func Trans2EtcdConfig added in v0.2.0

func Trans2EtcdConfig(ctx context.Context, config *Config) clientv3.Config

func Trans2NacosConfig added in v0.2.0

func Trans2NacosConfig(_ context.Context, config *Config) (clientConfig *constant.ClientConfig, serverConfigs []constant.ServerConfig, err error)

func Watch added in v0.2.0

func Watch(ctx context.Context, item *Item, callback func(item *Item)) error

Types

type Client added in v0.2.0

type Client interface {
	Close() error
	Init(ctx context.Context, config *Config) error
	Set(ctx context.Context, key, value string) error
	Get(ctx context.Context, key string) (*Item, error)
	Watch(ctx context.Context, item *Item, callback func(item *Item)) error
	Exist(ctx context.Context, key string) (bool, error)
}

func GetClientImplementation added in v0.2.0

func GetClientImplementation(ctx context.Context, typeName string) (Client, error)

GetClientImplementation get client implementation by typeName

type Config added in v0.2.0

type Config struct {
	Type      string `yaml:"type" json:"type"`
	Endpoints string `yaml:"endpoints" json:"endpoints"`
	Namespace string `yaml:"namespace" json:"namespace"`

	Username string `yaml:"username" json:"userName"`
	Password string `yaml:"password" json:"password"`

	Settings map[string]string `yaml:"settings" json:"settings"`
}

type EtcdConfigClient added in v0.2.0

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

func (*EtcdConfigClient) Close added in v0.2.0

func (s *EtcdConfigClient) Close() error

func (*EtcdConfigClient) Exist added in v0.2.0

func (s *EtcdConfigClient) Exist(ctx context.Context, key string) (bool, error)

func (*EtcdConfigClient) Get added in v0.2.0

func (s *EtcdConfigClient) Get(ctx context.Context, key string) (*Item, error)

func (*EtcdConfigClient) Init added in v0.2.0

func (s *EtcdConfigClient) Init(ctx context.Context, conf *Config) error

func (*EtcdConfigClient) Set added in v0.2.0

func (s *EtcdConfigClient) Set(ctx context.Context, key, value string) error

func (*EtcdConfigClient) Watch added in v0.2.0

func (s *EtcdConfigClient) Watch(ctx context.Context, item *Item, callback func(item *Item)) error

type Item added in v0.2.0

type Item struct {
	Namespace string `json:"namespace"`
	Key       string `json:"key"`

	*sync.RWMutex `json:"-"`
	// contains filtered or unexported fields
}

func Get added in v0.2.0

func Get(ctx context.Context, key string) (*Item, error)

func NewItem added in v0.2.0

func NewItem(namespace, key, value string) *Item

func (*Item) GetValue added in v0.2.0

func (i *Item) GetValue() string

func (*Item) SetValue added in v0.2.0

func (i *Item) SetValue(value string)

type NacosConfigClient added in v0.2.0

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

func (*NacosConfigClient) Close added in v0.2.0

func (s *NacosConfigClient) Close() error

func (*NacosConfigClient) Exist added in v0.2.0

func (s *NacosConfigClient) Exist(ctx context.Context, key string) (bool, error)

func (*NacosConfigClient) Get added in v0.2.0

func (s *NacosConfigClient) Get(ctx context.Context, key string) (*Item, error)

func (*NacosConfigClient) Init added in v0.2.0

func (s *NacosConfigClient) Init(ctx context.Context, conf *Config) error

func (*NacosConfigClient) Set added in v0.2.0

func (s *NacosConfigClient) Set(_ context.Context, key, value string) error

func (*NacosConfigClient) Watch added in v0.2.0

func (s *NacosConfigClient) Watch(ctx context.Context, item *Item, callback func(item *Item)) error

type Plugin added in v0.2.0

type Plugin struct {
	application.Plugin
	// contains filtered or unexported fields
}

func (*Plugin) Config added in v0.2.0

func (p *Plugin) Config(_ context.Context, conf []byte) error

func (*Plugin) Init added in v0.2.0

func (p *Plugin) Init(ctx context.Context) error

func (*Plugin) Run added in v0.2.3

func (p *Plugin) Run(ctx context.Context) error

type RegistryImplementationFunc added in v0.2.0

type RegistryImplementationFunc func(ctx context.Context) Client

Jump to

Keyboard shortcuts

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