teeth

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package teeth contains a job that will read leech and pull request event records from BigQuery and publish any available log invocations in a PR comment.

Index

Constants

This section is empty.

Variables

View Source
var PublisherSourceQuery string

PublisherSourceQuery is the source query that teeth job pipeline will use to publish results.

Functions

func SaveInvocationCommentStatus added in v0.0.16

func SaveInvocationCommentStatus(ctx context.Context, bqClient BigQueryClient, statuses []*InvocationCommentStatusRecord) error

SaveInvocationCommentStatus inserts the statuses into the InvocationCommentStatus table.

Types

type BQConfig

type BQConfig struct {
	ProjectID string
	DatasetID string

	PullRequestEventsTable       string
	InvocationCommentStatusTable string
	EventsTable                  string
	LeechStatusTable             string
}

TODO: Add query limit param.

BQConfig defines configuration parameters for the BigQuery client and the tables used by the teeth job pipeline.

type BigQuery added in v0.0.16

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

BigQuery provides a client to BigQuery API.

func NewBigQuery added in v0.0.16

func NewBigQuery(ctx context.Context, config *BQConfig) (*BigQuery, error)

NewBigQuery creates a new instance of a BigQuery client with config.

func (*BigQuery) Close added in v0.0.16

func (bq *BigQuery) Close() error

Close closes the BigQuery client.

func (*BigQuery) Insert added in v0.0.16

func (bq *BigQuery) Insert(ctx context.Context, statuses []*InvocationCommentStatusRecord) error

Insert writes statuses to the InvocationCommentStatusTable.

func (*BigQuery) QueryLatest added in v0.0.16

func (bq *BigQuery) QueryLatest(ctx context.Context) ([]*PublisherSourceRecord, error)

QueryLatest executes the source query for the latest PublisherSourceRecords to process.

type BigQueryClient

type BigQueryClient interface {
	QueryLatest(context.Context) ([]*PublisherSourceRecord, error)
	Insert(context.Context, []*InvocationCommentStatusRecord) error
}

BigQueryClient defines the spec for calls to read from and write to BigQuery tables.

type InvocationCommentStatusRecord

type InvocationCommentStatusRecord struct {
	PullRequestID  int                `bigquery:"pull_request_id"`
	PullRequestURL string             `bigquery:"pull_request_html_url"`
	ProcessedAt    time.Time          `bigquery:"processed_at"`
	CommentID      bigquery.NullInt64 `bigquery:"comment_id"`
	Status         string             `bigquery:"status"`
	JobName        string             `bigquery:"job_name"`
}

InvocationCommentStatusRecord is the output data structure that maps to the teeth pipeline's output table schema for invocation comment statuses.

type PublisherSourceRecord

type PublisherSourceRecord struct {
	DeliveryID     string    `bigquery:"delivery_id"`
	PullRequestID  int       `bigquery:"pull_request_id"`
	PullRequestURL string    `bigquery:"pull_request_html_url"`
	Received       time.Time `bigquery:"received"`
	LogsURI        string    `bigquery:"logs_uri"`
	HeadSHA        string    `bigquery:"head_sha"`
}

PublisherSourceRecord maps the columns from the source query to a struct.

func GetLatestSourceRecords added in v0.0.16

func GetLatestSourceRecords(ctx context.Context, bqClient BigQueryClient) ([]*PublisherSourceRecord, error)

GetLatestSourceRecords gets the latest publisher source records.

Jump to

Keyboard shortcuts

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