driver

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package driver provides the interface for providers of runtimevar. This serves as a contract of how the runtimevar API uses a provider implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Variable

type Variable struct {
	Value      interface{}
	UpdateTime time.Time
}

Variable contains a runtime variable and additional metadata about it.

type Watcher

type Watcher interface {
	// WatchVariable blocks until the variable changes, the Context's Done channel closes or an
	// error occurs.
	//
	// If the variable has changed, then method should return a Variable object with the
	// new value.
	//
	// It is recommended that an implementation should avoid returning the same error of the
	// previous WatchVariable call if the implementation can detect such and treat as no changes had
	// incurred instead.  A sample case is when the variable is deleted, WatchVariable should return an
	// error upon initial detection.  A succeeding WatchVariable call may decide to block until
	// the variable source is restored.
	//
	// To stop this function from blocking, caller can passed in Context object constructed via
	// WithCancel and call the cancel function.
	WatchVariable(context.Context) (Variable, error)
	// Close cleans up any resources used by the Watcher object.
	Close() error
}

Watcher watches for updates on a variable and returns an updated Variable object if there are changes. A Watcher object is associated with a variable upon construction.

An application can have more than one Watcher, one for each variable. It is typical to only have one Watcher per variable.

A Watcher provider can dictate the type of Variable.Value if the backend service dictates a particular format and type. If the backend service has the flexibility to store bytes and allow clients to dictate the format, it is better for a Watcher provider to allow users to dictate the type of Variable.Value and a decoding function. The Watcher provider can use the runtimevar.Decoder to facilitate the decoding logic.

Jump to

Keyboard shortcuts

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