statuszmock

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package statuszmock provides a minimal mock of a Block Node's statusz REST endpoints for daemon development and tests. It serves the two endpoints the traffic-shaper monitor polls — `statusz/inbound-clients` and `statusz/outbound-clients` — from an editable roster, so a developer can point the daemon's local-fallback statusz source at it and watch the nft set membership follow roster edits.

The wire contract mirrors block-node/api/network-data.proto (a `NetworkData` with `active_endpoints`). It is defined independently here so the mock stays decoupled from the daemon's decode types and can serve the contract on its own. The contract is PROVISIONAL — confirming it with the BN team is a blocking dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(provider RosterProvider) http.Handler

Handler returns an http.Handler serving the two statusz endpoints from the given provider. Paths are matched with and without a leading `statusz/` prefix so it works whether mounted at the root or behind a `statusz/` mount.

Types

type Connection

type Connection struct {
	Local       Endpoint `json:"local"`
	Remote      Endpoint `json:"remote"`
	Category    string   `json:"category"`
	TLSRequired bool     `json:"tls_required"`
}

Connection is one active endpoint the BN reports.

type Endpoint

type Endpoint struct {
	Address string `json:"address"`
	Port    string `json:"port"`
}

Endpoint is one side (local or remote) of a Connection. Port is a string because the BN reports "*" (any) alongside numeric ports.

type Roster

type Roster struct {
	Inbound  []Connection `json:"inbound"`
	Outbound []Connection `json:"outbound"`
}

Roster is the mock's full view: the endpoints served by each statusz endpoint.

type RosterProvider

type RosterProvider func() (Roster, error)

RosterProvider returns the roster to serve for a given request. A static provider returns a fixed roster; a file provider re-reads a JSON file so edits are picked up live between polls.

func FileRoster

func FileRoster(path string) RosterProvider

FileRoster returns a provider that reads and decodes the JSON roster at path on every call, so external edits take effect on the next poll without a restart. A missing file yields an empty roster (the BN "has no clients yet" bootstrap state) rather than an error.

func StaticRoster

func StaticRoster(r Roster) RosterProvider

StaticRoster returns a provider that always serves r.

Directories

Path Synopsis
Command statuszmock runs the mock Block Node statusz REST server for daemon development and the UTM-VM traffic-shaper demo.
Command statuszmock runs the mock Block Node statusz REST server for daemon development and the UTM-VM traffic-shaper demo.

Jump to

Keyboard shortcuts

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