services

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package services selects and constructs the runtime services provider chosen at startup by the RUNTIME_SERVICES_MODULE environment variable.

Providers live in subpackages (standalone, k8s, and future ones such as redis). Each self-registers from an init function by calling Register with its module name: only the provider whose name matches the selected module becomes active, the rest are no-ops. A binary blank-imports the provider packages it ships (mirroring how connectors are wired), then calls New to build whichever one selected itself.

Index

Constants

View Source
const DefaultModule = "standalone"

DefaultModule is the provider selected when RUNTIME_SERVICES_MODULE is unset: a single-process, no-dependency default.

View Source
const ModuleEnvVar = "RUNTIME_SERVICES_MODULE"

ModuleEnvVar names the environment variable selecting the runtime services provider.

Variables

This section is empty.

Functions

func Module

func Module() string

Module returns the selected module name (RUNTIME_SERVICES_MODULE, or the default when unset), for logging.

func New

func New(ctx context.Context, opts Options) (core.RuntimeServices, error)

New builds the active provider. It errors when no imported provider selected itself for the chosen module (typically a missing blank import). The returned services are owned by the caller, which must Close them on shutdown.

func Register

func Register(module string, factory Factory)

Register offers factory as the provider for module. It becomes the active provider only when module matches the selected module; otherwise the call is a no-op, so every imported provider may register unconditionally from its init.

Types

type Factory

type Factory func(ctx context.Context, opts Options) (core.RuntimeServices, error)

Factory constructs a runtime services provider. Construction may do real work (e.g. building an in-cluster Kubernetes client) and so may fail.

type Options

type Options struct {
	ResourceRoot string
}

Options carries construction inputs a provider may need beyond the context. ResourceRoot roots the standalone module's filesystem resource loader (the config directory); providers that resolve resources elsewhere (k8s) ignore it.

Directories

Path Synopsis
Package k8s implements the runtime services provider for a Kubernetes cluster: leader election backed by coordination/v1 Leases (so work runs on one replica) and a KV store backed by the orchestrator API (deployment-scoped, with encrypted secrets).
Package k8s implements the runtime services provider for a Kubernetes cluster: leader election backed by coordination/v1 Leases (so work runs on one replica) and a KV store backed by the orchestrator API (deployment-scoped, with encrypted secrets).
Package standalone implements the single-process runtime services module: leader election always grants leadership (there is nothing to elect) and the KV store lives in process memory.
Package standalone implements the single-process runtime services module: leader election always grants leadership (there is nothing to elect) and the KV store lives in process memory.

Jump to

Keyboard shortcuts

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