operator

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHandler added in v0.1.2

type BaseHandler struct {
}

func (*BaseHandler) PostHook added in v0.1.2

func (b *BaseHandler) PostHook(*HookCtx) error

type BaseResource

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

BaseResource is a resource that can have multiple instances

func (*BaseResource) Init added in v0.1.2

func (b *BaseResource) Init(spec map[string]interface{}) error

Init implements the Resource interface

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

	// State is the state access
	State state.State

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

	// GRPCAddr is the address of the grpc server
	GRPCAddr *net.TCPAddr
}

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 {

	// EvaluatePlan evaluates and modifies the execution plan
	EvaluatePlan(*PlanCtx) error

	// PostHook is executed when a node changes the state
	PostHook(*HookCtx) 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 HookCtx added in v0.1.2

type HookCtx struct {
	Cluster  *proto.Cluster
	Node     *proto.Node
	Executor Executor
}

type NodeUpdate added in v0.1.2

type NodeUpdate struct {
	// id of the node that has failed
	ID        string
	ClusterID string
}

NodeUpdate is an update from a node (TODO: move to proto)

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 PlanCtx added in v0.1.2

type PlanCtx struct {
	Cluster *proto.Cluster
	Plan    *proto.Plan
}

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)

	// WatchUpdates watches for updates from nodes
	WatchUpdates() chan *NodeUpdate

	// Exec executes a shell script
	Exec(handler string, path string, args ...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
	Init(spec map[string]interface{}) error
}

Resource is a resource in the cluster

type Server

type Server struct {
	Provider Provider
	State    state.State
	// 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 (*Server) Config added in v0.1.1

func (s *Server) Config() *Config

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