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
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Get(name string) (*longrunningpb.Operation, error)
- func (m *Manager) Latency() time.Duration
- func (m *Manager) Operations() []emu.OperationInfo
- func (m *Manager) Register(r emu.Router)
- func (m *Manager) Run(ctx context.Context, parent string, metadata proto.Message, run RunFunc) (*longrunningpb.Operation, error)
- func (m *Manager) ServeREST(w http.ResponseWriter, r *http.Request, path string) bool
- type RunFunc
- type Server
- func (s *Server) CancelOperation(_ context.Context, req *longrunningpb.CancelOperationRequest) (*emptypb.Empty, error)
- func (s *Server) DeleteOperation(_ context.Context, req *longrunningpb.DeleteOperationRequest) (*emptypb.Empty, error)
- func (s *Server) GetOperation(_ context.Context, req *longrunningpb.GetOperationRequest) (*longrunningpb.Operation, error)
- func (s *Server) ListOperations(_ context.Context, req *longrunningpb.ListOperationsRequest) (*longrunningpb.ListOperationsResponse, error)
- func (s *Server) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest) (*longrunningpb.Operation, error)
Constants ¶
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 ¶
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) Operations ¶ added in v0.2.0
func (m *Manager) Operations() []emu.OperationInfo
Operations implements emu.OperationLister for the manager's service.
func (*Manager) Register ¶
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 ¶
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 ¶
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 ¶
func (s *Server) GetOperation(_ context.Context, req *longrunningpb.GetOperationRequest) (*longrunningpb.Operation, error)
GetOperation implements longrunningpb.OperationsServer.
func (*Server) ListOperations ¶
func (s *Server) ListOperations(_ context.Context, req *longrunningpb.ListOperationsRequest) (*longrunningpb.ListOperationsResponse, error)
ListOperations implements longrunningpb.OperationsServer; req.Name is the parent collection owner (e.g. "projects/P/locations/L").
func (*Server) WaitOperation ¶
func (s *Server) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest) (*longrunningpb.Operation, error)
WaitOperation implements longrunningpb.OperationsServer.