Documentation
¶
Overview ¶
Package dispatch classifies durable webhook hints and coalesces them into River refresh jobs. It never treats webhook payload data as cache truth.
Index ¶
Constants ¶
const ( ActionAny = "*" PriorityEvent = queue.QueueEvent )
const ( // MaxDebounce is C-Q2's hard event-to-cache debounce ceiling. MaxDebounce = 15 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier applies an injected rule table.
func DefaultClassifier ¶
func DefaultClassifier() Classifier
func NewClassifier ¶
func NewClassifier(rules []Rule) Classifier
func (Classifier) Classify ¶
func (c Classifier) Classify(event string, body []byte) ([]Intent, error)
Classify parses only events that have a configured rule. Unknown events are successful no-ops even when their bodies are malformed (C-I5).
func (Classifier) ClassifyContent ¶
func (c Classifier) ClassifyContent( event string, contentType string, body []byte, ) ([]Intent, error)
ClassifyContent classifies a webhook body in either GitHub-supported wire format. It is primarily exposed for conformance tests; the dispatcher reads the content type captured by ingress before calling the same path.
type Config ¶
type Config struct {
BatchSize int
MaxAttempts int
Debounce time.Duration
PollInterval time.Duration
Now func() time.Time
Classifier Classifier
Observer Observer
Tracer trace.Tracer
}
Config controls dispatcher batching, poison tolerance, and bounded debounce.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher owns the delivery → River transaction boundary (C-P2).
func New ¶
func New( pool *pgxpool.Pool, riverClient *river.Client[pgx.Tx], config Config, ) (*Dispatcher, error)
New validates config and constructs a delivery dispatcher.
func (*Dispatcher) DispatchBatch ¶
func (d *Dispatcher) DispatchBatch( ctx context.Context, ) (count int, resultErr error)
DispatchBatch claims, classifies, enqueues, and finishes one batch in one pgx transaction shared by sqlc and River.
type Intent ¶
type Intent struct {
Kind string `json:"kind"`
Key string `json:"key"`
Priority string `json:"priority"`
}
Intent is a dispatch decision, not an entity payload.
type Observer ¶
Observer is M6's C-P2/C-I5 observability seam. Implementations run only after the delivery batch and its River pointers commit.
type Rule ¶
type Rule struct {
Event string `json:"event" yaml:"event"`
Action string `json:"action" yaml:"action"`
Target Target `json:"target" yaml:"target"`
StackedTarget Target `json:"stacked_target,omitempty" yaml:"stacked_target,omitempty"`
}
Rule is the config-driven event/action → refresh mapping. StackedTarget escalates a pull request event when its payload carries the stack preview object (SYNC_ENGINE §2.1).
func DefaultRules ¶
func DefaultRules() []Rule
DefaultRules is data rather than event-specific control flow so preview webhook changes can be accommodated by changing the table.
func LoadRulesFile ¶
LoadRulesFile makes observed-payload findings a reviewed data change rather than an event-specific code branch. YAML is a superset of the shipped JSON shape, so either format is accepted.
type Target ¶
type Target string
Target names a declarative key extractor used by a Rule.
const ( TargetPullRequest Target = "pull_request" TargetStack Target = "stack" TargetChecks Target = "checks" TargetBranch Target = "branch" // TargetResolveStackMembership carries only the PR key. Its M3 worker // consults cached membership and refreshes both the old and new stacks. TargetResolveStackMembership Target = "resolve_stack_membership" )
type UnmatchedEventObserver ¶
UnmatchedEventObserver is an optional coverage-gap signal. Dispatcher also logs every committed delivery that matched zero configured rules so the signal remains visible when the batch observer does not implement this interface.