Documentation ¶
Index ¶
- Constants
- Variables
- func StartWatch(s Store) (map[Key]*Resource, <-chan Event, error)
- func WatchChanges(wch <-chan Event, stop <-chan struct{}, watchFlushDuration time.Duration, ...)
- type ApplyEventsFn
- type BackEndResource
- type Backend
- type BackendEvent
- type BackendValidator
- type Builder
- type ChangeType
- type Event
- type Key
- type RegisterFunc
- type Registry
- type Resource
- type ResourceMeta
- type Store
- type Validator
Constants ¶
const (
// example fs:///tmp/testdata/configroot
FSUrl = "fs"
)
URL types supported by the config store
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is the error to be returned when the given key does not exist in the storage.
var ErrWatchAlreadyExists = errors.New("watch already exists")
ErrWatchAlreadyExists is the error to report that the watching channel already exists.
Functions ¶
func StartWatch ¶
StartWatch registers with store, initiates a watch, and returns the current config state.
func WatchChanges ¶
func WatchChanges(wch <-chan Event, stop <-chan struct{}, watchFlushDuration time.Duration, applyEvents ApplyEventsFn)
WatchChanges watches for changes on a channel and publishes a batch of changes via applyEvents. WatchChanges is started in a goroutine.
Types ¶
type BackEndResource ¶
type BackEndResource struct { Kind string Metadata ResourceMeta Spec map[string]interface{} }
BackEndResource represents a resources with a raw spec
func ParseChunk ¶
func ParseChunk(chunk []byte) (*BackEndResource, error)
ParseChunk parses a YAML formatted bytes into a BackEndResource.
func (*BackEndResource) Key ¶
func (ber *BackEndResource) Key() Key
Key returns the key of the resource in the store.
type Backend ¶
type Backend interface { Init(kinds []string) error Stop() // WaitForSynced blocks and awaits for the caches to be fully populated until timeout. WaitForSynced(time.Duration) error // Watch creates a channel to receive the events. Watch() (<-chan BackendEvent, error) // Get returns a resource's spec to the key. Get(key Key) (*BackEndResource, error) // List returns the whole mapping from key to resource specs in the store. List() map[Key]*BackEndResource }
Backend defines the typeless storage backend for mixer.
type BackendEvent ¶
type BackendEvent struct { Key Type ChangeType Value *BackEndResource }
BackendEvent is an event used between Backend and Store.
type BackendValidator ¶
type BackendValidator interface {
Validate(ev *BackendEvent) error
}
BackendValidator defines the interface to validte unstructured event.
func NewValidator ¶
func NewValidator(ev Validator, kinds map[string]proto.Message) BackendValidator
NewValidator creates a default validator which validates the structure through registered kinds and referential integrity through ev.
type Builder ¶
type Builder func(u *url.URL, gv *schema.GroupVersion, credOptions *creds.Options, ck []string) (Backend, error)
Builder is the type of function to build a Backend.
type ChangeType ¶
type ChangeType int
ChangeType denotes the type of a change
const ( // Update - change was an update or a create to a key. Update ChangeType = iota // Delete - key was removed. Delete )
type Event ¶
type Event struct { Key Type ChangeType // Value refers the new value in the updated event. nil if the event type is delete. Value *Resource }
Event represents an event. Used by Store.Watch.
type RegisterFunc ¶
RegisterFunc is the type to register a builder for URL scheme.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry keeps the relationship between the URL scheme and the Backend implementation.
func NewRegistry ¶
func NewRegistry(inventory ...RegisterFunc) *Registry
NewRegistry creates a new Registry instance for the inventory.
type Resource ¶
type Resource struct { Metadata ResourceMeta Spec proto.Message }
Resource represents a resources with converted spec.
type ResourceMeta ¶
type ResourceMeta struct { Name string Namespace string Labels map[string]string Annotations map[string]string Revision string }
ResourceMeta is the standard metadata associated with a resource.
type Store ¶
type Store interface { Init(kinds map[string]proto.Message) error Stop() // WaitForSynced blocks and awaits for the caches to be fully populated until timeout. WaitForSynced(time.Duration) error // Watch creates a channel to receive the events. A store can conduct a single // watch channel at the same time. Multiple calls lead to an error. Watch() (<-chan Event, error) // Get returns the resource to the key. Get(key Key) (*Resource, error) // List returns the whole mapping from key to resource specs in the store. List() map[Key]*Resource probe.SupportsProbe }
Store defines the access to the storage for mixer.
func WithBackend ¶
WithBackend creates a new Store with a certain backend. This should be used only by tests.