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

api

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: 18 Imported by: 0

Documentation

Overview

Package api pkg/deployment/conf/api/api.go c4-net-discovery

Package api pkg/deployment/conf/api/cxo_publisher.go c4-net-discovery

CXO publisher for the deployment's services config: the same document GET / serves, gzipped JSON at deployment.ServicesCXOPath on DmsgConfCXOPort. The feed is signed by the conf service's own key, so a visor checks the config against that key rather than trusting whichever stream carried it, and the feed's sequence keeps an older config from being replayed.

Visors hold one subscription to this feed (see pkg/visor/conf_cxo.go). The document changes rarely; the publisher's heartbeat keeps the connection warm in between, so a changed key reaches every subscribed visor within one publish interval and without a release.

The feed is open: it carries exactly what GET / already serves to anyone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	http.Handler
	// contains filtered or unexported fields
}

API represents the api of the stun-list service.

func New

func New(log *logging.Logger, conf Config, domain, dmsgAddr string) *API

New creates a new api. By default, serves the embedded deployment config (deployment.Prod). The domain parameter applies HTTP URL replacements for custom deployments; DMSG addresses are PK-based and don't change.

func (*API) Close

func (a *API) Close()

Close stops API.

func (*API) Services added in v1.3.99

func (a *API) Services() deployment.Services

Services returns a snapshot of the services config this API serves at GET /. It is taken under the lock so a caller encoding it doesn't see a torn state if refreshDmsgServers swaps the slice mid-encode.

type Config

type Config struct {
	StunServers       []string        `json:"stun_servers"`
	SetupNodes        []cipher.PubKey `json:"route_setup_nodes"`
	SurveyWhitelist   []cipher.PubKey `json:"survey_whitelist"`
	TransportSetupPKs []cipher.PubKey `json:"transport_setup"`
}

Config contains the list of stun servers and setup-nodes

type Error

type Error struct {
	Error string `json:"error"`
}

Error is the object returned to the client when there's an error.

type HealthCheckResponse

type HealthCheckResponse struct {
	ServiceName string          `json:"service_name,omitempty"`
	BuildInfo   *buildinfo.Info `json:"build_info,omitempty"`
	StartedAt   time.Time       `json:"started_at"`
	DmsgAddr    string          `json:"dmsg_address,omitempty"`
}

HealthCheckResponse is struct of /health endpoint

type ServicesCXOPublisher added in v1.3.99

type ServicesCXOPublisher struct {
	// contains filtered or unexported fields
}

ServicesCXOPublisher publishes the API's services config as a CXO feed.

func StartServicesCXOPublisher added in v1.3.99

func StartServicesCXOPublisher(ctx context.Context, api *API, dmsgC *dmsg.Client, sk cipher.SecKey, logger logrus.FieldLogger) (*ServicesCXOPublisher, error)

StartServicesCXOPublisher starts publishing api's services config over dmsgC, as a feed signed by sk, until ctx ends or Close is called.

func (*ServicesCXOPublisher) Close added in v1.3.99

func (s *ServicesCXOPublisher) Close() error

Close stops the publish loop and releases the publisher.

func (*ServicesCXOPublisher) FeedPK added in v1.3.99

func (s *ServicesCXOPublisher) FeedPK() cipher.PubKey

FeedPK returns the publisher's feed PK (the conf service's PK).

Jump to

Keyboard shortcuts

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