config

package
v0.0.0-...-678bb0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package config implements common LogDog daemon configuration.

The majority of LogDog configuration is loaded from "luci-config". The specific "luci-config" instance is passed to the daemon by the LogDog Coordaintor service. This library implements the logic to pull the configuration paramerers, load the "luci-config" configuration, and expose it to the service daemon.

Additionally, for testing, an option is implemented that allows the user to read the configuration from a local file (as a text protobuf) instead of from the Coordinator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheOptions

type CacheOptions struct {
	// CacheExpiration is the amount of time that a config entry should be cached.
	//
	// If this value is <= 0, no configuration caching will be enabled. This
	// should not be set for production systems.
	CacheExpiration time.Duration

	// DatastoreCacheAvailable, if true, indicates that requisite services for
	// datastore cache access are installed in the Context. This requires:
	// - A luci/gae datastore service instnace
	// - A settings service instance, presumably gaesettings.
	DatastoreCacheAvailable bool
}

CacheOptions is the set of configuration options.

func (*CacheOptions) WrapBackend

func (o *CacheOptions) WrapBackend(c context.Context, base backend.B) context.Context

WrapBackend wraps the supplied base backend in caching layers and returns a Conext with the resulting backend installed.

type ChangePoller

type ChangePoller struct {
	// ConfigSet is the slice of config paths to watch.
	ConfigSet cfgtypes.ConfigSet
	// Path is the path of the config to watch.
	Path string

	// Period is the amount of time in between checks to see if the configuration
	// has been updated. If <= 0, the poller will refrain from polling, and Run
	// will immediately exit.
	Period time.Duration
	// OnChange is the function that will be called if a configuration change has
	// been observed.
	//
	// Polling will be blocked until OnChange returns. If the Context supplied to
	// Run is canceled by OnChange, Run will exit at the beginning of the next
	// poll round.
	OnChange func()

	// ContentHash is the config's hash. This should be set to the initial config
	// value, either directly or via a Refresh call, before Run is called.
	ContentHash string
}

ChangePoller polls a configuration files for changes. If it changes, the OnChange function will be called and the polling will stop.

func (*ChangePoller) Refresh

func (p *ChangePoller) Refresh(c context.Context) error

Refresh reloads the configuration value, updating ContentHash.

func (*ChangePoller) Run

func (p *ChangePoller) Run(c context.Context)

Run starts polling for changes. It will stop when the Context is cancelled.

type MessageCache

type MessageCache struct {
	// Lifetime is the lifetime applied to an individual cache entry. If Lifetime
	// is <= 0, no caching will occur.
	Lifetime time.Duration
	// contains filtered or unexported fields
}

MessageCache is an in-memory configuration cache. Unlike the "MessageCache" config Backend, this stores the unmarshaled configuration object in-memory.

func (*MessageCache) Get

Get returns an unmarshalled configuration service text protobuf message.

If the message is not currently in the process cache, it will be fetched from the config service and cached prior to being returned.

func (*MessageCache) GetUncached

func (pc *MessageCache) GetUncached(c context.Context, cset cfgtypes.ConfigSet, path string,
	msg proto.Message) error

GetUncached returns an unmarshalled configuration service text protobuf message. This bypasses the cache, and, on success, does not cache the resulting value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL