outbound

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const HTTP = "http"

HTTP is the transport a destination uses unless it says otherwise. The name lives here, with the domain, so storage does not have to reach into the delivery loop for it.

View Source
const SignatureHeader = "X-Charon-Signature"

SignatureHeader carries the proof that a delivery came from here.

Variables

This section is empty.

Functions

func Signature

func Signature(secrets [][]byte, unix int64, body []byte) string

Signature is what SignatureHeader holds: the moment of this attempt, then one digest per secret the destination is signing with.

The timestamp is inside what is signed, so a captured delivery cannot be replayed forever. It belongs to the attempt rather than to the delivery, because a retry an hour later carrying the original moment is a delivery the receiver is right to refuse.

Rotating means both the old secret and the new one appear here at once. The receiver accepts whichever it already knows, so neither side has to change at the same instant as the other.

Types

type Answer

type Answer struct {
	Body []byte
	// Type is what the destination called it, so a reader knows whether the
	// bytes are worth showing.
	Type string
	// Truncated says the body was longer than what was kept.
	Truncated bool
}

Answer is what came back, kept for somebody reading later rather than for anything here to interpret.

type Delivery

type Delivery struct {
	ID uuid.UUID
	// Tenant is whose delivery this is. It travels with it because everything
	// done about it afterwards — recording the attempt, marking it delivered
	// or failed — is confined to that tenant, and the loop that does those
	// things handles every tenant at once.
	Tenant   uuid.UUID
	EventID  uuid.UUID
	Attempts int32
	Replays  int32
	// Which transport carries this delivery. The address in URL is written in
	// whatever form that transport reads.
	Transport string
	URL       string
	Provider  string
	Headers   map[string][]string
	Body      []byte
	// Signing names where the secrets are that this delivery is signed with,
	// never the secrets. They are read at the moment of the attempt, so a
	// rotation takes effect on the next one.
	Signing []string
}

type Result

type Result struct {
	// Accepted is the only thing that closes a delivery.
	Accepted bool
	// Status is the transport's own code when it has one, zero when it does
	// not. It is recorded for an operator to read, never interpreted here.
	Status int
	// Detail is what to show when an attempt did not succeed.
	Detail string
	// Answer is what the destination said back, bounded by whatever read it.
	// A status code is usually the whole answer and cannot be relied on to be:
	// a rejection carries a reason, and losing it leaves a number nobody can
	// act on.
	Answer Answer
	// Signed names the secrets the delivery went out signed with, never the
	// secrets. Recorded on the attempt because after a rotation the set that
	// is configured no longer says which one went out when.
	Signed []string
	// Retryable is false when the transport knows another attempt cannot
	// help, so a delivery is not retried twelve times against a rejection
	// that will never change.
	Retryable bool
}

Result is what one attempt to hand a delivery over produced. It is not an HTTP response: a transport that has no status codes reports Accepted and a Detail, and the delivery loop does not care which kind it was talking to.

type Route

type Route struct {
	Provider    string
	Destination string
	Transport   string
	URL         string
	Enabled     bool
	// Signed is how many secrets the destination signs with. Zero is a
	// destination whose receiver cannot tell a delivery from here apart from
	// anything else that reaches its address.
	Signed int
}

type Transport

type Transport interface {
	Send(ctx context.Context, delivery Delivery) Result
}

Transport hands a delivery to a destination. One implementation per kind of destination; the delivery loop owns attempts, backoff and leases, and knows nothing about how the handover happens.

Jump to

Keyboard shortcuts

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