luci: go.chromium.org/luci/config/server/cfgclient/backend Index | Files | Directories

package backend

import "go.chromium.org/luci/config/server/cfgclient/backend"

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

Package Files

authority.go authority_string.go backend.go doc.go gen.go get_all.go

Constants

const (
    // GetAllProject indicates that project configus should be retrieved.
    GetAllProject = GetAllTarget("Project")
    // GetAllRef indicates that ref configs should be retrieved.
    GetAllRef = GetAllTarget("Ref")
)

func WithBackend Uses

func WithBackend(c context.Context, b B) context.Context

WithBackend returns a derivative Context with the supplied Backend installed.

func WithFactory Uses

func WithFactory(c context.Context, f Factory) context.Context

WithFactory returns a derivative Context with the supplied BackendFactory installed.

type Authority Uses

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 Uses

func (a Authority) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

We use a shorthand notation so that we don't waste space in JSON.

func (Authority) String Uses

func (i Authority) String() string

func (*Authority) UnmarshalJSON Uses

func (a *Authority) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type B Uses

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.

func Get Uses

func Get(c context.Context) B

Get returns the Backend that is installed into the Context.

If no Backend is installed in the Context, Get will panic.

type Factory Uses

type Factory func(context.Context) B

Factory is a function that generates a B given a Context.

type GetAllTarget Uses

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 Uses

func (gat GetAllTarget) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*GetAllTarget) UnmarshalJSON Uses

func (gat *GetAllTarget) UnmarshalJSON(d []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Params Uses

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)

Directories

PathSynopsis
cachingPackage caching implements a config.Interface that uses a caching layer to store its configuration values.
clientPackage client implements a config client backend for a configuration client.
erroringPackage erroring implements config.Backend that simply returns an error.
formatPackage format implements a config client Backend that performs formatting on items.
testconfig

Package backend imports 6 packages (graph) and is imported by 14 packages. Updated 2018-08-19. Refresh now. Tools for package owners.