papdashboard

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package papdashboard forwards taskqueue facts to a PapDashboard instance: a dead-lettered task becomes an alert (alert.triggered), and if the task later completes (e.g. after tq dlq --rescue), that alert is resolved (alert.resolved). The bridge consumes the same journal seam as tq tail, so it works against any Store and never mutates queue state.

Delivery semantics: at-least-once within a bridge process lifetime — the journal watermark only advances after PapDashboard accepts a fact, and the Idempotency-Key header (derived from the fact sequence) makes retries safe. Across restarts the bridge starts at the journal head: incidents that fired while the bridge was down are not replayed (review them with tq dlq); a completion that would resolve a pre-restart alert is not seen, so those alerts stay open for a human.

Index

Constants

View Source
const DefaultPollInterval = 5 * time.Second

DefaultPollInterval is how often the journal is tailed.

View Source
const SourceApp = "go-taskqueue"

SourceApp is the default sourceApp stamped on ingested alerts.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge tails the taskqueue journal and mirrors dead-letter incidents into PapDashboard alerts.

func New

func New(store FactSource, cfg Config) *Bridge

New builds a Bridge. Call Run to start tailing.

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context) error

Run tails the journal until ctx is cancelled. Facts are forwarded in Seq order; the watermark advances past a fact only when it is accepted (2xx) or permanently rejected (4xx) — transient failures retry on the next poll.

type Config

type Config struct {
	// Endpoint is PapDashboard's base URL, e.g. http://localhost:8080.
	Endpoint string
	// APIKey is the Bearer token protecting PapDashboard's ingest route.
	APIKey string
	// SourceApp overrides the default sourceApp ("go-taskqueue").
	SourceApp string
	// Severity is the alert severity for dead-lettered tasks.
	// Default "critical".
	Severity string
	// PollInterval tails the journal this often. Default 5s.
	PollInterval time.Duration
	// FromSeq, when set, starts forwarding AFTER this fact sequence instead
	// of the journal head (replay mode).
	FromSeq *int64
	// Client overrides the HTTP client.
	Client *http.Client
	// Logger receives bridge diagnostics. Default slog.Default().
	Logger *slog.Logger
}

Config controls a Bridge. Endpoint and APIKey come from the PapDashboard deployment (its public /api/ingest route and the PAP_API_KEY value).

type FactSource

type FactSource interface {
	Facts(ctx context.Context, after int64) ([]journal.Fact, error)
	Get(ctx context.Context, id task.ID) (task.Task, error)
}

FactSource is the slice of queue.Store the bridge needs.

Jump to

Keyboard shortcuts

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