Documentation ¶
Index ¶
- Variables
- type Action
- type InstanceOperation
- func Create(projectName string, instanceName string, apiOp *operations.Operation, ...) (*InstanceOperation, error)
- func CreateWaitGet(projectName string, instanceName string, apiOp *operations.Operation, ...) (*InstanceOperation, error)
- func Get(projectName string, instanceName string) *InstanceOperation
- func (op *InstanceOperation) Action() Action
- func (op *InstanceOperation) ActionMatch(matchActions ...Action) bool
- func (op *InstanceOperation) Done(err error)
- func (op *InstanceOperation) GetInstanceInitiated() bool
- func (op *InstanceOperation) GetOperation() *operations.Operation
- func (op *InstanceOperation) SetInstanceInitiated(instanceInitiated bool)
- func (op *InstanceOperation) Wait(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ErrNonReusuableSucceeded error = fmt.Errorf("A matching non-reusable operation has now succeeded")
ErrNonReusuableSucceeded is returned when no operation is created due to having to wait for a matching non-reusuable operation that has now completed successfully.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action string
Action indicates the operation action type.
const ActionCreate Action = "create"
ActionCreate for creating an instance.
const ActionDelete Action = "delete"
ActionDelete for deleting an instance.
const ActionMigrate Action = "migrate"
ActionMigrate for migrating an instance.
const ActionRestart Action = "restart"
ActionRestart for restarting an instance.
const ActionRestore Action = "restore"
ActionRestore for restoring an instance.
const ActionStart Action = "start"
ActionStart for starting an instance.
const ActionStop Action = "stop"
ActionStop for stopping an instance.
const ActionUpdate Action = "update"
ActionUpdate for updating an instance.
type InstanceOperation ¶
type InstanceOperation struct {
// contains filtered or unexported fields
}
InstanceOperation operation locking.
func Create ¶
func Create(projectName string, instanceName string, apiOp *operations.Operation, action Action, createReusuable bool, reuseExisting bool) (*InstanceOperation, error)
Create creates a new operation lock for an Instance if one does not already exist and returns it. The lock will be released after TimeoutDefault or when Done() is called, which ever occurs first. If createReusuable is set as true then future lock attempts can specify the reuseExisting argument as true which will then trigger a reset of the timeout to TimeoutDefault on the existing lock and return it.
func CreateWaitGet ¶
func CreateWaitGet(projectName string, instanceName string, apiOp *operations.Operation, action Action, inheritableActions []Action, createReusuable bool, reuseExisting bool) (*InstanceOperation, error)
CreateWaitGet is a weird function which does what we happen to want most of the time.
If the instance has an operation of the same type and it's not reusable or the caller doesn't want to reuse it, the function will wait and indicate that it did so.
If the instance has an existing operation of one of the inheritableActions types, then the operation is returned to the user. This allows an operation started in one function/routine to be inherited by another.
If the instance doesn't have an ongoing operation, has an operation of a different type that is not in the inheritableActions list or has the right type and is being reused, then this behaves as a Create call.
Returns ErrWaitedForMatching if it waited for a matching operation to finish and it's finished successfully and so didn't return create a new operation.
func Get ¶
func Get(projectName string, instanceName string) *InstanceOperation
Get retrieves an existing lock or returns nil if no lock exists.
func (*InstanceOperation) Action ¶
func (op *InstanceOperation) Action() Action
Action returns operation's action.
func (*InstanceOperation) ActionMatch ¶
func (op *InstanceOperation) ActionMatch(matchActions ...Action) bool
ActionMatch returns true if operation's action matches one of the matchActions.
func (*InstanceOperation) Done ¶
func (op *InstanceOperation) Done(err error)
Done indicates the operation has finished.
func (*InstanceOperation) GetInstanceInitiated ¶
func (op *InstanceOperation) GetInstanceInitiated() bool
GetInstanceInitiated gets the instance initiated marker.
func (*InstanceOperation) GetOperation ¶ added in v6.0.2
func (op *InstanceOperation) GetOperation() *operations.Operation
GetOperation gets the API background operation.
func (*InstanceOperation) SetInstanceInitiated ¶
func (op *InstanceOperation) SetInstanceInitiated(instanceInitiated bool)
SetInstanceInitiated sets the instance initiated marker.