edge

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 9 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 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

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

func BuildEnvelope(route Route, body []byte, query url.Values) wire.Envelope

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

func StatusForError(err error) int

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

func StatusForReply(reply wire.Envelope) int

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.

func NewRouter

func NewRouter(s Spec) *Router

NewRouter builds a router from a spec. The route key is "METHOD /path", so the method is part of the match (GET and POST on the same path are distinct routes).

func (*Router) Match

func (r *Router) Match(method, path string) (Route, bool)

Match returns the route for a method+path, or false if none is configured.

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

func SpecFromEnv() (Spec, error)

SpecFromEnv reads and parses the edge Spec the lord injected via EnvSpec.

Jump to

Keyboard shortcuts

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