operator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleResource

func HandleResource(eval *proto.Evaluation, handler Handler, e *proto.Cluster) error

Types

type BaseResource

type BaseResource struct {
	ID string `schema:"id"`
}

BaseResource is a resource that can have multiple instances

func (*BaseResource) SetID

func (b *BaseResource) SetID(id string)

SetID sets the id of the specific resource

type Config

type Config struct {
	// Provider is the provider used by the operator
	Provider Provider

	// Backends are the list of backends handled by the operator
	HandlerFactories []HandlerFactory
}

Config is the parametrization of the operator server

type Executor

type Executor interface {
	Exec(n *proto.Node, path string, cmd ...string) error
}

Executor is the interface required by the backends to execute

type Handler

type Handler interface {
	// Reconcile is called whenever there is an internal state change in the cluster
	Reconcile(executor Executor, e *proto.Cluster, node *proto.Node, plan *proto.Plan) error

	// EvaluatePlan evaluates and modifies the execution plan
	EvaluatePlan(plan *proto.Plan) error

	// Spec returns the specification for the cluster
	Spec() *Spec

	// Client returns a connection with a specific node in the cluster
	Client(node *proto.Node) (interface{}, error)
}

Handler is the interface that needs to be implemented by the backend

type HandlerFactory

type HandlerFactory func() Handler

HandlerFactory is a factory for Handlers

type Nodetype

type Nodetype struct {
	// Image is the default docker image for the node
	Image string

	// Version is the default docker image for the node
	Version string

	// Volume is a list volumes for this node type
	Volumes []*Volume

	// Ports is a list of ports for this node type
	Ports []*Port
}

Nodetype is a type of node for the Backend

type Port

type Port struct {
	Name        string
	Port        uint64
	Description string
}

Port is an exposed port for the node

type Provider

type Provider interface {
	// Setup setups the provider (Maybe do this on the factory)
	Setup() error

	// Start starts the provider
	Start() error

	// CreateResource creates the computational resource
	CreateResource(*proto.Node) (*proto.Node, error)

	// DeleteResource deletes the computational resource
	DeleteResource(*proto.Node) (*proto.Node, error)

	// Exec executes a shell script
	Exec(handler string, path string, args ...string) error

	// Update the status of the node
	UpdateNodeStatus(*proto.Node) (*proto.Node, error)

	// LoadCluster loads a Cluster at the specific resourceVersion
	LoadCluster(name string) (*proto.Cluster, error)

	// GetTask receives updates for ensembles
	GetTask() (*proto.Task, error)

	// FinalizeTask is used to notify the provider that the given task is done
	FinalizeTask(uuid string) error
}

Provider is the entity that holds the state of the infrastructure. Both for the computing resources and the general resources.

type ProviderFactory

type ProviderFactory func(map[string]interface{}) error

ProviderFactory is a factory method to create factories

type Resource

type Resource interface {
	GetName() string
	Delete(conn interface{}) error
	Reconcile(conn interface{}) error
}

Resource is a resource in the cluster

type Server

type Server struct {
	Provider Provider
	// contains filtered or unexported fields
}

Server is the operator server

func NewServer

func NewServer(logger hclog.Logger, config *Config) (*Server, error)

NewServer starts an instance of the operator server

func TestOperator

func TestOperator(t *testing.T, provider Provider, factory HandlerFactory) *Server

func (*Server) Exec

func (s *Server) Exec(n *proto.Node, path string, cmd ...string) error

Exec implements the Activator interface

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server

type Spec

type Spec struct {
	Name      string
	Nodetypes map[string]Nodetype
	Resources []Resource
}

Spec returns the backend specification

type Volume

type Volume struct {
	Name        string
	Path        string
	Description string
}

Volume is a mounted path for the node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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