W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
?gcfg
?組件采用了接口化設(shè)計(jì),以實(shí)現(xiàn)高擴(kuò)展性。通過接口化設(shè)計(jì)的方式,使用者可以自定義對(duì)接的配置獲取方式,例如?etcd
?, ?zookeeper
?, ?consule
?, ?kubernetes
??configmap
?, ?apollo
?等等。
https://github.com/gogf/gf/v2/blob/master/os/gcfg/gcfg_adaper.go
// Adapter is the interface for configuration retrieving.
type Adapter interface {
// Available checks and returns the configuration service is available.
// The optional parameter `resource` specifies certain configuration resource.
//
// It returns true if configuration file is present in default AdapterFile, or else false.
// Note that this function does not return error as it just does simply check for backend configuration service.
Available(ctx context.Context, resource ...string) (ok bool)
// Get retrieves and returns value by specified `pattern`.
Get(ctx context.Context, pattern string) (value interface{}, err error)
// Data retrieves and returns all configuration data as map type.
// Note that this function may lead lots of memory usage if configuration data is too large,
// you can implement this function if necessary.
Data(ctx context.Context) (data map[string]interface{}, err error)
}
// SetAdapter sets the adapter of current Config object.
func (c *Config) SetAdapter(adapter Adapter)
// GetAdapter returns the adapter of current Config object.
func (c *Config) GetAdapter() Adapter
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: