roles

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 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 roles provides zero-boilerplate role-based service composition. Instead of a switch statement in every main.go, declare once and run.

Usage:

roles.New().
    Add("gateway",  gateway.Setup).
    Add("pipeline", pipeline.Setup).
    Add("eval",     eval.Setup).
    AddAlias("all", "gateway", "pipeline", "eval").
    Run(app, cfg)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry maps role names to their setup functions.

func New

func New() *Registry

func (*Registry) Add

func (r *Registry) Add(name string, fns ...SetupFn) *Registry

Add registers one or more setup functions for a named role. Multiple calls to Add with the same name append (useful for composing).

func (*Registry) AddAlias

func (r *Registry) AddAlias(alias string, roles ...string) *Registry

AddAlias defines a composite role that runs multiple underlying roles.

AddAlias("all", "gateway", "pipeline", "eval")

func (*Registry) Run

func (r *Registry) Run(envKey ...string)

Run reads ROLE from the environment and executes the matching setup functions. Panics with a helpful message if the role is unknown — fail fast at boot.

type SetupFn

type SetupFn func()

SetupFn is any function that configures a nexss.App for a given role. Keep it generic — callers can use any signature via closure capture.

Jump to

Keyboard shortcuts

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