Documentation
¶
Overview ¶
Package edge holds the translation logic of the built-in HTTP ingress: matching an incoming request to a configured route, building the ether call/cast envelope, and mapping the outcome back to an HTTP status. It depends only on the wire contract, not on the manifest or the lord, so it stays a small, pure, unit-testable core; the HTTP server and NATS I/O live in the `aether _edge` subcommand that drives it.
Index ¶
Constants ¶
const EnvSpec = "AETHER_EDGE_SPEC"
EnvSpec is the environment variable through which the lord hands an edge process its Spec as JSON.
Variables ¶
This section is empty.
Functions ¶
func BuildEnvelope ¶
BuildEnvelope assembles the call/cast envelope for a matched route. The payload is the request body; if the body is empty, the query parameters are used instead (as a JSON object of string values), falling back to "{}". A fresh Trace is minted per request so the logical operation can be followed across hops.
func StatusForError ¶
StatusForError maps a transport-level failure of a call to an HTTP status: no responders (the target thrall is not running or not subscribed) becomes 503, a timeout becomes 504, and any other transport error becomes 502.
func StatusForReply ¶
StatusForReply maps a completed call's reply to an HTTP status: an application-level error reply from the thrall becomes 502 (the upstream thrall failed), a successful reply becomes 200.
Types ¶
type Route ¶
type Route struct {
Thrall string `json:"thrall"`
Op string `json:"op"`
Kind string `json:"kind"` // call (wait for reply) | cast (fire-and-forget)
// SchemaJSON is the inlined JSON Schema content (empty = no schema validation). The lord reads
// and compile-checks the file at manifest load and inlines it here, so the edge process does
// not depend on a filesystem path or its working directory.
SchemaJSON string `json:"schemaJson,omitempty"`
}
Route is a single HTTP route's target on the ether.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router resolves an incoming request's method and path to a configured route.
type Spec ¶
type Spec struct {
Name string `json:"name"`
Addr string `json:"addr"`
Routes map[string]Route `json:"routes"` // key: "METHOD /path"
}
Spec is the runtime configuration of one HTTP edge server. The lord transports it to the spawned `aether _edge` process as JSON (env AETHER_EDGE_SPEC); it mirrors the manifest's [[edge.http]] section but is decoupled from TOML parsing.
func SpecFromEnv ¶
SpecFromEnv reads and parses the edge Spec the lord injected via EnvSpec.