config

package
v0.0.0-...-57b83e3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgManager

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

CfgManager ... Configure Manager

func NewDBCfgManager

func NewDBCfgManager() *CfgManager

NewDBCfgManager - create DB config manager

func NewInMemoryManager

func NewInMemoryManager() *CfgManager

NewInMemoryManager create a manager for unit testing, doesn't involve database or REST

func NewRESTCfgManager

func NewRESTCfgManager(configURL, secret string) *CfgManager

NewRESTCfgManager - create REST config manager

func (*CfgManager) DumpTrace

func (c *CfgManager) DumpTrace()

DumpTrace dump all configurations

func (*CfgManager) Get

Get ...

func (*CfgManager) GetAll

func (c *CfgManager) GetAll() map[string]interface{}

GetAll get all settings.

func (*CfgManager) GetDatabaseCfg

func (c *CfgManager) GetDatabaseCfg() *models.Database

GetDatabaseCfg - Get database configurations

func (*CfgManager) GetUserCfgs

func (c *CfgManager) GetUserCfgs() map[string]interface{}

GetUserCfgs retrieve all user configs

func (*CfgManager) Load

func (c *CfgManager) Load() error

Load load configuration from storage, like database or redis

func (*CfgManager) Save

func (c *CfgManager) Save() error

Save - Save all current configuration to storage

func (*CfgManager) Set

func (c *CfgManager) Set(key string, value interface{})

Set ...

func (*CfgManager) UpdateConfig

func (c *CfgManager) UpdateConfig(cfgs map[string]interface{}) error

UpdateConfig - Update config store with a specified configuration and also save updated configure.

func (*CfgManager) ValidateCfg

func (c *CfgManager) ValidateCfg(cfgs map[string]interface{}) error

ValidateCfg validate config by metadata. return the first error if exist.

type FileKeyProvider

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

FileKeyProvider reads key from file

func (*FileKeyProvider) Get

func (f *FileKeyProvider) Get(params map[string]interface{}) (string, error)

Get returns the key read from file

type InMemoryDriver

type InMemoryDriver struct {
	sync.Mutex
	// contains filtered or unexported fields
}

InMemoryDriver driver for unit testing

func (*InMemoryDriver) Load

func (d *InMemoryDriver) Load() (map[string]interface{}, error)

Load load data from driver, for example load from database, it should be invoked before get any user scope config for system scope config, because it is immutable, no need to call this method

func (*InMemoryDriver) Save

func (d *InMemoryDriver) Save(cfg map[string]interface{}) error

Save only save user config setting to driver, for example: database, REST

type KeyProvider

type KeyProvider interface {
	// Get returns the key
	// params can be used to pass parameters in different implements
	Get(params map[string]interface{}) (string, error)
}

KeyProvider provides the key used to encrypt and decrypt attrs

func NewFileKeyProvider

func NewFileKeyProvider(path string) KeyProvider

NewFileKeyProvider returns an instance of FileKeyProvider path: where the key should be read from

type PresetKeyProvider

type PresetKeyProvider struct {
	Key string
}

PresetKeyProvider returns the preset key disregarding the parm, this is for testing only

func (*PresetKeyProvider) Get

func (p *PresetKeyProvider) Get(params map[string]interface{}) (string, error)

Get ...

Directories

Path Synopsis
Package metadata define config related metadata
Package metadata define config related metadata
Package store is only used in the internal implement of manager, not a public api.
Package store is only used in the internal implement of manager, not a public api.
driver
Package driver provide the implementation of config driver used in CfgManager
Package driver provide the implementation of config driver used in CfgManager

Jump to

Keyboard shortcuts

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