Skip to content

Commit

Permalink
docs(bigquery/storage/managedwriter): augment context usage in packag…
Browse files Browse the repository at this point in the history
…e docs (#8334)

This PR augments existing information about how this package uses
context.  Out of band feedback from users related to PR 8275 indicates
more documentation is warranted about the use and retention of
context throughout the package.
  • Loading branch information
shollyman authored Aug 4, 2023
1 parent 63b3fb7 commit b30a7f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bigquery/storage/managedwriter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type Client struct {
}

// NewClient instantiates a new client.
//
// The context provided here is retained and used for background connection management
// between the client and the BigQuery Storage service.
func NewClient(ctx context.Context, projectID string, opts ...option.ClientOption) (c *Client, err error) {
// Set a reasonable default for the gRPC connection pool size.
numConns := runtime.GOMAXPROCS(0)
Expand Down
13 changes: 13 additions & 0 deletions bigquery/storage/managedwriter/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ In support of the retry changes, the AppendResult returned as part of an append
TotalAttempts(), which returns the number of times that specific append was enqueued to the service.
Values larger than 1 are indicative of a specific append being enqueued multiple times.
# Usage of Contexts
The underlying rpc mechanism used to transmit requests and responses between this client and
the service uses a gRPC bidirectional streaming protocol, and the context provided when invoking
NewClient to instantiate the client is used to maintain those background connections.
This package also exposes context when instantiating a new writer (NewManagedStream), as well as
allowing a per-request context when invoking the AppendRows function to send a set of rows. If the
context becomes invalid on the writer all subsequent AppendRows requests will be blocked.
Finally, there is a per-request context supplied as part of the AppendRows call on the ManagedStream
writer itself, useful for bounding individual requests.
# Connection Sharing (Multiplexing)
Note: This feature is EXPERIMENTAL and subject to change.
Expand Down

0 comments on commit b30a7f4

Please sign in to comment.