Documentation
¶
Overview ¶
Package bqutil provides utils to interact with BigQuery.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetryQueryEntries ¶
func RetryQueryEntries[T any](ctx context.Context, q Query[T], wantCount int, backoff retry.Backoff) ([]T, error)
RetryQueryEntries retries the given Query until either the query result returns "wantCount" number of entries or the retry backoff is exhausted (and returns error). The returned result size is guaranteed to be greater or equal to "wantCount".
To collect result in custom Go struct:
type queryResult struct {
ColNameX, ColNameY string
}
q := NewQuery[*queryResult](bigqueryQuery)
backoff := retry.WithMaxRetries(3, retry.NewConstant(time.Second))
result, err := RetryQueryEntries(context.Background(), q, 1, backoff)
// result will be in type []*queryResult
To use this func in testing:
// Set the test logger in the context on the debug level. ctx := logging.WithLogger(context.Background(), logging.TestLogger(t, zaptest.Level(zapcore.DebugLevel))) q := NewQuery[*queryResult](bigqueryQuery) backoff := retry.WithMaxRetries(3, retry.NewConstant(time.Second)) result, err := RetryQueryEntries(ctx, q, 1, backoff)
Types ¶
Click to show internal directories.
Click to hide internal directories.