lro

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lro implements google.longrunning Operations for services whose mutations are long-running in GCP (FR-CORE-023).

A service creates one Manager, calls Register in its own Register (which installs a shared google.longrunning.Operations gRPC server on the gateway once per gRPC server) and starts operations with Run. Operations are named "<parent>/operations/<uuid>" (normally parent is "projects/P/locations/L"), persisted in the store namespace "lro/operations" and complete after env.Config.LRO(service); a latency of zero completes them before Run returns. ServeREST serves the REST mappings for services whose clients poll operations over HTTP.

Index

Constants

View Source
const Namespace = "lro/operations"

Namespace is the store namespace holding operations, keyed by name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager creates and completes the operations of one service.

func NewManager

func NewManager(env *emu.Env, service string) *Manager

NewManager returns a manager for service.

func (*Manager) Close

func (m *Manager) Close()

Close stops pending timers and detaches the manager from its server.

func (*Manager) Get

func (m *Manager) Get(name string) (*longrunningpb.Operation, error)

Get returns an operation of this service.

func (*Manager) Latency

func (m *Manager) Latency() time.Duration

Latency returns the configured operation latency for the service.

func (*Manager) Operations added in v0.2.0

func (m *Manager) Operations() []emu.OperationInfo

Operations implements emu.OperationLister for the manager's service.

func (*Manager) Register

func (m *Manager) Register(r emu.Router)

Register installs the shared Operations gRPC server on r (once per gRPC server) and marks operations left pending by a previous process as aborted, since their work cannot be resumed.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, parent string, metadata proto.Message, run RunFunc) (*longrunningpb.Operation, error)

Run starts an operation under parent with the given metadata. With zero latency run executes synchronously and the returned operation is done; otherwise run executes after the latency and the operation is returned pending. The ctx values (principal) are kept for the deferred run.

func (*Manager) ServeREST

func (m *Manager) ServeREST(w http.ResponseWriter, r *http.Request, path string) bool

ServeREST serves the google.longrunning REST mappings for this service's operations. path is the resource path after the API version, e.g. "projects/P/locations/L/operations/ID" (optionally with ":cancel" or ":wait"), or "projects/P/locations/L/operations" to list. It reports whether path addressed an operation; when false nothing was written.

GET    {name=**/operations/*}
DELETE {name=**/operations/*}
POST   {name=**/operations/*}:cancel
POST   {name=**/operations/*}:wait
GET    {name=**}/operations

type RunFunc

type RunFunc func(ctx context.Context) (proto.Message, error)

RunFunc performs the operation's work and returns its response message (e.g. the created resource, or emptypb.Empty for deletes).

type Server

type Server struct {
	longrunningpb.UnimplementedOperationsServer
	// contains filtered or unexported fields
}

Server implements google.longrunning.Operations over every operation in the store; managers attached to it handle cancellation.

func (*Server) CancelOperation

func (s *Server) CancelOperation(_ context.Context, req *longrunningpb.CancelOperationRequest) (*emptypb.Empty, error)

CancelOperation implements longrunningpb.OperationsServer.

func (*Server) DeleteOperation

func (s *Server) DeleteOperation(_ context.Context, req *longrunningpb.DeleteOperationRequest) (*emptypb.Empty, error)

DeleteOperation implements longrunningpb.OperationsServer.

func (*Server) GetOperation

GetOperation implements longrunningpb.OperationsServer.

func (*Server) ListOperations

ListOperations implements longrunningpb.OperationsServer; req.Name is the parent collection owner (e.g. "projects/P/locations/L").

func (*Server) WaitOperation

WaitOperation implements longrunningpb.OperationsServer.

Jump to

Keyboard shortcuts

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