Documentation
¶
Overview ¶
Package httpapi is the host's HTTP surface, path for path and shape for shape with the TypeScript host it replaces (overlay-blueprints src/http.ts):
POST /submit BRC-22: body = BEEF bytes, header x-topics (and the bridge's
SPV marker, internal/bridgetrust); answers the BARE STEAK map
POST /lookup BRC-24: {service, query}; answers {type, outputs:[{beef:[bytes], outputIndex}]}
GET /listTopicManagers
the topic managers this host carries, name to metadata, as
overlay-express answers it; with an ETag (a matching
If-None-Match answers 304). overlay-bridge -topics-from
engine follows it.
GET /healthz liveness
GET /readyz storage and the chain tracker both answer
GET /metrics Prometheus
POST /admin/reload read the topic settings again (host Reloader)
POST /admin/checkpoint store backup: the index, the modules' state, the blobs
POST /admin/gc store gc (blobs and metas no row refers to)
POST /admin/prune the anytx retention, now
GET /admin/stats the store's counts
(the /admin routes answer loopback callers only; docs/storage.md)
POST /requestSyncResponse, POST /requestForeignGASPNode
the GASP peer routes (internal/catchup), to the configured peers
All are mounted at the ROOT, as the released Express server does. The TypeScript host's other /admin routes are not served.
Index ¶
Constants ¶
const ( MaxBody = 64 << 20 MaxQuestion = 64 << 10 )
MaxBody matches the bridge's object ceiling; MaxQuestion is generous for a BRC-24 question and three orders of magnitude below it.
Variables ¶
This section is empty.
Functions ¶
func ParseTopics ¶
ParseTopics reads x-topics in both wire forms: a JSON array (the SDK's facilitator) or a comma list (the generated server's binder). Values are trimmed; a repeated header, an empty entry or no topic at all is an error rather than a silently shorter list. (Upstream's Go server comma-splits UNTRIMMED and reads only the first value; this host does not inherit that.)
Types ¶
type BridgeVerifiedSubmitter ¶ added in v0.10.0
type BridgeVerifiedSubmitter interface {
SubmitBridgeVerified(ctx context.Context, raw []byte, topics []string) (overlay.Steak, error)
}
BridgeVerifiedSubmitter is a Submitter that can take an object whose overlay-bridge marker was accepted, verifying everything but its scripts (the pipeline's SubmitBridgeVerified). A Submitter without it verifies every object in full.
type Deps ¶
type Deps struct {
Submit Submitter
Lookup Looker
Topics []string
Ready func() bool
Metrics *metrics.Metrics
Log *slog.Logger
// Checkpoint writes a checkpoint named name (with the blob snapshot when
// blobs) and answers what it wrote, its directory as "dir". Nil leaves
// POST /admin/checkpoint unserved. The /admin routes answer loopback
// callers only: the backup timer and the operator on the host, never a
// remote client.
Checkpoint func(ctx context.Context, name string, blobs bool) (any, error)
// GC runs store gc; ok false is a maintenance pass running (409). Nil
// leaves POST /admin/gc unserved.
GC func(ctx context.Context, dryRun, rowless bool) (res any, ok bool, err error)
// Prune runs the anytx retention now, keeping keep when it is above
// zero instead of the configured hours; ok false as GC's. Nil leaves
// POST /admin/prune unserved.
Prune func(ctx context.Context, dryRun bool, keep time.Duration) (res any, ok bool, err error)
// Stats counts the store (files: the blob files too). Nil leaves GET
// /admin/stats unserved.
Stats func(ctx context.Context, files bool) (any, error)
// GASP mounts the GASP peer routes (internal/catchup Server); nil leaves
// them unserved.
GASP interface{ Register(mux *http.ServeMux) }
// Reload reads the host's topic settings again and rebuilds the host on
// them (host Reloader); nil leaves POST /admin/reload unserved.
Reload func(ctx context.Context) (any, error)
// Dynamic serves the topics local applications ask for (host Reloader);
// nil leaves /admin/topics unserved.
Dynamic TopicsAdmin
// TopicManagers lists the carried topic managers (the engine's
// ListTopicManagers); nil leaves GET /listTopicManagers unserved.
TopicManagers func() map[string]*overlay.MetaData
// Trust judges overlay-bridge's SPV marker on POST /submit; nil is
// trust off (a marker counts as disabled and the object is verified in
// full).
Trust *bridgetrust.Trust
}
Deps is what the server needs.
type Looker ¶
type Looker interface {
Lookup(ctx context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)
}
Looker is the engine's lookup.
type Submitter ¶
type Submitter interface {
Submit(ctx context.Context, raw []byte, topics []string) (overlay.Steak, error)
}
Submitter is the pipeline, as the server sees it.
type TopicsAdmin ¶ added in v0.19.0
type TopicsAdmin interface {
List() any
Put(ctx context.Context, ask TopicsAsk) (any, error)
Delete(ctx context.Context, id string) (any, error)
}
TopicsAdmin is what /admin/topics calls.
type TopicsAsk ¶ added in v0.19.0
type TopicsAsk struct {
ID string `json:"id"`
Settings map[string][]string `json:"settings"`
// TTLSeconds is the ask's lifetime, required (1 s up to the host's
// OVERLAY_TOPICS_DYNAMIC_MAX_TTL_SECONDS), refreshed by asking again.
TTLSeconds int `json:"ttl_seconds"`
}
TopicsAsk is a local application's ask for topics while it uses them.