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

appdisc

package
v1.3.100 Latest Latest
Warning

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

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

Documentation

Overview

Package appdisc pkg/app/appdisc/discovery_manager.go c2-vis-appsvc

Package appdisc pkg/app/appdisc/discovery_manager_native.go c2-vis-appsvc

The service-discovery-backed updaters. servicedisc.HTTPClient pulls net/http, which does not compile on the TinyGo js/wasm target, so the serviceUpdater and PublicVisorUpdater live here (native-only). The Updater interface and the no-op emptyUpdater stay in discovery_manager.go; on TinyGo the Factory hands out emptyUpdater (a browser visor does not register in service discovery).

Package appdisc pkg/app/appdisc/egress_native.go c2-vis-appsvc

Package appdisc pkg/app/appdisc/factory.go c2-vis-appsvc

Package appdisc pkg/app/appdisc/factory_native.go c2-vis-appsvc

The Factory's updater constructors. They build servicedisc.HTTPClient instances (net/http), so they are native-only; factory_tinygo.go provides the TinyGo stubs that return emptyUpdater. Factory.Client is an *http.Client recovered from the `any`-typed field here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	Log               logrus.FieldLogger
	MLog              *logging.MasterLogger
	PK                cipher.PubKey
	SK                cipher.SecKey
	ServiceDisc       string // Address of service-discovery
	DisplayNodeIP     bool
	Client            any // *http.Client on native builds
	ClientPublicIP    string
	HeartbeatInterval time.Duration // Interval for service discovery heartbeats
	Geo               any           // *geo.LocationData on native builds; visor geolocation in service entries
	// GeoFunc, when set, is a `func() *geo.LocationData` that returns the visor's
	// CURRENT geolocation. It is preferred over Geo so a heartbeat picks up the
	// geo once the async public-IP/geo lookup finishes — Geo alone was a nil
	// snapshot captured at init (before that lookup), which dropped country from
	// every registration that lost the race.
	GeoFunc any
	// EntrySink, when set, is a `servicedisc.EntrySink` handed to every
	// service-discovery client this factory builds, so the visor's
	// SD-registration-over-CXO publisher sees the exact entries the SD
	// accepted. Typed `any` for the same reason as Client/Geo: pkg/servicedisc
	// pulls net/http, which this shared struct must not.
	EntrySink any
}

Factory creates appdisc.Updater instances based on the app name.

The updater constructors (VisorUpdater/PublicVisorUpdater/AppUpdater) build service-discovery HTTP clients and so live in factory_native.go (//go:build !tinygo); on the TinyGo js/wasm target factory_tinygo.go hands out emptyUpdater. Client is typed `any` (an *http.Client on native) so this shared struct definition stays net/http-free.

func (*Factory) AppUpdater

func (f *Factory) AppUpdater(conf appcommon.ProcConfig) (Updater, bool)

AppUpdater obtains an app updater based on the app name and configuration.

func (*Factory) PublicVisorUpdater

func (f *Factory) PublicVisorUpdater(
	port uint16,
	registrationTimeout time.Duration,
	maxTransports int,
	getTransportCount func() int,
) *PublicVisorUpdater

PublicVisorUpdater obtains a public visor updater with validation logic. It wraps a regular service updater and monitors for external STCPR connections and transport count to determine if the visor should stay registered.

func (*Factory) VisorUpdater

func (f *Factory) VisorUpdater(port uint16) Updater

VisorUpdater obtains a visor updater.

type PublicVisorUpdater

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

PublicVisorUpdater wraps a serviceUpdater with public visor validation logic. It monitors for external STCPR connections and transport count to determine if the visor should stay registered in service discovery.

func NewPublicVisorUpdater

func NewPublicVisorUpdater(
	log logrus.FieldLogger,
	inner *serviceUpdater,
	registrationTimeout time.Duration,
	maxTransports int,
	getTransportCount func() int,
) *PublicVisorUpdater

NewPublicVisorUpdater creates a new public visor updater with validation logic.

func (*PublicVisorUpdater) IsValidated

func (u *PublicVisorUpdater) IsValidated() bool

IsValidated returns whether the visor has received an external connection.

func (*PublicVisorUpdater) OnExternalSTCPR

func (u *PublicVisorUpdater) OnExternalSTCPR()

OnExternalSTCPR should be called when an external STCPR connection is received. This validates that the visor is reachable from the internet.

func (*PublicVisorUpdater) Start

func (u *PublicVisorUpdater) Start()

Start starts the updater with validation monitoring.

func (*PublicVisorUpdater) Stop

func (u *PublicVisorUpdater) Stop()

Stop stops the updater.

type Updater

type Updater interface {

	// Start starts the updater.
	Start()

	// Stop stops the updater.
	Stop()
}

Updater updates the associated app discovery

Jump to

Keyboard shortcuts

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