handler

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: BSD-2-Clause Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package handler contains the HTTP handlers for the github-build watcher. /trigger publishes a TriggerBuildCheckCommand to Kafka and returns 202; the heavy lifting (Poll cycle) happens in the in-pod command consumer.

Index

Constants

This section is empty.

Variables

AvailableWebhookHeaders lists the webhook header names the handler reads.

Functions

This section is empty.

Types

type TriggerBuildCheckHandler

type TriggerBuildCheckHandler = libhttp.WithError

TriggerBuildCheckHandler handles POST /trigger. The handler is intentionally minimal: parse the optional ?force=<bool> query parameter via libparse.ParseBoolDefault (spec 069), build a TriggerBuildCheckCommand carrying the parsed Force value, publish it to Kafka via the injected sender, and return HTTP 202. The Scope field stays reserved-unread (spec Non-goal: per-repo filter UX is a separate spec). All scan-cycle work is owned by the in-pod command consumer.

func NewTriggerBuildCheckHandler

func NewTriggerBuildCheckHandler(
	sender command.TriggerBuildCheckCommandSender,
) TriggerBuildCheckHandler

NewTriggerBuildCheckHandler returns a handler that publishes a TriggerBuildCheckCommand to Kafka for each /trigger request and returns 202. The sender is the only collaborator.

type WebhookHandler added in v0.4.0

type WebhookHandler = libhttp.WithError

WebhookHandler handles POST /webhook/github-build. The handler is intentionally thin, mirroring TriggerBuildCheckHandler: verify the GitHub HMAC signature, extract the repo from the workflow_run event, publish a TriggerBuildCheckCommand to Kafka, and return 202. All GitHub API access, filter evaluation, and state-machine logic stays in the in-pod command consumer (shared with /trigger), so the allowlist gate and the green/red state transitions apply to webhook deliveries unchanged.

func NewWebhookHandler added in v0.4.0

func NewWebhookHandler(
	sender command.TriggerBuildCheckCommandSender,
	secret string,
	metrics WebhookMetrics,
	clock libtime.CurrentDateTimeGetter,
	debouncer pkg.Debouncer,
) WebhookHandler

NewWebhookHandler returns a handler that publishes a TriggerBuildCheckCommand for each signature-verified workflow_run webhook delivery that (a) completed with conclusion=failure, (b) ran on the repository's default branch, and (c) passes the per-repo debounce. All other deliveries are acked and skipped.

type WebhookHeader added in v0.4.0

type WebhookHeader string

WebhookHeader is a typed GitHub webhook header name, so header-name typos are caught by the type system.

const (
	WebhookSignatureHeader WebhookHeader = "X-Hub-Signature-256"
	WebhookEventHeader     WebhookHeader = "X-GitHub-Event"
)

type WebhookMetrics added in v0.4.0

type WebhookMetrics interface {
	IncWebhookDelivery(result string)
	IncWebhookSignatureRejected()
	ObserveWebhookDispatchLatency(seconds float64)
	// IncWebhookSkipped counts workflow_run deliveries that did not dispatch a
	// build-check. reason: "not_completed" | "not_failure" | "not_default_branch" | "debounced".
	IncWebhookSkipped(reason string)
}

WebhookMetrics is the narrow slice of watcher metrics the webhook handler records. pkg.Metrics satisfies it structurally, keeping this handler free of the pkg import — mirroring trigger_handler's thin dependency set.

Jump to

Keyboard shortcuts

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