operations

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdmissionController

type AdmissionController interface {
	// Admit transactionally clears an operation to be performed.
	Admit(context.Context, *pb.InProgressOperation) (AdmissionRelease, error)
	// CanAdmit optimistically determines if there's capacity to run an operation.
	CanAdmit(context.Context, *pb.InProgressOperation) error
}

AdmissionController determines if an operation can be processed.

func NewCountAdmissionController

func NewCountAdmissionController(ctx context.Context, name string, capacity int, tokenFunc func(*pb.InProgressOperation) int) AdmissionController

NewCountAdmissionController creates an admission controller based on a token counter.

func NewThreadAdmissionController

func NewThreadAdmissionController(ctx context.Context, name string, capacity int) AdmissionController

NewThreadAdmissionController creates an admission controller based on a thread pool size.

type AdmissionRelease

type AdmissionRelease interface {
	// Release the tokens. Subsequent calls have no effect.
	Release(context.Context) error
}

AdmissionRelease releases the tokens that were acquired for the operation.

type Handle

type Handle interface {
	// SetStatus on the operation.
	SetStatus(label string, currentValue int, targetValue int)
	// GetName returns the name of the operation.
	GetName() string
	// Get the current state of the operation. This method returns the cached
	// version of the operation data.
	Get() (*pb.InProgressOperation, error)
	// Finish the operation.
	Finish(data proto.Message) (*pb.InProgressOperation, error)
	// Update the operation with new data with throttling. Good for frequent updates.
	Update(data proto.Message, statusLabel string, currentValue int, targetValue int)
	// UpdateImmediately the operation with new data immediately.
	UpdateImmediately(data proto.Message, statusLabel string, currentValue int, targetValue int) (*pb.InProgressOperation, error)
}

Handle mutates operations.

type Handler

type Handler interface {
	// ExecuteOperation runs an attempt to process an operation.
	ExecuteOperation(Handle) error
	// ExecuteOperationRollback runs an attempt to rollback the operation that failed.
	ExecuteOperationRollback(Handle) error
}

Handler handles callback events when an operation is requested to be handled by the server.

type Listener

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

Listener creates an operation polling loop and auto responder.

func NewListener

func NewListener(action string, clients *appmain.Clients, interval time.Duration, admissionController AdmissionController) *Listener

NewListener creates an operation listener.

func (*Listener) Accept

Accept an operation to work on.

func (*Listener) Start

func (l *Listener) Start(handler Handler)

Start operation polling.

func (*Listener) Stop

func (l *Listener) Stop()

Stop operation polling.

type Wait

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

Wait for an operation to be completed.

func NewWait

func NewWait(clients *appmain.Clients, operationName string) *Wait

NewWait creates an operation waiter.

func (*Wait) GetResult

func (w *Wait) GetResult() (*longrunning.Operation, bool, error)

GetResult of the operation.

func (*Wait) Wait

func (w *Wait) Wait(ctx context.Context) <-chan *Wait

Wait for the operation to complete.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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