Documentation
¶
Overview ¶
Package clients encapsulates all clients and associated helper methods to interact with other services.
Package webhook is the base webhook server for the github metrics ingestion.
Index ¶
- Constants
- type BigQuery
- func (bq *BigQuery) Close() error
- func (bq *BigQuery) DeliveryEventExists(ctx context.Context, eventsTableID, deliveryID string) (bool, error)
- func (bq *BigQuery) FailureEventsExceedsRetryLimit(ctx context.Context, failureEventTableID, deliveryID string, retryLimit int) (bool, error)
- func (bq *BigQuery) WriteFailureEvent(ctx context.Context, failureEventTableID, deliveryID, createdAt string) error
- type Config
- type Datastore
- type FailureEventEntry
- type MockDatastore
- func (m *MockDatastore) Close() error
- func (m *MockDatastore) DeliveryEventExists(ctx context.Context, eventsTableID, deliveryID string) (bool, error)
- func (m *MockDatastore) FailureEventsExceedsRetryLimit(ctx context.Context, failureEventTableID, deliveryID string, retryLimit int) (bool, error)
- func (m *MockDatastore) WriteFailureEvent(ctx context.Context, failureEventTableID, deliveryID, createdAt string) error
- type PubSubClientConfig
- type PubSubMessenger
- type Server
- type WebhookClientOptions
Constants ¶
const ( // SHA256SignatureHeader is the GitHub header key used to pass the HMAC-SHA256 hexdigest. SHA256SignatureHeader = "X-Hub-Signature-256" // EventTypeHeader is the GitHub header key used to pass the event type. EventTypeHeader = "X-Github-Event" // DeliveryIDHeader is the GitHub header key used to pass the unique ID for the webhook event. DeliveryIDHeader = "X-Github-Delivery" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BigQuery ¶
type BigQuery struct {
// contains filtered or unexported fields
}
BigQuery provides a client and dataset identifiers.
func NewBigQuery ¶
func NewBigQuery(ctx context.Context, projectID, datasetID string, opts ...option.ClientOption) (*BigQuery, error)
NewBigQuery creates a new instance of a BigQuery client.
func (*BigQuery) DeliveryEventExists ¶
func (bq *BigQuery) DeliveryEventExists(ctx context.Context, eventsTableID, deliveryID string) (bool, error)
Check if an entry with a given delivery_id already exists in the events table, this attempts to prevent duplicate processing of events. This is used by the webhook service.
func (*BigQuery) FailureEventsExceedsRetryLimit ¶
func (bq *BigQuery) FailureEventsExceedsRetryLimit(ctx context.Context, failureEventTableID, deliveryID string, retryLimit int) (bool, error)
Check if the number of entries with a given delivery_id in the failure-events table exceeds the retry limit. This is used by the webhook service.
type Config ¶
type Config struct {
BigQueryProjectID string `env:"BIG_QUERY_PROJECT_ID,default=$PROJECT_ID"`
DatasetID string `env:"DATASET_ID,required"`
EventsTableID string `env:"EVENTS_TABLE_ID,required"`
FailureEventsTableID string `env:"FAILURE_EVENTS_TABLE_ID,required"`
Port string `env:"PORT,default=8080"`
ProjectID string `env:"PROJECT_ID,required"`
RetryLimit int `env:"RETRY_LIMIT,required"`
EventsTopicID string `env:"EVENTS_TOPIC_ID,required"`
DLQEventsTopicID string `env:"DLQ_EVENTS_TOPIC_ID,required"`
GitHubWebhookSecret string `env:"GITHUB_WEBHOOK_SECRET,required"`
}
Config defines the set over environment variables required for running this application.
func (*Config) ToFlags ¶
ToFlags binds the config to the give cli.FlagSet and returns it.
type Datastore ¶
type Datastore interface {
DeliveryEventExists(ctx context.Context, eventsTableID, deliveryID string) (bool, error)
FailureEventsExceedsRetryLimit(ctx context.Context, failureEventTableID, deliveryID string, retryLimit int) (bool, error)
WriteFailureEvent(ctx context.Context, failureEventTableID, deliveryID, createdAt string) error
Close() error
}
Datastore adheres to the interaction the webhook service has with a datastore.
type FailureEventEntry ¶
type FailureEventEntry struct {
// contains filtered or unexported fields
}
FailureEventEntry is the shape of an entry to the failure_events table.
type MockDatastore ¶
type MockDatastore struct {
// contains filtered or unexported fields
}
func (*MockDatastore) Close ¶
func (m *MockDatastore) Close() error
func (*MockDatastore) DeliveryEventExists ¶
func (*MockDatastore) FailureEventsExceedsRetryLimit ¶
func (*MockDatastore) WriteFailureEvent ¶
func (m *MockDatastore) WriteFailureEvent(ctx context.Context, failureEventTableID, deliveryID, createdAt string) error
type PubSubClientConfig ¶
type PubSubClientConfig struct {
PubSubURL string
PubSubGRPCConn *grpc.ClientConn
}
PubSubClientConfig are the pubsub client config options.
type PubSubMessenger ¶
type PubSubMessenger struct {
// contains filtered or unexported fields
}
PubSubMessenger implements the Messenger interface for Google Cloud pubsub.
func NewPubSubMessenger ¶
func NewPubSubMessenger(ctx context.Context, projectID, topicID string, opts ...option.ClientOption) (*PubSubMessenger, error)
NewPubSubMessenger creates a new instance of the PubSubMessenger.
func (*PubSubMessenger) Close ¶
func (p *PubSubMessenger) Close() error
Close handles the graceful shutdown of the pubsub client.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides the server implementation.
func NewServer ¶
func NewServer(ctx context.Context, h *renderer.Renderer, cfg *Config, wco *WebhookClientOptions) (*Server, error)
NewServer creates a new HTTP server implementation that will handle receiving webhook payloads.
type WebhookClientOptions ¶
type WebhookClientOptions struct {
EventPubsubClientOpts []option.ClientOption
DLQEventPubsubClientOpts []option.ClientOption
BigQueryClientOpts []option.ClientOption
DatastoreClientOverride Datastore // used for unit testing
}
WebhookClientOptions encapsulate client config options as well as dependency implementation overrides.