Package longrunning
Overview ▹
Index ▹
Variables
ErrNoMetadata is the error returned by Metadata if the operation contains no metadata.
var ErrNoMetadata = errors.New("operation contains no metadata")
type Operation ¶
Operation represents the result of an API call that may not be ready yet.
type Operation struct {
// contains filtered or unexported fields
}
func InternalNewOperation ¶
func InternalNewOperation(inner *autogen.OperationsClient, proto *pb.Operation) *Operation
InternalNewOperation is for use by the google Cloud Libraries only.
InternalNewOperation returns an long-running operation, abstracting the raw pb.Operation. The conn parameter refers to a server that proto was received from.
func (*Operation) Cancel ¶
func (op *Operation) Cancel(ctx context.Context, opts ...gax.CallOption) error
Cancel starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns grpc.Code(error) == codes.Unimplemented. Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, op.Poll returns an error with code Canceled.
▹ Example
func (*Operation) Delete ¶
func (op *Operation) Delete(ctx context.Context, opts ...gax.CallOption) error
Delete deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, grpc.Code(error) == codes.Unimplemented.
▹ Example
func (*Operation) Done ¶
func (op *Operation) Done() bool
Done reports whether the long-running operation has completed.
func (*Operation) Metadata ¶
func (op *Operation) Metadata(meta proto.Message) error
Metadata unmarshals op's metadata into meta. If op does not contain any metadata, Metadata returns ErrNoMetadata and meta is unmodified.
▹ Example
func (*Operation) Name ¶
func (op *Operation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*Operation) Poll ¶
func (op *Operation) Poll(ctx context.Context, resp proto.Message, opts ...gax.CallOption) error
Poll fetches the latest state of a long-running operation.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true; if resp != nil, the response of the operation is stored in resp.
func (*Operation) Wait ¶
func (op *Operation) Wait(ctx context.Context, resp proto.Message, opts ...gax.CallOption) error
Wait blocks until the operation is completed. If resp != nil, Wait stores the response in resp.
See documentation of Poll for error-handling information.
▹ Example