operationlock

package
v0.0.0-...-a810e79 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstanceOperation

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

InstanceOperation operation locking.

func Create

func Create(instanceID int, action string, reusable bool, reuse 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 30s or when Done() is called, which ever occurs first. If reusable is set as true then future lock attempts can specify the reuse argument as true which will then trigger a reset of the 30s timeout on the existing lock and return it.

func CreateWaitGet

func CreateWaitGet(instanceID int, action string, altActions []string, reusable bool, reuse bool) (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 operation of one of the alternate types, then the operation is returned to the user.

If the instance doesn't have an operation, has an operation of a different type that is not in the alternate list or has the right type and is being reused, then this behaves as a Create call.

func Get

func Get(instanceID int) *InstanceOperation

Get retrieves an existing lock or returns nil if no lock exists.

func (InstanceOperation) Action

func (op InstanceOperation) Action() string

Action returns operation's action.

func (*InstanceOperation) Done

func (op *InstanceOperation) Done(err error)

Done indicates the operation has finished.

func (*InstanceOperation) Reset

func (op *InstanceOperation) Reset() error

Reset resets the operation timeout.

func (*InstanceOperation) Wait

func (op *InstanceOperation) Wait() error

Wait waits for an operation to finish.

Jump to

Keyboard shortcuts

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