gcfg_adaper.go 1.2 KB

123456789101112131415161718192021222324252627282930
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gcfg
  7. import "context"
  8. // Adapter is the interface for configuration retrieving.
  9. type Adapter interface {
  10. // Available checks and returns the backend configuration service is available.
  11. // The optional parameter `resource` specifies certain configuration resource.
  12. //
  13. // Note that this function does not return error as it just does simply check for
  14. // backend configuration service.
  15. Available(ctx context.Context, resource ...string) (ok bool)
  16. // Get retrieves and returns value by specified `pattern` in current resource.
  17. // Pattern like:
  18. // "x.y.z" for map item.
  19. // "x.0.y" for slice item.
  20. Get(ctx context.Context, pattern string) (value interface{}, err error)
  21. // Data retrieves and returns all configuration data in current resource as map.
  22. // Note that this function may lead lots of memory usage if configuration data is too large,
  23. // you can implement this function if necessary.
  24. Data(ctx context.Context) (data map[string]interface{}, err error)
  25. }