Documentation
¶
Overview ¶
Package facade serves the engine's own submit interface, so a client publishes once through the bridge instead of to every host of a topic.
An accepted submission is forwarded to the LOCAL engine first, so the client gets that engine's real admittance instructions and the local host has admitted the object before anything else happens, and is then published once onto the object plane for every other subscribed host.
One listener ¶
There is one listener and one origin. An earlier design had a second, private listener to distinguish submissions arriving from the local engine's own propagation; the ruling that switched propagation off removed the thing it was there to hear, so there is nothing left to distinguish.
The reply keeps the host's shape ¶
Two engines answer /submit differently: one wraps the result, the other returns it bare. The facade re-emits whichever form the host used rather than normalising, so a client that worked against the host directly keeps working when it is pointed here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseTopics ¶
ParseTopics accepts the two x-topics wire forms our clients actually send.
tm_a,tm_b the comma list: the Go engine's generated binder form, and
the TypeScript host's non-bracket branch
["tm_a","tm_b"] the JSON array: the SDK facilitator's form, and the
TypeScript host's bracket branch
Accepting both is what makes the facade a drop-in for a client written against either host, which is the whole point of serving the engine's own interface rather than a new one.
Two deliberate differences from the Go engine's binder, which this replaces rather than imitates:
- Values are trimmed. That binder splits on commas without trimming, so a single leading space turns a valid topic into an unknown one and fails the whole submit.
- A repeated header is an error. That binder reads only the first value and silently discards the rest, which loses topics without saying so.
Types ¶
type Config ¶
type Config struct {
// Engine is the local engine client.
Engine feed.DetailSubmitter
// Publish puts records on the plane. Nil disables publishing, which makes
// the facade a plain pass-through to the local engine.
Publish Publisher
// Guard is the loop guard, shared with the feed.
Guard *guard.Guard
// Topics is the set of names this bridge may publish. The bridge holds the
// only name map, so a topic it cannot name it cannot publish.
Topics map[string]struct{}
// MaxObject bounds a submitted object. Zero takes the codec default.
MaxObject int
Log *slog.Logger
// Routes send the topics each pattern names to an engine of their own,
// as the feed's routes do; every other topic goes to Engine.
Routes []*feed.Route
// Shadow is the default shadow (the feed's), offered a submission only
// when ShadowFacade is set; a routed topic's shadow is its route's.
Shadow *feed.Shadow
// ShadowFacade offers each accepted submission to the topic's shadow
// once the local engine has answered, with that answer to compare
// against, so a host that publishes through its own facade counts
// parity on what it publishes and not only on what the lane delivers.
// A submission the engine failed is not offered: there is no answer to
// compare, and the client's retry brings the object again.
ShadowFacade bool
// Trusted names the sources whose submissions on some topics are
// published without the local route: no engine, no shadow, no other
// local target, and no local check. A storage node's gateway hands its
// own provider every piece in process, so the facade's route to that
// provider would only check again what the gateway minted. Empty, every
// submission is routed and checked; the operator lists only its own
// addresses.
Trusted []TrustRule
}
Config configures a Facade.
type Facade ¶
type Facade struct {
// contains filtered or unexported fields
}
Facade is the submit server.
type Publisher ¶
Publisher puts one BRC-149 submission record on the plane. The facade calls it from inside a client's synchronous request, so it may hold the caller only for a bounded wait for room in its own queue (overload then shows as request latency rather than a refusal) and never for the plane itself.
sent runs once the record has ACTUALLY reached the plane and never if it has not. Acceptance is not publication: an asynchronous send can still fail after the client has been answered.
type Stats ¶
type Stats struct {
OK, Malformed, UnknownTopic, LoopDropped, EngineError, PublishFailed uint64
// Trusted counts topics published unrouted for a trusted source.
Trusted uint64
}
Stats is a point-in-time snapshot.
type TrustRule ¶ added in v0.14.0
TrustRule is one -facade-trusted value: the topics Pattern names (a glob, as a route's) from a source in Nets are published unrouted.
func ParseTrust ¶ added in v0.14.0
ParseTrust parses one -facade-trusted value: GLOB=CIDR[,CIDR]...