Back to godoc.org

Package config

v0.0.0-...-1557bcf
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Overview

Package config abstracts access to Logdog service and project configuration.

Sync(...) assumes the context has a cfgclient implementation and a read-write datastore. All other methods need only read-only datastore.

Index

Variables

var (
	// ErrInvalidConfig is returned when the configuration exists, but is invalid.
	ErrInvalidConfig = errors.New("invalid configuration")
)

func Config

func Config(ctx context.Context) (*svcconfig.Config, error)

Config loads and returns the service configuration.

func Middleware

func Middleware(s *Store) router.Middleware

Middleware returns a middleware that installs `s` into requests' context.

func ProjectConfig

func ProjectConfig(ctx context.Context, projectID string) (*svcconfig.ProjectConfig, error)

ProjectConfig loads the project config protobuf from the config service.

This function will return following errors:

- nil, if the project exists and the configuration successfully loaded
- config.ErrNoConfig if the project configuration was not present.
- ErrInvalidConfig if the project configuration was present, but could not
  be loaded.
- Some other error if an error occurred that does not fit one of the
  previous categories.

func Sync

func Sync(ctx context.Context) error

Sync makes sure configs in the datastore match what's in LUCI Config.

Performs as much work as possible (even in presence of errors). Logs errors inside in addition to returning them as a single errors.MultiError.

func WithStore

func WithStore(ctx context.Context, s *Store) context.Context

WithStore installs a store that caches configs in memory.

type Store

type Store struct {
	// NoCache disables in-process caching (useful in tests).
	NoCache bool
	// contains filtered or unexported fields
}

Store caches configs in memory to avoid hitting cfgclient all the time.

Keep at as a global variable and install into contexts via WithStore.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier