module

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package module is how an application mounts its topic managers and lookup services in the Go overlay engine.

It replaces the TypeScript host's Module/ModuleHost loader. Go has no runtime module loading worth using, so a module is compiled in: its package calls Register from init, the binary imports it, and OVERLAY_MODULES names which registered modules this host mounts. Each module is a thin adapter over its application's Go core: it holds no admission or lookup logic of its own that the core does not already hold.

The interfaces are upstream's (go-overlay-services pkg/core/engine) unchanged, so a manager written here runs on any host of that engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, f Factory)

Register makes a module available under name. Call it from init. A name registered twice panics: two modules under one name is a build error.

func Registered

func Registered() []string

Registered lists registered module names, sorted.

Types

type Factory

type Factory func(h Host) (Module, error)

Factory builds a module for one host.

type Host

type Host struct {
	// Topics are the topics this host carries (OVERLAY_TOPICS). A module may
	// claim only topics in this list.
	Topics []string
	// Storage is the engine's storage, for lookup services that answer from
	// it rather than from an index of their own.
	Storage engine.Storage
	// Registerer is the host's metrics registry; a module's families use its
	// own prefix (bstore_, bbox_ ...), never overlay_go_.
	Registerer prometheus.Registerer
	Log        *slog.Logger
}

Host is what a module is handed when it is built.

type Module

type Module struct {
	TopicManagers  map[string]engine.TopicManager
	LookupServices map[string]engine.LookupService
}

Module is what a factory returns: managers keyed by tm_* topic name and lookup services keyed by ls_* name.

type Mounted

type Mounted struct {
	TopicManagers  map[string]engine.TopicManager
	LookupServices map[string]engine.LookupService
	// Owner says which module mounted each topic and lookup name.
	Owner map[string]string
}

Mounted is the result of Mount: what the engine is built with.

func Mount

func Mount(names []string, h Host, m *metrics.Metrics) (*Mounted, error)

Mount builds the named modules in order and merges them. It refuses rather than resolves every conflict, and it refuses a carried topic with no manager: a host must never admit a topic under a manager nobody chose.

  • a name not registered;
  • a topic outside h.Topics, or claimed by two modules;
  • a lookup name claimed by two modules;
  • a carried topic no module claims.

Jump to

Keyboard shortcuts

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