2021-09-19 10:01:09 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
package gcfg
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
// Adapter is the interface for configuration retrieving.
|
|
|
|
type Adapter interface {
|
2021-11-27 01:33:53 +08:00
|
|
|
// Available checks and returns the configuration service is available.
|
2021-11-27 01:36:21 +08:00
|
|
|
// The optional parameter `resource` specifies certain configuration resource.
|
2021-11-27 01:33:53 +08:00
|
|
|
//
|
|
|
|
// 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.
|
2021-11-27 01:36:21 +08:00
|
|
|
Available(ctx context.Context, resource ...string) (ok bool)
|
2021-11-27 01:33:53 +08:00
|
|
|
|
2021-09-19 10:01:09 +08:00
|
|
|
// 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)
|
|
|
|
}
|