Documentation ¶
Overview ¶
Package lro contains an implementation of https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#OperationsServer
Index ¶
- Constants
- Variables
- func BuildOperation(id string, done bool, result *anypb.Any, e error) *opspb.Operation
- func CreateJobID() string
- func GetOperationData(id string, j job) *opspb.Operation
- type Job
- type Server
- func (s *Server) AddJob(id string, job job) error
- func (s *Server) CancelOperation(_ context.Context, request *opspb.CancelOperationRequest) (*emptypb.Empty, error)
- func (s *Server) DeleteExpiredJobs(ttlAfterDelete time.Duration, ttlAfterComplete time.Duration)
- func (s *Server) DeleteOperation(_ context.Context, request *opspb.DeleteOperationRequest) (*emptypb.Empty, error)
- func (s *Server) EndOperation(id string, status string)
- func (s *Server) GetOperation(_ context.Context, request *opspb.GetOperationRequest) (*opspb.Operation, error)
- func (s *Server) ListOperations(_ context.Context, request *opspb.ListOperationsRequest) (*opspb.ListOperationsResponse, error)
- func (s *Server) WaitAndUnmarshalResult(ctx context.Context, opName string, targetProto proto.Message) error
- func (s *Server) WaitOperation(_ context.Context, request *opspb.WaitOperationRequest) (*opspb.Operation, error)
Constants ¶
const ( // TaskIDMetadataTag is the tag for the task ID in gRPC metadata. TaskIDMetadataTag = "taskID" // JobStartIndicator is a log line we use to identify when the job has been started. JobStartIndicator = "CreateAndRunLROJobWithID: Create and run LRO job with id %v" )
const ( // DefaultWaitOperationTimeOut is the timeout for WaitOperation. DefaultWaitOperationTimeOut = 1 * time.Hour )
Variables ¶
var CreateAndRunLROJobWithID = func(ctx context.Context, id, name string, lro *Server, call func(ctx context.Context) (proto.Message, error)) (*Job, error) { if id == "" { id = CreateJobID() } job := &Job{ id: id, name: name, call: call, lro: lro, } return addAndStartJob(ctx, lro, job) }
CreateAndRunLROJobWithID creates an LRO job that can be cancelled. The method passed in is the main part of the call, adding into the job set and then starting it. It uses the given lro job id as the id.
Functions ¶
func BuildOperation ¶
BuildOperation builds the operation response for this specific grpcstatus.
func GetOperationData ¶
GetOperationData fills in the operation data for this specific job.
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job represents a long running operation and its metadata.
func CreateAndRunLROJobWithContext ¶
func CreateAndRunLROJobWithContext(ctx context.Context, name string, lro *Server, call func(ctx context.Context) (proto.Message, error)) (*Job, error)
CreateAndRunLROJobWithContext creates an LRO job that can be cancelled. The method passed in is the main part of the call, adding into the job set and then starting it. It pulls the job id from grpc context.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a gRPC based operation server which implements google/longrunning/operations.proto .
func (*Server) CancelOperation ¶
func (s *Server) CancelOperation(_ context.Context, request *opspb.CancelOperationRequest) (*emptypb.Empty, error)
CancelOperation cancels a long running operation. It is the implementation of CancelOperation in google/longrunning/operations.proto.
func (*Server) DeleteExpiredJobs ¶
DeleteExpiredJobs deletes the jobs that are considered as expired.
func (*Server) DeleteOperation ¶
func (s *Server) DeleteOperation(_ context.Context, request *opspb.DeleteOperationRequest) (*emptypb.Empty, error)
DeleteOperation is part of google/longrunning/operations.proto.
func (*Server) EndOperation ¶
EndOperation records the result of the operation.
func (*Server) GetOperation ¶
func (s *Server) GetOperation(_ context.Context, request *opspb.GetOperationRequest) (*opspb.Operation, error)
GetOperation gets the status of the LRO operation. It is the implementation of GetOperation in google/longrunning/operations.proto.
func (*Server) ListOperations ¶
func (s *Server) ListOperations(_ context.Context, request *opspb.ListOperationsRequest) (*opspb.ListOperationsResponse, error)
ListOperations is part of google/longrunning/operations.proto. It is not implemented fully yet.
func (*Server) WaitAndUnmarshalResult ¶
func (s *Server) WaitAndUnmarshalResult(ctx context.Context, opName string, targetProto proto.Message) error
WaitAndUnmarshalResult waits until the operation with the opName finishes, and either populates the result or the error.
func (*Server) WaitOperation ¶
func (s *Server) WaitOperation(_ context.Context, request *opspb.WaitOperationRequest) (*opspb.Operation, error)
WaitOperation is part of google/longrunning/operations.proto.