Help us shape the future of Go! Take the 2026 Go Developer Survey

state

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package state owns the process-wide mutable runtime state. Configuration is published as immutable snapshots so request and queue goroutines never race with an administrator-triggered reinitialization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State is the runtime state the composition root shares with the services: the configuration snapshot, the Telegram bot, the node traffic multiplier and the late-bound restart and reinitialize handlers.

func New

func New(initial config.Config) *State

New returns the state holding initial as its first configuration snapshot.

func (*State) Config

func (s *State) Config() config.Config

Config returns the current immutable configuration snapshot.

func (*State) NodeMultiplierManager

func (s *State) NodeMultiplierManager() *network.MultiplierManager

NodeMultiplierManager returns the node traffic multiplier periods, nil before the node settings were loaded.

func (*State) Reinitialize

func (s *State) Reinitialize(subsystem string) error

Reinitialize reloads a subsystem's runtime configuration and reports a failure; before the server installed its handler there is nothing to reload.

func (*State) Restart

func (s *State) Restart() error

Restart restarts the HTTP server; before the server installed its handler there is nothing to restart.

func (*State) SetNodeMultiplierManager

func (s *State) SetNodeMultiplierManager(manager *network.MultiplierManager)

SetNodeMultiplierManager publishes the multiplier periods the node settings define.

func (*State) SetReinitialize

func (s *State) SetReinitialize(handler func(string) error)

SetReinitialize installs the subsystem reload the HTTP server runs the bootstrap with.

func (*State) SetRestart

func (s *State) SetRestart(handler func() error)

SetRestart installs the HTTP server's restart; the server installs it once it started.

func (*State) SetTelegramBot

func (s *State) SetTelegramBot(bot *tgbot.Bot)

SetTelegramBot publishes the bot client the bootstrap (re)initialized.

func (*State) TelegramBot

func (s *State) TelegramBot() *tgbot.Bot

TelegramBot returns the running bot client, nil while none is configured.

func (*State) UpdateRuntime added in v1.21.0

func (s *State) UpdateRuntime(update func(*config.Runtime))

UpdateRuntime serializes partial updates of the runtime settings and atomically publishes the result; the boot settings cannot change while the process runs. Callers must replace nested slices/maps instead of mutating values retained from an older snapshot.

Jump to

Keyboard shortcuts

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