config

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeFile - config type file
	TypeFile = "file"
	// TypeETCD - config type etcd
	TypeETCD = "etcd"
	// TypeConsul - config type consul
	TypeConsul = "consul"
)

Variables

This section is empty.

Functions

func Register

func Register(name string, adapter Instance)

Register makes a Config adapter available by the adapter name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type Config

type Config interface {
	// get config value by key.
	Get(key string) interface{}
	// get bool config value by key
	GetBool(key string) bool
	// get float64 config value by key
	GetFloat64(key string) float64
	// get Int config value by key
	GetInt(key string) int
	// get Int32 config value by key
	GetInt32(key string) int32
	// get Int64 config value by key
	GetInt64(key string) int64
	// get string config value by key
	GetString(key string) string
	// get stringMap config value by key
	GetStringMap(key string) map[string]interface{}
	// get stringMapstring config value by key
	GetStringMapString(key string) map[string]string
	// get stringSlice config value by key
	GetStringSlice(key string) []string
	// get time config value by key
	GetTime(key string) time.Time
	// get Duration config value by key
	GetDuration(key string) time.Duration
	// check if config value exists or not.
	IsExist(key string) bool
	// get all config value
	AllSettings() map[string]interface{}
	// start gc routine based on config param settings.
	StartAndGC(param Param) error
}

Config interface contains all behaviors for config adapter.

func NewConfig

func NewConfig(adapterName string, config Param) (adapter Config, err error)

NewConfig Create a new config driver by adapter name and config string.

type Instance

type Instance func() Config

Instance is a function create a new Config Instance

type Param

type Param struct {
	// public param
	Type string `json:"type"`

	// for key/value store
	Server   string `json:"server"`
	User     string `json:"user"`
	Password string `json:"password"`
	Prefix   string `json:"prefix"`
	Port     int64  `json:"port"`

	// file param
	Path string `json:"path"`
	Name string `json:"name"`
	File string `json:"file"`

	// Extend fields
	// Extended fields can be used if there is a special implementation
	Extend1 string `json:"extend_1"`
	Extend2 string `json:"extend_2"`
}

Param - config param

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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