scope

package
v0.4.2-0...-ae8ecb7 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Nil = DefaultScope(func() discovery.Plugins {
	d, err := local.NewPluginDiscovery()
	if err != nil {
		panic(err)
	}
	return d
})

Nil is no scope

Functions

func DefaultControllerResolver

func DefaultControllerResolver(plugins func() discovery.Plugins) func(string) (controller.Controller, error)

DefaultControllerResolver returns a resolver

func DefaultFlavorResolver

func DefaultFlavorResolver(plugins func() discovery.Plugins) func(string) (flavor.Plugin, error)

DefaultFlavorResolver returns a resolver

func DefaultGroupResolver

func DefaultGroupResolver(plugins func() discovery.Plugins) func(string) (group.Plugin, error)

DefaultGroupResolver returns a resolver

func DefaultInstanceResolver

func DefaultInstanceResolver(plugins func() discovery.Plugins) func(string) (instance.Plugin, error)

DefaultInstanceResolver returns a resolver

func DefaultL4Resolver

func DefaultL4Resolver(plugins func() discovery.Plugins) func(string) (loadbalancer.L4, error)

DefaultL4Resolver returns a resolver

func DefaultMetadataResolver

func DefaultMetadataResolver(plugins func() discovery.Plugins) func(string) (*MetadataCall, error)

DefaultMetadataResolver returns a resolver

func IsExpired

func IsExpired(err error) bool

IsExpired returns true if the error is from wait expired / timeout

func IsReadonly

func IsReadonly(err error) bool

IsReadonly returns true if the error is from wait expired / timeout

func MetadataFunc

func MetadataFunc(scope Scope) func(string, ...interface{}) (interface{}, error)

MetadataFunc returns a template function to support metadata retrieval in templates. The function allows an additional parameter to set the value, provided the metadata plugin is not readonly (supports the metadata.Updatable spi). In the case of an update, the returned value is always an empty string, with error (can be nil). The behavior is the same as var function.

Types

type MetadataCall

type MetadataCall struct {
	Plugin metadata.Plugin
	Name   plugin.Name
	Key    types.Path
}

MetadataCall is a struct that has all the information needed to evaluate a template metadata function

type Scope

type Scope interface {

	// Plugins returns the plugin lookup
	Plugins() discovery.Plugins

	// Stack returns the stack that entails this scope
	Stack() (stack.Interface, error)

	// Group is for looking up an group plugin
	Group(n string) (group.Plugin, error)

	// Controller returns the controller by name
	Controller(n string) (controller.Controller, error)

	// Instance is for looking up an instance plugin
	Instance(n string) (instance.Plugin, error)

	// Flavor is for lookup up a flavor plugin
	Flavor(n string) (flavor.Plugin, error)

	// L4 is for lookup up an L4 plugin
	L4(n string) (loadbalancer.L4, error)

	// Metadata is for resolving metadata / path related queries
	Metadata(p string) (*MetadataCall, error)

	// TemplateEngine creates a template engine for use.
	TemplateEngine(url string, opts template.Options) (*template.Template, error)
}

Scope provides an environment in which the necessary plugins are available for doing a unit of work. The scope can be local or remote, namespaced, depending on implementation. The first implementation is to simply run a set of steps locally on a set of required plugins. Because the scope provides the plugin lookup, it can control what plugins are available. This is good for programmatically control access of what a piece of code can interact with the system. Scope is named scope instead of 'context' because it's much heavier weight and involves lots of calls across process boundaries, yet it provides lookup and scoping of services based on some business logical and locality of code.

func DefaultScope

func DefaultScope(plugins func() discovery.Plugins) Scope

DefaultScope returns the default scope

type Work

type Work func(Scope) error

Work is a unit of work that is executed in the scope of the plugins running. When work completes, the plugins are shutdown.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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