core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package core holds the domain types shared across the gateway modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackoffConfig

type BackoffConfig struct {
	BaseDelay   time.Duration `json:"base_delay"`
	Multiplier  float64       `json:"multiplier"`
	MaxDelay    time.Duration `json:"max_delay"`
	MaxAttempts int           `json:"max_attempts"`
}

BackoffConfig controls retry timing.

type DeliveryAttempt

type DeliveryAttempt struct {
	ID              string
	EventID         string
	DestinationID   string
	AttemptNumber   int
	StatusCode      int // 0 when no response was received
	ResponseSnippet string
	DurationMS      int64
	Outcome         Outcome
	IsReplay        bool
	AttemptedAt     time.Time
}

DeliveryAttempt records the result of one delivery try.

type DeliveryState

type DeliveryState string

DeliveryState is the pending-or-terminal state of an (event, destination) delivery in the queue.

const (
	StatePending    DeliveryState = "pending"
	StateDelivered  DeliveryState = "delivered"
	StateDeadLetter DeliveryState = "dead_letter"
)

type Destination

type Destination struct {
	ID         string
	Source     string
	URL        string
	Enabled    bool
	FilterSpec *FilterSpec    // nil matches everything
	Backoff    *BackoffConfig // nil uses the gateway default
	CreatedAt  time.Time
}

Destination is a target the gateway forwards matching events to.

type Event

type Event struct {
	ID         string
	Source     string
	ReceivedAt time.Time
	SourceIP   string
	Method     string
	Path       string
	Query      string
	Headers    map[string][]string
	Body       []byte
	DedupKey   string // empty when the provider supplied none
	Status     EventStatus
}

Event is a captured inbound request.

type EventStatus

type EventStatus string

EventStatus is the capture status of an inbound request.

const (
	StatusReceived EventStatus = "received"
	StatusRejected EventStatus = "rejected"
)

type FilterSpec

type FilterSpec struct {
	BodyEquals   map[string]string   `json:"body_equals,omitempty"`
	HeaderEquals map[string]string   `json:"header_equals,omitempty"`
	BodyExists   []string            `json:"body_exists,omitempty"` // path must be present
	BodyIn       map[string][]string `json:"body_in,omitempty"`     // value must be in the list
	BodyPrefix   map[string]string   `json:"body_prefix,omitempty"` // value must start with the prefix
	BodyNot      map[string]string   `json:"body_not,omitempty"`    // value must not equal
}

FilterSpec is a destination's routing filter. All clauses must match (AND); an empty spec matches every event. Body clauses address a JSON field by a dot-separated path (e.g. "data.object.status").

type Outcome

type Outcome string

Outcome classifies a single delivery attempt.

const (
	OutcomeSuccess   Outcome = "success"
	OutcomeRetryable Outcome = "retryable"
	OutcomePermanent Outcome = "permanent"
)

type PendingDelivery

type PendingDelivery struct {
	ID            string
	EventID       string
	DestinationID string
	AttemptNumber int
	NextAttemptAt time.Time
	State         DeliveryState
	IsReplay      bool
}

PendingDelivery is a queued delivery for an (event, destination) pair.

type Source

type Source struct {
	ID          string
	Name        string
	Verifier    string // empty means no signature verification
	HasSecret   bool
	DedupHeader string
	CreatedAt   time.Time
}

Source is a registered inbound integration. Webhooks POST to /ingest/{name}.

Jump to

Keyboard shortcuts

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