goconfig_center

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 11 Imported by: 2

README

goconfig配置中心

对goconfig的增强,提供一种配置化方案来支持goconfig接入配置中心

默认支持viper原生配置中心etcd/etcd3/consul/firestore

Documentation

Index

Constants

View Source
const (
	KeyConfig = "config_center"
)

Variables

View Source
var (
	ErrDriverNotFound = errors.New("no Driver")
)

Functions

func Equal

func Equal(v1, v2 *viper.Viper) bool

func IsSupport

func IsSupport(driverName string) bool

func Register

func Register(driverName string, fn DriverFactory)

Types

type Center

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

func New

func New(config *goconfig.Config, key ...string) *Center

func NewWithViper

func NewWithViper(v *viper.Viper, key ...string) *Center

func (*Center) Attach added in v1.0.1

func (c *Center) Attach(v *viper.Viper)

func (*Center) Detach added in v1.0.1

func (c *Center) Detach(v *viper.Viper)

func (*Center) GetConfig

func (c *Center) GetConfig() *goconfig.Config

func (*Center) StopWatch

func (c *Center) StopWatch()

func (*Center) Watch

func (c *Center) Watch()

type ConfigDriver

type ConfigDriver struct {
	Driver string `mapstructure:"Driver"`
	Enable bool   `mapstructure:"enable"`
}

type Driver

type Driver interface {
	Name() string
	GetViper() (*viper.Viper, error)
	OnUpdate() <-chan struct{}
	Close() error
	Prefix() string
}

type DriverFactory

type DriverFactory func(cfg *viper.Viper) (Driver, error)

Jump to

Keyboard shortcuts

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