Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrQueueFull = errors.New("deployment queue is full")
ErrQueueFull is returned when the deployment queue is at capacity.
Functions ¶
func ComputeHmacSHA256 ¶
ComputeHmacSHA256 returns the hex-encoded HMAC-SHA256 of body using secret. Useful for generating test signatures.
func ValidateSignature ¶
ValidateSignature verifies that the request body matches the signature provided by the Git provider. Supports:
GitHub: X-Hub-Signature-256: sha256=<hex> GitLab: X-Gitlab-Token: <plaintext token>
The signatureHeader should be the raw value of the signature header. Returns true if the signature is valid.
Types ¶
type DeployJob ¶
type DeployJob struct {
// RepoURL is the clone URL of the repository (e.g., "https://github.com/user/repo.git").
RepoURL string `json:"repo_url"`
// CommitHash is the full SHA of the commit that triggered the webhook.
CommitHash string `json:"commit_hash"`
// ReceivedAt is the time the webhook was received.
ReceivedAt time.Time `json:"received_at"`
}
DeployJob represents a deployment request extracted from a webhook payload.
func ParseWebhookPayload ¶
ParseWebhookPayload attempts to parse a webhook JSON body as a GitHub, GitLab, or generic push event. Returns a DeployJob if successful.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a bounded, channel-based deployment job queue. A single worker goroutine processes jobs sequentially, preventing concurrent Docker builds from exhausting server resources.
The queue also performs debouncing: if a job with the same commit hash is already being processed (in-flight), duplicate submissions are silently skipped.
func NewQueue ¶
NewQueue creates a deployment queue with the given capacity. capacity determines how many jobs can be buffered before Enqueue returns ErrQueueFull.
func (*Queue) Drain ¶
func (q *Queue) Drain()
Drain blocks until the queue is empty, then returns. Useful for graceful shutdown.
func (*Queue) Enqueue ¶
Enqueue submits a deployment job to the queue. Returns ErrQueueFull if the queue buffer is at capacity. Silently skips the job (returns nil) if a job with the same commit hash is already in-flight.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an HTTP server that receives Git provider webhook events, validates their HMAC signatures, rate-limits by IP, and enqueues deployment jobs.