Documentation
¶
Overview ¶
Package provision exposes the Engine type. Engine is a fully configurable type that can be used to implement custom provisioning of workloads
Index ¶
- func GetContract(ctx context.Context) substrate.NodeContract
- func GetDeployment(ctx context.Context) (gridtypes.Deployment, error)
- func GetDeploymentID(ctx context.Context) (twin uint32, deployment uint64)
- func GetEngine(ctx context.Context) provision.Engine
- func GetWorkload(ctx context.Context, name gridtypes.Name) (gridtypes.WorkloadWithID, error)
- func IsRentedNode(ctx context.Context) bool
- func NewMapProvisioner(managers map[gridtypes.WorkloadType]Manager) provision.Provisioner
- func NewRegistrarAdmins(registrarGateway *stubs.RegistrarGatewayStub, farmID uint64) (provision.Twins, error)
- func NewRegistrarTwins(registrarGateway *stubs.RegistrarGatewayStub) (provision.Twins, error)
- type Callback
- type EngineOption
- func WithAPIGateway(node uint64, registrarGateway *stubs.RegistrarGatewayStub) EngineOption
- func WithAdmins(g provision.Twins) EngineOption
- func WithCallback(cb Callback) EngineOption
- func WithRerunAll(t bool) EngineOption
- func WithStartupOrder(t ...gridtypes.WorkloadType) EngineOption
- func WithTwins(g provision.Twins) EngineOption
- type Initializer
- type Manager
- type NativeEngine
- func (e *NativeEngine) Admins() provision.Twins
- func (n *NativeEngine) Changes(twin uint32, contractID uint64) ([]gridtypes.Workload, error)
- func (n *NativeEngine) CreateOrUpdate(twin uint32, deployment gridtypes.Deployment, update bool) error
- func (e *NativeEngine) DecommissionCached(id string, reason string) error
- func (e *NativeEngine) Deprovision(ctx context.Context, twin uint32, id uint64, reason string) error
- func (n *NativeEngine) Get(twin uint32, contractID uint64) (gridtypes.Deployment, error)
- func (e *NativeEngine) GetWorkloadStatus(id string) (gridtypes.ResultState, bool, error)
- func (n *NativeEngine) List(twin uint32) ([]gridtypes.Deployment, error)
- func (n *NativeEngine) ListPrivateIPs(twin uint32, network gridtypes.Name) ([]string, error)
- func (n *NativeEngine) ListPublicIPs() ([]string, error)
- func (e *NativeEngine) Pause(ctx context.Context, twin uint32, id uint64) error
- func (e *NativeEngine) Provision(ctx context.Context, deployment gridtypes.Deployment) error
- func (e *NativeEngine) Resume(ctx context.Context, twin uint32, id uint64) error
- func (e *NativeEngine) Run(root context.Context) error
- func (e *NativeEngine) Storage() provision.Storage
- func (e *NativeEngine) Twins() provision.Twins
- func (e *NativeEngine) Update(ctx context.Context, update gridtypes.Deployment) error
- type Pauser
- type Response
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetContract ¶
func GetContract(ctx context.Context) substrate.NodeContract
GetContract of deployment. panics if engine has no substrate set.
func GetDeployment ¶
func GetDeployment(ctx context.Context) (gridtypes.Deployment, error)
GetDeployment gets a copy of the current deployment with latest state
func GetDeploymentID ¶
GetDeploymentID gets twin and deployment ID for current deployment
func GetWorkload ¶
GetWorkload get the last state of the workload for the current deployment
func IsRentedNode ¶
IsRentedNode returns true if current node is rented
func NewMapProvisioner ¶
func NewMapProvisioner(managers map[gridtypes.WorkloadType]Manager) provision.Provisioner
NewMapProvisioner returns a new instance of a map provisioner
func NewRegistrarAdmins ¶
func NewRegistrarAdmins(registrarGateway *stubs.RegistrarGatewayStub, farmID uint64) (provision.Twins, error)
NewRegistrarAdmins creates a twins db that implements the provision.Users interface. but it also make sure the user is an admin
func NewRegistrarTwins ¶
func NewRegistrarTwins(registrarGateway *stubs.RegistrarGatewayStub) (provision.Twins, error)
NewRegistrarTwins creates a users db that implements the provision.Users interface.
Types ¶
type EngineOption ¶
type EngineOption interface {
// contains filtered or unexported methods
}
EngineOption interface
func WithAPIGateway ¶
func WithAPIGateway(node uint64, registrarGateway *stubs.RegistrarGatewayStub) EngineOption
WithAPIGateway sets the API Gateway. If set it will be used by the engine to fetch (and validate) the deployment contract then contract with be available on the deployment context
func WithAdmins ¶
func WithAdmins(g provision.Twins) EngineOption
WithAdmins sets the admins key getter on the engine
func WithCallback ¶
func WithCallback(cb Callback) EngineOption
WithCallback sets a callback that is called when a deployment is being Created, Updated, Or Deleted The handler then can use the id to get current "state" of the deployment from storage and take proper action. A callback must not block otherwise the engine operation will get blocked
func WithRerunAll ¶
func WithRerunAll(t bool) EngineOption
WithRerunAll if set forces the engine to re-run all reservations on engine start.
func WithStartupOrder ¶
func WithStartupOrder(t ...gridtypes.WorkloadType) EngineOption
WithStartupOrder forces a specific startup order of types any type that is not listed in this list, will get started in an nondeterministic order
func WithTwins ¶
func WithTwins(g provision.Twins) EngineOption
WithTwins sets the user key getter on the engine
type Initializer ¶
Initializer interface define an extra Initialize method which is run on the provisioner before the provision engine is started.
type Manager ¶
type Manager interface {
Provision(ctx context.Context, wl *gridtypes.WorkloadWithID) (interface{}, error)
Deprovision(ctx context.Context, wl *gridtypes.WorkloadWithID) error
}
Manager defines basic type manager functionality. This interface declares the provision and the deprovision method which is required by any Type manager.
type NativeEngine ¶
type NativeEngine struct {
// contains filtered or unexported fields
}
NativeEngine is the core of this package The engine is responsible to manage provision and decomission of workloads on the system
func New ¶
func New(storage provision.Storage, provisioner provision.Provisioner, root string, opts ...EngineOption) (*NativeEngine, error)
New creates a new engine. Once started, the engine will continue processing all reservations from the reservation source and try to apply them. the default implementation is a single threaded worker. so it process one reservation at a time. On error, the engine will log the error. and continue to next reservation.
func (*NativeEngine) Admins ¶
func (e *NativeEngine) Admins() provision.Twins
Admins returns admins db
func (*NativeEngine) CreateOrUpdate ¶
func (n *NativeEngine) CreateOrUpdate(twin uint32, deployment gridtypes.Deployment, update bool) error
func (*NativeEngine) DecommissionCached ¶
func (e *NativeEngine) DecommissionCached(id string, reason string) error
DecommissionCached implements the zbus interface
func (*NativeEngine) Deprovision ¶
func (e *NativeEngine) Deprovision(ctx context.Context, twin uint32, id uint64, reason string) error
Deprovision workload
func (*NativeEngine) Get ¶
func (n *NativeEngine) Get(twin uint32, contractID uint64) (gridtypes.Deployment, error)
func (*NativeEngine) GetWorkloadStatus ¶
func (e *NativeEngine) GetWorkloadStatus(id string) (gridtypes.ResultState, bool, error)
GetWorkloadStatus get workload status, returns status, exists, error
func (*NativeEngine) List ¶
func (n *NativeEngine) List(twin uint32) ([]gridtypes.Deployment, error)
func (*NativeEngine) ListPrivateIPs ¶
func (*NativeEngine) ListPublicIPs ¶
func (n *NativeEngine) ListPublicIPs() ([]string, error)
func (*NativeEngine) Provision ¶
func (e *NativeEngine) Provision(ctx context.Context, deployment gridtypes.Deployment) error
Provision workload
func (*NativeEngine) Run ¶
func (e *NativeEngine) Run(root context.Context) error
Run starts reader reservation from the Source and handle them
func (*NativeEngine) Update ¶
func (e *NativeEngine) Update(ctx context.Context, update gridtypes.Deployment) error
Update workloads
type Pauser ¶
type Pauser interface {
Pause(ctx context.Context, wl *gridtypes.WorkloadWithID) error
Resume(ctx context.Context, wl *gridtypes.WorkloadWithID) error
}
Pauser defines optional Pause, Resume method for type managers. Types are allowed to implement pause, resume to put the workload in paused state where it's not usable by the user but at the same time not completely deleted.
type Response ¶
type Response interface {
error
// contains filtered or unexported methods
}
func Ok ¶
func Ok() Response
Ok response. you normally don't need to return this from Manager methods. instead returning `nil` error is preferred.