router

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package router decides, in code, how a message is handled (RFC 6.1, 6.6, R-ISO-3): allowlists first, then hop and thread guards, then the first matching rule. The model never takes part in these decisions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstRule

func FirstRule(a *config.Agent, e *envelope.Envelope) *config.Rule

FirstRule returns the first matching rule for the recipient.

func Match

func Match(r *config.Rule, e *envelope.Envelope) bool

Match reports whether a rule matches the envelope.

Types

type Action

type Action string

Action is the routing outcome.

const (
	Queue    Action = "queue"    // command or worker handler
	Escalate Action = "escalate" // needs_human
	Digest   Action = "digest"   // stored and counted
	Reject   Action = "reject"   // rejected with a reason
)

Actions.

type Decision

type Decision struct {
	Action  Action
	Rule    *config.Rule
	Handler string
	Profile string
	Reason  string
	// Notify asks the daemon to tell the human (escalations, guard trips).
	Notify bool
	// Freeze asks the daemon to freeze the thread.
	Freeze bool
}

Decision is what the router chose.

func Route

func Route(cfg *config.Config, e *envelope.Envelope, ts ThreadStats, ownReply bool) Decision

Route decides how e is handled. ownReply is true when e answers an ask the recipient itself sent (replies to your own asks bypass the allowlist).

type Limiter

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

Limiter is a per-sender token bucket (RFC 6.6).

func NewLimiter

func NewLimiter(perMinute int) *Limiter

NewLimiter allows perMinute messages per sender, bursting to perMinute.

func (*Limiter) Allow

func (l *Limiter) Allow(sender string) bool

Allow takes one token for sender.

func (*Limiter) SetRate

func (l *Limiter) SetRate(perMinute int)

SetRate changes the rate (config reload).

type ThreadStats

type ThreadStats struct {
	Frozen       bool
	FrozenReason string
	Messages     int // including this one
	PairRecent   int // messages between from and to in the window, including this one
}

ThreadStats are the counts the guards need, read from the store.

Jump to

Keyboard shortcuts

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