lro

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package lro provides Long Running Operation (LRO) background processing.

Index

Constants

View Source
const (
	// Active indicates the item is in the queue to be processed, or is being processed.
	Active = "active"
	// Inactive indicates the item has been ABORTED or COMPLETED
	Inactive = "inactive"
)

Variables

This section is empty.

Functions

func StateToString

func StateToString(state pb.Process_Status_State) string

StateToString offers a human-readable label for a State enum.

Types

type LRO

type LRO interface {
	AddRealmRemoval(id, realm string, identity *ga4gh.Identity, tx storage.Tx) (*pb.Process_Work, error)
	Remove(id string, tx storage.Tx) error
	Run(ctx context.Context)
}

LRO is an interface for long running operations.

type Service

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

Service is a long running operation service.

func New

func New(name string, wakeFrequency, maxProgress time.Duration, store storage.Store, tx storage.Tx) (*Service, error)

New creates a new LRO processing routine that holds multiple LROs that share the same setup parameters.

func (*Service) AddRealmRemoval

func (s *Service) AddRealmRemoval(id, realm string, identity *ga4gh.Identity, tx storage.Tx) (*pb.Process_Work, error)

AddRealmRemoval adds a LRO work item for the stated goal to the state for workers to process.

func (*Service) CleanupWork

func (s *Service) CleanupWork(ctx context.Context, state *pb.Process, workName string, process *processlib.Process) error

CleanupWork has a worker perform the work needed to clean up a work item that was active previously.

func (*Service) ProcessActiveWork

func (s *Service) ProcessActiveWork(ctx context.Context, state *pb.Process, workName string, work *pb.Process_Work, process *processlib.Process) error

ProcessActiveWork has a worker perform the work needed to process an active work item.

func (*Service) Remove

func (s *Service) Remove(id string, tx storage.Tx) error

Remove deletes one LRO work item from the active queue or inactive list. It does not provide any cleanup if the state is partial. Depending on execution, this deletion could later be rewritten by an active processing agent, so deleting is a best effort.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run schedules a background process. Typically this will be on its own go routine.

func (*Service) Wait

func (s *Service) Wait(ctx context.Context, schedule time.Duration) bool

Wait indicates that the worker should wait for the next active cycle to begin.

func (*Service) WaitCondition

func (s *Service) WaitCondition(fn func(ctx context.Context, duration time.Duration) bool)

WaitCondition registers a callback that is called and checks conditions before every wait cycle.

Jump to

Keyboard shortcuts

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