edge

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

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

View Source
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.

View Source
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

View Source
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) AgentURI

func (a *AgentConn) AgentURI() string

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) String

func (a *AgentConn) String() string

func (*AgentConn) WriteCtrl

func (a *AgentConn) WriteCtrl(typ orp.FrameType, msg proto.Message) error

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.

func (*Server) Registry

func (s *Server) Registry() *registry.Registry

Registry exposes the in-memory service registry (tests use this).

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run blocks until ctx is canceled or Accept errors. Returns nil on clean shutdown.

func (*Server) RunListener

func (s *Server) RunListener(ctx context.Context, ln transport.Listener) error

RunListener uses an already-bound listener (for tests that want a random ephemeral port and need to know the address before Run).

Jump to

Keyboard shortcuts

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