Help us shape the future of Go! Take the 2026 Go Developer Survey

dmsgdisc

package
v1.3.101 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package dmsgdisc pkg/services/dmsgdisc/config.go c2-vis-appsvc

JSON schema for dmsg-discovery as both a standalone-service config file (cmd/dmsg/dmsg-discovery -c path) AND a service block in a multi-service services.json (skywire svc run --config services.json). Both consumers parse the same struct so there's a single source of truth for the field set.

Package dmsgdisc pkg/services/dmsgdisc/dmsgdisc.go c2-vis-appsvc

dmsg-discovery as a pkg/services.Service. Both the standalone cobra command (`skywire dmsg disc`) and the multi-service supervisor (`skywire svc run`) end up calling Run(ctx, cfg, log) — the per-flag CLI path lives in cmd/dmsg/dmsg-discovery and constructs the Config from flags + optional --config file before handing off to Run.

dmsg-discovery is a "register-by-HTTP, query-by-HTTP-or-DMSG" service: dmsg-servers reach it over plain HTTP (so --mode=dmsg is rejected), but visors and operators may query it over either transport. The Run loop bootstraps an HTTP listener immediately and, when SecKey is set and the resolved Mode includes DMSG, brings up a dmsg.Client for the dmsghttp / pprof / CXO publisher surfaces.

Index

Constants

View Source
const RedisPasswordEnvName = "REDIS_PASSWORD"

RedisPasswordEnvName is the env var the redis store reads its password from. Re-exported so the cobra command's help text and the multi-service runner's docs can reference the same constant.

View Source
const Type = "dmsg-discovery"

Type is the registry key used in services.json blocks.

Variables

This section is empty.

Functions

func New

func New(cfg *Config, log *logging.Logger) services.Service

New builds a Service from an already-parsed Config. Used by the cobra command (which builds Config from flags) and by factory (which builds Config from JSON).

Types

type Config

type Config struct {
	Path string `json:"-"`

	// Common: Mode is "http" or "dual" here (dmsg-only is rejected
	// because dmsg-servers register over plain HTTP); a zero
	// EntryTimeout disables expiry (stale entries accumulate).
	services.Common

	// AuthPassphrase, when non-empty, gates official-server
	// registration with a shared secret.
	AuthPassphrase string `json:"auth_passphrase,omitempty"`
	// OfficialServers is a list of PKs treated as "official" — they
	// can register without the auth passphrase. Hex-encoded PKs.
	OfficialServers []string `json:"official_servers,omitempty"`
	// ChartsAddr serves only the charts page over plain HTTP. Empty disables it.
	ChartsAddr string `json:"charts_addr,omitempty"`
	// DmsgServerType filters dmsg-servers by their declared type.
	DmsgServerType string `json:"dmsg_server_type,omitempty"`
	// EnableLoadTesting allows sending fake load to the discovery.
	EnableLoadTesting bool `json:"enable_load_testing,omitempty"`
	// Whitelist is the network-monitor PKs allowed to deregister
	// stale entries. Hex-encoded PKs.
	Whitelist []string `json:"whitelist_keys,omitempty"`

	// DmsgServers is the static dmsg-server transit set the
	// discovery preloads at startup. Replaces the runtime read of
	// deployment.Prod.DmsgServers — operators ship a config file
	// generated from the keyring and edit it as servers rotate, no
	// rebuild required. Empty list falls back to the embedded
	// keyring at runtime as a last-resort safety net.
	DmsgServers []*disc.Entry `json:"dmsg_servers,omitempty"`
}

Config is the JSON configuration for dmsg-discovery. Mirrors the cobra-flag set on cmd/dmsg/dmsg-discovery so a config file or a services.json block can drive the same Run() with no flag-only surprises.

In services.json the block also carries `type: "dmsg-discovery"` and an optional `name`; those fields are consumed by the supervisor and are accepted-but-ignored by this struct (json "type" / "name" tags omitted — DisallowUnknownFields is OFF for the block path so the supervisor's framing fields pass through).

func LoadFile

func LoadFile(path string) (*Config, error)

LoadFile reads, parses, and returns a Config from the given path. Returns an error if the file is missing, malformed, or has fields the JSON decoder doesn't recognize (strict decoding catches typos).

Used by the standalone cobra command (`skywire dmsg disc -c path`). The multi-service supervisor goes through ParseBlock instead since it has the bytes already.

func ParseBlock

func ParseBlock(raw []byte) (*Config, error)

ParseBlock decodes a services.json block (the inline JSON object the supervisor passes through Block.Raw) into a Config. Unlike LoadFile, this path tolerates unknown fields — the supervisor's framing keys ("type", "name") arrive in the same object, and any future inline-block extension shouldn't break older binaries.

Jump to

Keyboard shortcuts

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