vendor: update all dependencies
This commit is contained in:
+20
-15
@@ -32,6 +32,7 @@ import (
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
autogen "cloud.google.com/go/longrunning/autogen"
|
||||
pb "google.golang.org/genproto/googleapis/longrunning"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -42,17 +43,23 @@ var ErrNoMetadata = errors.New("operation contains no metadata")
|
||||
|
||||
// Operation represents the result of an API call that may not be ready yet.
|
||||
type Operation struct {
|
||||
c pb.OperationsClient
|
||||
c operationsClient
|
||||
proto *pb.Operation
|
||||
}
|
||||
|
||||
type operationsClient interface {
|
||||
GetOperation(context.Context, *pb.GetOperationRequest, ...gax.CallOption) (*pb.Operation, error)
|
||||
CancelOperation(context.Context, *pb.CancelOperationRequest, ...gax.CallOption) error
|
||||
DeleteOperation(context.Context, *pb.DeleteOperationRequest, ...gax.CallOption) error
|
||||
}
|
||||
|
||||
// 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 InternalNewOperation(conn *grpc.ClientConn, proto *pb.Operation) *Operation {
|
||||
func InternalNewOperation(inner *autogen.OperationsClient, proto *pb.Operation) *Operation {
|
||||
return &Operation{
|
||||
c: pb.NewOperationsClient(conn),
|
||||
c: inner,
|
||||
proto: proto,
|
||||
}
|
||||
}
|
||||
@@ -86,9 +93,9 @@ func (op *Operation) Metadata(meta proto.Message) error {
|
||||
// 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 (op *Operation) Poll(ctx context.Context, resp proto.Message) error {
|
||||
func (op *Operation) Poll(ctx context.Context, resp proto.Message, opts ...gax.CallOption) error {
|
||||
if !op.Done() {
|
||||
p, err := op.c.GetOperation(ctx, &pb.GetOperationRequest{Name: op.Name()})
|
||||
p, err := op.c.GetOperation(ctx, &pb.GetOperationRequest{Name: op.Name()}, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -116,20 +123,20 @@ func (op *Operation) Poll(ctx context.Context, resp proto.Message) error {
|
||||
// If resp != nil, Wait stores the response in resp.
|
||||
//
|
||||
// See documentation of Poll for error-handling information.
|
||||
func (op *Operation) Wait(ctx context.Context, resp proto.Message) error {
|
||||
func (op *Operation) Wait(ctx context.Context, resp proto.Message, opts ...gax.CallOption) error {
|
||||
bo := gax.Backoff{
|
||||
Initial: 100 * time.Millisecond,
|
||||
Max: 10 * time.Second,
|
||||
}
|
||||
return op.wait(ctx, resp, &bo, gax.Sleep)
|
||||
return op.wait(ctx, resp, &bo, gax.Sleep, opts...)
|
||||
}
|
||||
|
||||
type sleeper func(context.Context, time.Duration) error
|
||||
|
||||
// wait implements Wait, taking exponentialBackoff and sleeper arguments for testing.
|
||||
func (op *Operation) wait(ctx context.Context, resp proto.Message, bo *gax.Backoff, sl sleeper) error {
|
||||
func (op *Operation) wait(ctx context.Context, resp proto.Message, bo *gax.Backoff, sl sleeper, opts ...gax.CallOption) error {
|
||||
for {
|
||||
if err := op.Poll(ctx, resp); err != nil {
|
||||
if err := op.Poll(ctx, resp, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
if op.Done() {
|
||||
@@ -149,15 +156,13 @@ func (op *Operation) wait(ctx context.Context, resp proto.Message, bo *gax.Backo
|
||||
// operation completed despite cancellation. On successful cancellation,
|
||||
// the operation is not deleted; instead, op.Poll returns an error
|
||||
// with code Canceled.
|
||||
func (op *Operation) Cancel(ctx context.Context) error {
|
||||
_, err := op.c.CancelOperation(ctx, &pb.CancelOperationRequest{Name: op.Name()})
|
||||
return err
|
||||
func (op *Operation) Cancel(ctx context.Context, opts ...gax.CallOption) error {
|
||||
return op.c.CancelOperation(ctx, &pb.CancelOperationRequest{Name: op.Name()}, opts...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (op *Operation) Delete(ctx context.Context) error {
|
||||
_, err := op.c.DeleteOperation(ctx, &pb.DeleteOperationRequest{Name: op.Name()})
|
||||
return err
|
||||
func (op *Operation) Delete(ctx context.Context, opts ...gax.CallOption) error {
|
||||
return op.c.DeleteOperation(ctx, &pb.DeleteOperationRequest{Name: op.Name()}, opts...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user