github.com/gogf/gf/v2@v2.7.4/os/gcfg/gcfg_adaper.go (about)

     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  
     7  package gcfg
     8  
     9  import "context"
    10  
    11  // Adapter is the interface for configuration retrieving.
    12  type Adapter interface {
    13  	// Available checks and returns the backend configuration service is available.
    14  	// The optional parameter `resource` specifies certain configuration resource.
    15  	//
    16  	// Note that this function does not return error as it just does simply check for
    17  	// backend configuration service.
    18  	Available(ctx context.Context, resource ...string) (ok bool)
    19  
    20  	// Get retrieves and returns value by specified `pattern` in current resource.
    21  	// Pattern like:
    22  	// "x.y.z" for map item.
    23  	// "x.0.y" for slice item.
    24  	Get(ctx context.Context, pattern string) (value interface{}, err error)
    25  
    26  	// Data retrieves and returns all configuration data in current resource as map.
    27  	// Note that this function may lead lots of memory usage if configuration data is too large,
    28  	// you can implement this function if necessary.
    29  	Data(ctx context.Context) (data map[string]interface{}, err error)
    30  }