configs

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 6 Imported by: 7

README

配置中心

可从文件、etcd中读取配置

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegistrySource

func RegistrySource(name string, f NewSource)

Types

type Config

type Config struct {
	AppName string
	Version string
	Env     Env
	Debug   bool
	// contains filtered or unexported fields
}

func Default

func Default() *Config

func NewConfig

func NewConfig(appName string, opt ...Option) (*Config, error)

func (*Config) Bool

func (c *Config) Bool(ctx context.Context, key string) bool

func (*Config) Has

func (c *Config) Has(ctx context.Context, key string) (bool, error)

func (*Config) Scan

func (c *Config) Scan(ctx context.Context, key string, value interface{}) error

func (*Config) String

func (c *Config) String(ctx context.Context, key string) string

func (*Config) Watch added in v1.1.0

func (c *Config) Watch(ctx context.Context, key string, callback func(event source.Event)) error

type Env

type Env string
const (
	DEV  Env = "dev"
	TEST Env = "test"
	PRE  Env = "pre"
	PROD Env = "prod"
)

type NewSource

type NewSource func(cfg *Config, serialization file.Serialization) (source.Source, error)

type Option

type Option func(*Options)

func WithConfigFile

func WithConfigFile(file string) Option

func WithSerialization

func WithSerialization(serialization file.Serialization) Option

func WithSource

func WithSource(source source.Source) Option

type Options

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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