Documentation
¶
Overview ¶
Package edge implements the relay's data-plane front: it accepts QUIC connections from agents, dispatches ORP control frames, and pairs streams across two agents in splice mode. It is the integration surface where registry resolution, policy evaluation, the stream-resume matcher (for reconnects), the candidate forwarder (for P2P promotion), and the inter-relay forwarder come together.
Index ¶
Constants ¶
const MigrationTTL = 60 * time.Second
MigrationTTL bounds how long the relay holds stream metadata after MIGRATE_TO_P2P. Within this window a fast demotion via MIGRATE_TO_RELAY can pick up where the splice left off without the agents redoing service resolution / policy evaluation.
const ResumeWindow = 30 * time.Second
ResumeWindow is the matching window for stream-resume: both halves of a resumed stream must arrive within ResumeWindow of each other. Sized to absorb asymmetric reconnect detection — one side may get an explicit ApplicationError while the other waits out an idle timeout, so the slower half can still hit the same matcher entry.
Variables ¶
var RequiredPromotionTimeout = 10 * time.Second
RequiredPromotionTimeout bounds how long a `p2p_mode=required` stream may flow through the relay before MIGRATE_TO_P2P arrives. Past the timeout the relay tears down the splice so the stream fails fast at the application — keeping the splice would silently violate the policy. Exposed as a var so integration tests can shrink it without waiting 10 s.
Functions ¶
This section is empty.
Types ¶
type AgentConn ¶
type AgentConn struct {
// contains filtered or unexported fields
}
AgentConn is the relay's view of one connected agent. It implements registry.Provider so the same pointer is used as the lookup target for service registration.
func (*AgentConn) OpenIncoming ¶
func (a *AgentConn) OpenIncoming(service, method, caller string, streamID uint64) (registry.Stream, error)
OpenIncoming opens a fresh stream toward the provider agent and writes an INCOMING_STREAM frame carrying the consumer's stream_id; the agent will reply on the same stream with STREAM_ACCEPT or STREAM_REJECT.
func (*AgentConn) WriteCtrl ¶
WriteCtrl serialises a single framed proto onto the agent's stream-0 control channel under ctrlMu. Used for any relay -> agent ctrl frame originating outside controlLoop's request/response pattern (e.g. an AllocGranted notification from handleConsumerStream once policy resolves to relay_mode=FORWARD).
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server runs the relay accept loop.
func New ¶
func New(listenAddr string, tlsConf *tls.Config, reg *registry.Registry, policyEngine *policy.Engine, cache *policy.Cache, auditEm *audit.Emitter, pool *intra.Pool, fwd *forward.Plane, obsReg *observe.Registry, logger *slog.Logger) *Server
New configures (but does not start) a relay server. policyEngine, cache, audit, pool, and obsReg may be nil for tests / single-relay setups.