mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
add Available function for Adapter of package gcfg
This commit is contained in:
@ -92,6 +92,15 @@ func (c *Config) GetAdapter() Adapter {
|
||||
return c.adapter
|
||||
}
|
||||
|
||||
// Available checks and returns the configuration service is available.
|
||||
// The optional parameter `pattern` 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.
|
||||
func (c *Config) Available(ctx context.Context, resource ...string) (ok bool) {
|
||||
return c.adapter.Available(ctx, resource...)
|
||||
}
|
||||
|
||||
// Set sets value with specified `pattern`.
|
||||
// It supports hierarchical data access by char separator, which is '.' in default.
|
||||
// It is commonly used for updates certain configuration value in runtime.
|
||||
|
||||
@ -11,11 +11,11 @@ import "context"
|
||||
// Adapter is the interface for configuration retrieving.
|
||||
type Adapter interface {
|
||||
// Available checks and returns the configuration service is available.
|
||||
// The optional parameter `pattern` specifies certain configuration resource.
|
||||
// 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, pattern ...string) (ok bool)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user