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.
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, path string, p Params) (*Item, error) // GetAll retrieves all configurations of a given type. GetAll(c context.Context, t GetAllTarget, path string, p Params) ([]*Item, error) // ConfigSetURL returns the URL for the specified config set. ConfigSetURL(c context.Context, configSet string, p Params) (url.URL, 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 Factory ¶
Factory is a function that generates a B given a Context.
type FormatSpec ¶
type FormatSpec struct { // Formatter is the supported destination Resolver format for this item. // Backends (notably the format.Backend) may project the Item into this // format. // // An empty string means the original config service format. Formatter string // Data is additional format data describing the type. It may be empty. Data string }
FormatSpec is a specification for formatted data.
func (*FormatSpec) Unformatted ¶
func (fs *FormatSpec) Unformatted() bool
Unformatted retrns true if fs does not specify a format.
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 Item ¶
type Item struct { Meta Content string // FormatSpec, if non-empty, qualifies the format of the Content. FormatSpec FormatSpec }
Item is a single config item. It is used to pass configuration data between Backend instances.
type Meta ¶
type Meta struct { // ConfigSet is the item's config set. ConfigSet string // Path is the item's path within its config set. Path string // ContentHash is the content hash. ContentHash string // Revision is the revision string. Revision string }
Meta is backend metadata about a single configuration file.
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 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. |