resource

package
v0.0.0-...-3a937ec Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Plan

func Plan(left, right allocation.ResourceSlice) (c, u, d allocation.ResourceSlice)

Types

type Estimator

type Estimator interface {

	// Get estimator uuid
	Results() (uid string, ctx context.Context, ch chan *estimator.Result)

	// Create resource and notify downstream
	Create(id string, request *allocation.Resource) (err error)

	// Update resource and notify downstream
	Update(id string, request *allocation.Resource) (err error)

	// Destroy resource and notify downstream
	Destroy(name string) (err error)

	// Destroy all resources without notify downstream
	Shutdown()
	io.Closer
}

Estimator estimates resources and sends results to downstream consumer in form id:map[string]string there values are:

allocated = true|false
<key> = "<value>"

Downstream should be notified about destroyed resources by message with empty payload.

func GetEstimator

func GetEstimator(globalConfig estimator.GlobalConfig, config estimator.Config) (e Estimator, err error)

type Evaluator

type Evaluator struct {
	*supervisor.Control
	// contains filtered or unexported fields
}

func NewEvaluator

func NewEvaluator(ctx context.Context, log *logx.Log, upstream, downstream bus.Consumer, dirty allocation.PodSlice) (e *Evaluator)

func (*Evaluator) Allocate

func (e *Evaluator) Allocate(pod *manifest.Pod, env map[string]string)

func (*Evaluator) CreateProvider

func (e *Evaluator) CreateProvider(id string, alloc *allocation.Provider)

Create provider

func (*Evaluator) Deallocate

func (e *Evaluator) Deallocate(name string)

func (*Evaluator) DestroyProvider

func (e *Evaluator) DestroyProvider(id string)

func (*Evaluator) GetConstraint

func (e *Evaluator) GetConstraint(pod *manifest.Pod) (c manifest.Constraint)

If Pod has any resources returns "${provider.<resource-provider>.allocated}":"true" for each resource. Elsewhere returns "resource.allocate":"false".

func (*Evaluator) Open

func (e *Evaluator) Open() (err error)

func (*Evaluator) UpdateProvider

func (e *Evaluator) UpdateProvider(id string, alloc *allocation.Provider)

type Sandbox

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

Sandbox manages underlying estimator and proxies notifications to downstream

func NewSandbox

func NewSandbox(config SandboxConfig, id string, provider *allocation.Provider) (s *Sandbox)

func (*Sandbox) Close

func (s *Sandbox) Close() (err error)

close sandbox without deallocate any resources

func (*Sandbox) Configure

func (s *Sandbox) Configure(p *allocation.Provider) (err error)

Update provider

func (*Sandbox) Create

func (s *Sandbox) Create(id string, req *allocation.Resource)

Create resource with id

func (*Sandbox) Destroy

func (s *Sandbox) Destroy(id string)

func (*Sandbox) Shutdown

func (s *Sandbox) Shutdown() (err error)

Destroy all resources in sandbox and notify upstream and downstream

func (*Sandbox) Update

func (s *Sandbox) Update(id string, req *allocation.Resource)

type SandboxConfig

type SandboxConfig struct {
	Ctx          context.Context
	Log          *logx.Log
	GlobalConfig estimator.GlobalConfig
	Upstream     bus.Consumer // "resource." upstream (lifted)
	Downstream   bus.Consumer // "provider." upstream (lifted)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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