features

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 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 features is the organizations' flags: parts of the hub that are switched on for an organization at a time (docs/hub/api.md, «Feature flags»). Everything new in the hub ships dark behind one of them.

A flag is on for an organization when, in this order: the instance forces it (HUB_FEATURES_FORCE, `name` on, `-name` off); else the organization chose (table org_features); else the instance defaults it on (HUB_FEATURES_DEFAULT); else it is off.

Index

Constants

View Source
const (
	// UIHX is the new interface; the old one stays until everything is switched over.
	UIHX = "ui.hx"
	// Env is the machines' environment screen.
	Env = "env"
	// Catalog is the catalog of tools and skills.
	Catalog = "catalog"
	// MachineResources is editing a machine's resources and showing their price.
	MachineResources = "machine.resources"
	// OrgEvents is the organization's live stream (GET /api/orgs/{org}/events).
	OrgEvents = "org.events"
	// UIHXLive is the lively hub: the common motion on every screen, free periods, sortable tables and the tools screen.
	UIHXLive = "ui.hx.live"
	// RuntimeFleet is one runtime for all of a person's machines: GET /api/me/machines and the /api/v2 proxy of the hub.
	RuntimeFleet = "runtime.fleet"
	// SecretsVault is the hub's safe: the machines of the organization keep their secrets on the hub's server
	// (HUB_SECRETS_VAULT_*, docs/safe.md).
	SecretsVault = "secrets.vault"
	// Efficiency is the «Эффективность» screen's figures: GET /api/orgs/{org}/efficiency/summary.
	Efficiency = "efficiency"
	// ChatResume is continuing a chat on another machine of the person while the one it ran on is off, from the resume
	// snapshot its machine left in the hub's store after each turn (docs/hub/resume.md).
	ChatResume = "chat.resume"
	// MachineSeats shows the machines of one server (one hostname in a tenant, a Linux user per person) as one server
	// with the people's seats in it; the server's load and hardware are counted once.
	MachineSeats = "machine.seats"
	// EnvPacks lets an organization put environment packs (tools, hooks, MCP and the safe's rules in a versioned
	// repository folder) in its catalog (docs/hub/packs.md).
	EnvPacks = "env.packs"
	// EnvOwn is a person's own layer of the environment: their own skills and MCP servers, and their switches, on their
	// own machines' lists (docs/hub/environment.md «Own layer»).
	EnvOwn = "env.own"
	// HooksNoSpool is an organization's policy to keep no webhook bodies in the hub: a managed webhook is passed to its
	// holder while it is online, and the sender gets 503 otherwise (docs/hub/sources.md «Вебхуки»).
	HooksNoSpool = "hooks.nospool"
)

The flags the hub knows.

View Source
const CacheTTL = 5 * time.Second

CacheTTL is how long an organization's flags are kept before the table is read again; a change made by this process is seen at once, one made by another replica within this time.

Variables

Known are the flag names in the order they are shown.

Functions

func IsKnown

func IsKnown(name string) bool

IsKnown says that name is a flag of the hub.

Types

type AllOn

type AllOn struct{}

AllOn is a Gate with every flag on.

func (AllOn) On

On implements Gate.

type Gate

type Gate interface {
	On(ctx context.Context, orgID, name string) bool
}

Gate answers whether a flag is on for an organization (its id, or `space:<id>` for a space that is in none).

type Static

type Static map[string]map[string]bool

Static is a Gate with fixed flags, for tests of other packages: Static{"org": {"env": true}}.

func (Static) On

func (g Static) On(_ context.Context, orgID, name string) bool

On implements Gate.

type Store

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

Store is the Gate over the org_features table.

func New

func New(db *store.DB, conf config.Features, now func() time.Time) *Store

New makes the gate; now is the clock, nil means time.Now.

func (*Store) Forced

func (s *Store) Forced(name string) bool

Forced says that the instance decides the flag, so an organization's choice changes nothing.

func (*Store) Instance

func (s *Store) Instance() []string

Instance are the flags that are on for an organization that chose nothing: what the instance forces or defaults on.

func (*Store) List

func (s *Store) List(ctx context.Context, orgID string) []string

List are the flags that are on for the organization, in the order of Known.

func (*Store) On

func (s *Store) On(ctx context.Context, orgID, name string) bool

On is whether the flag is on for the organization. A table that cannot be read leaves only the instance's say.

func (*Store) Set

func (s *Store) Set(ctx context.Context, orgID, name string, enabled bool, by string) error

Set keeps the organization's choice and drops its cached flags.

Jump to

Keyboard shortcuts

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