module

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 15 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 defines the public boundary for compiled modules and remote services.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRemoteUnavailable   = errors.New("remote module unavailable")
	ErrRemoteConfiguration = errors.New("remote module configuration invalid")
	ErrRemoteIncompatible  = errors.New("remote module protocol incompatible")
)

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Descriptor Descriptor
	Start      func(context.Context) error
	Stop       func(context.Context) error
	Ready      func(context.Context) error
	// Critical makes the module's core availability part of process readiness.
	Critical bool
}

Definition's hooks must respect context cancellation. Start must clean up its own partial failure; Fx stops previously started modules in reverse order.

type Dependency

type Dependency struct {
	ID  string `json:"id"`
	API int    `json:"api"`
}

type Descriptor

type Descriptor struct {
	ID                 string                  `json:"id"`
	Version            string                  `json:"version"`
	API                int                     `json:"api"`
	Requires           []Dependency            `json:"requires"`
	Optional           []Dependency            `json:"optional,omitempty"`
	Capabilities       []string                `json:"capabilities"`
	CapabilityRequires map[string][]Dependency `json:"capability_requires,omitempty"`
}

Descriptor contains public operational metadata only, never provider settings.

type Registry

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

func New

func New(definitions []Definition, enabled []string) (*Registry, error)

New validates the entire composition before hooks can start any work.

func (*Registry) Available

func (r *Registry) Available(ctx context.Context, id string) bool

func (*Registry) Capabilities

func (r *Registry) Capabilities(ctx context.Context) []string

func (*Registry) CapabilityAvailable

func (r *Registry) CapabilityAvailable(ctx context.Context, id, name string) bool

func (*Registry) Healthy

func (r *Registry) Healthy(ctx context.Context) bool

func (*Registry) Owns

func (r *Registry) Owns(id, cap string) bool

func (*Registry) ReadyForTraffic

func (r *Registry) ReadyForTraffic(ctx context.Context) bool

ReadyForTraffic checks only explicitly critical modules and their core dependencies.

func (*Registry) RegisterLifecycle

func (r *Registry) RegisterLifecycle(lc fx.Lifecycle)

RegisterLifecycle delegates ordered startup, rollback and shutdown to Fx. Enable/disable is configuration-driven and applied by a controlled restart.

func (*Registry) Statuses

func (r *Registry) Statuses() []Status

func (*Registry) StatusesContext

func (r *Registry) StatusesContext(ctx context.Context) []Status

type Remote

type Remote struct {
	Expected      Descriptor
	URL           string
	TokenFile     string
	Timeout       time.Duration
	ProbeInterval time.Duration
	MaxBackoff    time.Duration
}

Remote's monitor owns network probes and credential reloads. Request handlers read its bounded snapshot; remote metadata can only confirm approved capabilities.

func (Remote) Definition

func (config Remote) Definition() (Definition, error)

type State

type State string
const (
	Disabled State = "disabled"
	Starting State = "starting"
	Ready    State = "ready"
	Stopping State = "stopping"
	Stopped  State = "stopped"
	Failed   State = "failed"
)

type Status

type Status struct {
	ID     string `json:"id"`
	State  State  `json:"state"`
	Health string `json:"health"`
}

Jump to

Keyboard shortcuts

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