Skip to content

Commit

Permalink
refactor(bigquery/storage/managedwriter): improve readability (google…
Browse files Browse the repository at this point in the history
…apis#5239)

This PR introduces no functional changes.  It simply colocates the
two types of variadic options into the same file to aid readability.

Towards: googleapis#4366
  • Loading branch information
shollyman authored and BrennaEpp committed Dec 23, 2021
1 parent 33be882 commit 3c5ab2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
21 changes: 0 additions & 21 deletions bigquery/storage/managedwriter/appendresult.go
Expand Up @@ -20,7 +20,6 @@ import (
storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

// NoStreamOffset is a sentinel value for signalling we're not tracking
Expand Down Expand Up @@ -114,23 +113,3 @@ func (pw *pendingWrite) markDone(startOffset int64, err error, fc *flowControlle
fc.release(pw.reqSize)
}
}

// AppendOption are options that can be passed when appending data with a managed stream instance.
type AppendOption func(*pendingWrite)

// UpdateSchemaDescriptor is used to update the descriptor message schema associated
// with a given stream.
func UpdateSchemaDescriptor(schema *descriptorpb.DescriptorProto) AppendOption {
return func(pw *pendingWrite) {
pw.newSchema = schema
}
}

// WithOffset sets an explicit offset value for this append request.
func WithOffset(offset int64) AppendOption {
return func(pw *pendingWrite) {
pw.request.Offset = &wrapperspb.Int64Value{
Value: offset,
}
}
}
Expand Up @@ -17,6 +17,7 @@ package managedwriter
import (
"github.com/googleapis/gax-go/v2"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

// WriterOption are variadic options used to configure a ManagedStream instance.
Expand Down Expand Up @@ -96,3 +97,23 @@ func WithAppendRowsCallOption(o gax.CallOption) WriterOption {
ms.callOptions = append(ms.callOptions, o)
}
}

// AppendOption are options that can be passed when appending data with a managed stream instance.
type AppendOption func(*pendingWrite)

// UpdateSchemaDescriptor is used to update the descriptor message schema associated
// with a given stream.
func UpdateSchemaDescriptor(schema *descriptorpb.DescriptorProto) AppendOption {
return func(pw *pendingWrite) {
pw.newSchema = schema
}
}

// WithOffset sets an explicit offset value for this append request.
func WithOffset(offset int64) AppendOption {
return func(pw *pendingWrite) {
pw.request.Offset = &wrapperspb.Int64Value{
Value: offset,
}
}
}

0 comments on commit 3c5ab2d

Please sign in to comment.