bq

package
v0.0.0-...-51f9457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package bq handles sending rows to BigQuery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProdClient

func NewProdClient(ctx context.Context, cloudProject string) (*prodClient, error)

NewProdClient creates new production client.

The specified cloud project should be the one, in the scope of which this code is running, e.g. "luci-change-verifier-dev".

Types

type Client

type Client interface {
	// SendRow appends a row to a BigQuery table synchronously.
	SendRow(ctx context.Context, row Row) error
}

type Fake

type Fake struct {
	// contains filtered or unexported fields
}

Fake is a fake BQ client for tests.

func (*Fake) Rows

func (f *Fake) Rows(cloudProject, dataset, table string) []proto.Message

Rows returns the stored rows for a given dataset and table.

cloudProject can be empty, implying the same cloud project as the running code.

func (*Fake) RowsCount

func (f *Fake) RowsCount(cloudProject, dataset, table string) int

RowsCount returns the number of stored rows for a given dataset and table.

cloudProject can be empty, implying the same cloud project as the running code.

func (*Fake) SendRow

func (f *Fake) SendRow(ctx context.Context, row Row) error

SendRow provides a mock SendRow implementation for tests.

func (*Fake) TotalSent

func (f *Fake) TotalSent() int

TotalSent returns total number of all rows sent across all destinations.

type Row

type Row struct {
	// CloudProject allows sending rows to other projects.
	//
	// Optional. Defaults to the one in the scope of which this process is running
	// (e.g. "luci-change-verifier-dev").
	CloudProject string
	Dataset      string
	Table        string
	// OperationID is used for de-duplication, but over just 1 minute window :(
	OperationID string
	Payload     proto.Message
}

Row encapsulates destination and actual row to send.

Exists to avoid confusion over multiple string arguments to SendRow.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL