Documentation ¶
Overview ¶
Package backend implements configuration client backend interface and associated data types.
The backend package implements a generalized implementation-oriented interface to configuration services that can be layered. Various backend implementations are best defined out of this package.
All non-user-facing operations of cfgclient will operate on backend types.
Index ¶
Constants ¶
const ( // GetAllProject indicates that project configus should be retrieved. GetAllProject = GetAllTarget("Project") // GetAllRef indicates that ref configs should be retrieved. GetAllRef = GetAllTarget("Ref") )
Variables ¶
This section is empty.
Functions ¶
func WithBackend ¶
WithBackend returns a derivative Context with the supplied Backend installed.
Types ¶
type Authority ¶
type Authority int
Authority is the authority that is requesting configurations. It can be installed via WithAuthority.
Authority marshals/unmarshals to/from a compact JSON representation. This is used by the caching layer.
const ( // AsAnonymous requests config data as an anonymous user. // // Corresponds to auth.NoAuth. AsAnonymous Authority = iota // AsService requests config data as the currently-running service. // // Corresponds to auth.AsSelf. AsService // AsUser requests config data as the currently logged-in user. // // Corresponds to auth.AsUser. AsUser )
func (Authority) MarshalJSON ¶
MarshalJSON implements encoding/json.Marshaler.
We use a shorthand notation so that we don't waste space in JSON.
func (*Authority) UnmarshalJSON ¶
UnmarshalJSON implements encoding/json.Unmarshaler.
type B ¶
type B interface { // ServiceURL returns the service URL. ServiceURL(context.Context) url.URL // Get retrieves a single configuration. Get(c context.Context, configSet config.Set, path string, p Params) (*config.Config, error) // GetAll retrieves all configurations of a given type. GetAll(c context.Context, t GetAllTarget, path string, p Params) ([]*config.Config, error) // GetConfigInterface returns the raw configuration interface of the backend. GetConfigInterface(c context.Context, a Authority) config.Interface }
B is a configuration backend interface.
type GetAllTarget ¶
type GetAllTarget string
GetAllTarget is the type of configuration to retrieve with GetAll.
GetAllTarget marshals/unmarshals to/from a compact JSON representation. This is used by the caching layer.
func (GetAllTarget) MarshalJSON ¶
func (gat GetAllTarget) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*GetAllTarget) UnmarshalJSON ¶
func (gat *GetAllTarget) UnmarshalJSON(d []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Params ¶
type Params struct { // Authority is the authority to use in the request. Authority Authority // Content, if true, indicates that config content should also be fetched. // Otherwise, only the content hash needs to be returned. Content bool // FormatSpec, if non-empty, qualifies the format of the Content. FormatSpec config.FormatSpec }
Params are parameters supplied to Backend methods. They are generated by the main interface user-facing methods (config.go)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package caching implements a config.Interface that uses a caching layer to store its configuration values.
|
Package caching implements a config.Interface that uses a caching layer to store its configuration values. |
Package client implements a config client backend for a configuration client.
|
Package client implements a config client backend for a configuration client. |
Package erroring implements config.Backend that simply returns an error.
|
Package erroring implements config.Backend that simply returns an error. |
Package format implements a config client Backend that performs formatting on items.
|
Package format implements a config client Backend that performs formatting on items. |