Skip to content

Commit

Permalink
refactor(bigquery/storage/managedwriter): improve readability (#5239)
Browse files Browse the repository at this point in the history
This PR introduces no functional changes.  It simply colocates the
two types of variadic options into the same file to aid readability.

Towards: #4366
  • Loading branch information
shollyman committed Dec 21, 2021
1 parent 5444809 commit c6c8522
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 c6c8522

Please sign in to comment.