config

package
v0.0.0-...-6472126 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2017 License: Apache-2.0, Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package config handles configuration ingestion and processing. validator 1. Accepts new configuration from user 2. Validates configuration 3. Produces a "ValidatedConfig" runtime

  1. It is validated and actionable configuration
  2. It resolves the configuration to a list of Combined {aspect, adapter} configs given an attribute.Bag.
  3. Combined config has complete information needed to dispatch aspect

Index

Constants

View Source
const (
	AttributesKindName = "attributes"
	QuotasKindName     = "quotas"
)

Name of all supported aspect kinds.

Variables

This section is empty.

Functions

func AdapterInfoMap

func AdapterInfoMap(handlerRegFns []adapter.InfoFn,
	hndlrBldrValidator handlerBuilderValidator) map[string]*adapter.Info

AdapterInfoMap returns the known adapter.Infos, indexed by their names.

func GetScopes

func GetScopes(attr string, domain string, scopes []string) ([]string, error)

GetScopes returns configuration scopes that apply given a target service k8s example: domain maps to global attr - my-svc.my-namespace.svc.cluster.local domain - svc.cluster.local --> "global", "my-namespace.svc.cluster.local", "my-svc.my-namespace.svc.cluster.local" ordering of scopes is from least specific to most specific.

func InventoryMap

func InventoryMap(inv []adapter.InfoFn) map[string]*adapter.Info

InventoryMap converts adapter inventory to a builder map.

func NewCompatFSStore

func NewCompatFSStore(globalConfigFile string, serviceConfigFile string) (store.KeyValueStore, error)

NewCompatFSStore creates and returns an fsStore using old style This should be removed once we migrate all configs to new style configs.

func SetupHandlers

func SetupHandlers(actions []*pb.Action, instances map[string]*pb.Instance,
	handlers map[string]*HandlerBuilderInfo, tmplRepo template.Repository, expr expr.TypeChecker, df expr.AttributeDescriptorFinder) error

SetupHandlers identifies and invokes all the type configuration (per template) that needs to be done on a handler.

func Store2Inventory

func Store2Inventory() []store.RegisterFunc2

Store2Inventory returns the inventory of Store2Backend.

func StoreInventory

func StoreInventory() []store.RegisterFunc

StoreInventory returns the inventory of store backends.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API defines and implements the configuration API. The server constructs and uses a validator for validations The server uses store.KeyValueStore to persist keys.

func NewAPI

func NewAPI(version string, port uint16, tc expr.TypeChecker, aspectFinder AspectValidatorFinder,
	builderFinder BuilderValidatorFinder, getBuilderInfoFns []adapter.InfoFn, findAspects AdapterToAspectMapper,
	store store.KeyValueStore, repository template.Repository) *API

NewAPI creates a new API server

func (*API) Run

func (a *API) Run()

Run calls listen and serve on the API server

type APIResponse

type APIResponse struct {
	Data   interface{} `json:"data,omitempty"`
	Status rpc.Status  `json:"status,omitempty"`
}

APIResponse defines the shape of the api response.

type AdapterToAspectMapper

type AdapterToAspectMapper func(builder string) KindSet

AdapterToAspectMapper returns the set of aspect kinds implemented by the given builder.

type AspectParams

type AspectParams proto.Message

AspectParams describes configuration parameters for an aspect.

type AspectValidator

type AspectValidator interface {
	// DefaultConfig returns a default configuration struct for this
	// adapter. This will be used by the configuration system to establish
	// the shape of the block of configuration state passed to the NewAspect method.
	DefaultConfig() (c AspectParams)

	// ValidateConfig determines whether the given configuration meets all correctness requirements.
	ValidateConfig(c AspectParams, validator expr.TypeChecker, finder descriptor.Finder) *adapter.ConfigErrors
}

AspectValidator describes a type that is able to validate Aspect configuration.

type AspectValidatorFinder

type AspectValidatorFinder func(kind Kind) (AspectValidator, bool)

AspectValidatorFinder is used to find specific underlying validators. Manager registry and adapter registry should implement this interface so ConfigValidators can be uniformly accessed.

type BuilderInfoFinder

type BuilderInfoFinder func(name string) (*adapter.Info, bool)

BuilderInfoFinder is used to find specific handlers Info for configuration.

type BuilderValidatorFinder

type BuilderValidatorFinder func(name string) (adapter.ConfigValidator, bool)

BuilderValidatorFinder is used to find specific underlying validators. Manager registry and adapter registry should implement this interface so ConfigValidators can be uniformly accessed.

type ChangeListener

type ChangeListener interface {
	ConfigChange(cfg Resolver, df descriptor.Finder, handlers map[string]*HandlerInfo)
}

ChangeListener listens for config change notifications.

type HandlerBuilderInfo

type HandlerBuilderInfo struct {
	// contains filtered or unexported fields
}

HandlerBuilderInfo stores validated HandlerBuilders..

type HandlerInfo

type HandlerInfo struct {
	Instance adapter.Handler
	Name     string
	// contains filtered or unexported fields
}

HandlerInfo stores validated and configured Handlers.

type Kind

type Kind uint

Kind of aspect

const (
	Unspecified Kind = iota
	// Please don't change the order, tests depend on the order.
	AttributesKind
	QuotasKind
	NumKinds
)

Supported kinds of aspects

func ParseKind

func ParseKind(s string) (Kind, bool)

ParseKind converts a string into a Kind.

func (Kind) String

func (k Kind) String() string

String returns the string representation of the kind, or "" if an unknown kind is given.

type KindSet

type KindSet uint

KindSet is a set of aspects by kind.

func (KindSet) IsSet

func (ks KindSet) IsSet(k Kind) bool

IsSet tests whether the given kind is enabled in the set.

func (KindSet) Set

func (ks KindSet) Set(k Kind) KindSet

Set returns a new KindSet with the given aspect kind enabled.

func (KindSet) String

func (ks KindSet) String() string

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Manager represents the config Manager. It is responsible for fetching and receiving configuration changes. It applies validated changes to the registered config change listeners. api.Handler listens for config changes.

func NewManager

func NewManager(eval expr.Evaluator, aspectFinder AspectValidatorFinder, builderFinder BuilderValidatorFinder,
	getBuilderInfoFns []adapter.InfoFn, findAspects AdapterToAspectMapper, repository template.Repository,
	store store.KeyValueStore, loopDelay time.Duration, identityAttribute string,
	identityAttributeDomain string) *Manager

NewManager returns a config.Manager. Eval validates and evaluates selectors. It is also used downstream for attribute mapping. AspectFinder finds aspect validator given aspect 'Kind'. BuilderFinder finds builder validator given builder 'Impl'. LoopDelay determines how often configuration is updated. The following fields will be eventually replaced by a repository location. At present we use GlobalConfig and ServiceConfig as command line input parameters. GlobalConfig specifies the location of Global Config. ServiceConfig specifies the location of Service config.

func (*Manager) Close

func (c *Manager) Close()

Close stops the config manager go routine.

func (*Manager) LastError

func (c *Manager) LastError() (err error)

LastError returns last error encountered by the manager while processing config.

func (*Manager) Register

func (c *Manager) Register(cc ChangeListener)

Register makes the ConfigManager aware of a ConfigChangeListener.

func (*Manager) Start

func (c *Manager) Start()

Start watching for configuration changes and handle updates.

type Resolver

type Resolver interface {
	// Resolve resolves configuration to a list of combined configs.
	Resolve(bag attribute.Bag, kindSet KindSet, strict bool) ([]*pb.Combined, error)
	// ResolveUnconditional resolves configuration for unconditioned rules.
	// Unconditioned rules are those rules with the empty selector ("").
	ResolveUnconditional(bag attribute.Bag, kindSet KindSet, strict bool) ([]*pb.Combined, error)
}

Resolver resolves configuration to a list of combined configs.

type SetupHandlerFn

type SetupHandlerFn func(actions []*pb.Action, instances map[string]*pb.Instance,
	handlers map[string]*HandlerBuilderInfo, tmplRepo template.Repository, expr expr.TypeChecker, df expr.AttributeDescriptorFinder) error

SetupHandlerFn is used to configure handler implementation with Types associated with all the templates that it supports.

type Validated

type Validated struct {
	// contains filtered or unexported fields
}

Validated store validated configuration. It has been validated as internally consistent and correct.

func (*Validated) Clone

func (v *Validated) Clone() *Validated

Clone makes a clone of validated config

Directories

Path Synopsis
Package crd provides the store interface to config resources stored as kubernetes custom resource definitions (CRDs).
Package crd provides the store interface to config resources stored as kubernetes custom resource definitions (CRDs).
Package store provides the interface to the backend storage for the config and the default fsstore implementation.
Package store provides the interface to the backend storage for the config and the default fsstore implementation.

Jump to

Keyboard shortcuts

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