systemsetting

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package systemsetting implements the system configuration subdomain of the platform module. Runtime subsystem re-initialization, restart and the mutable configuration snapshot are reached through injected callbacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditWriter added in v1.21.0

type AuditWriter interface {
	Insert(ctx context.Context, data *log.SystemLog) error
}

AuditWriter records the administrator's change next to the settings it changed, in the same transaction.

type Deps

type Deps struct {
	System kernel.SystemRepo
	// Store runs the writes of each update in one transaction.
	Store SettingsTransactor
	// Reinitialize re-runs a subsystem's initialization after its
	// configuration changed, reporting a failure.
	Reinitialize func(subsystem string) error
	// Restart restarts the transport server (subscribe path changes).
	Restart func() error
	// SubscribePath reads the currently active subscribe path.
	SubscribePath func() string
	// Multiplier evaluates the current node traffic multiplier.
	Multiplier func(at time.Time) float32
}

Deps declares the subdomain's dependencies; the module facade forwards them from the composition root.

type MultiplierFunc

type MultiplierFunc = func(at time.Time) float32

MultiplierFunc evaluates the current node traffic multiplier.

type PlatformTransactor

type PlatformTransactor interface {
	InPlatformTx(ctx context.Context, fn func(kernel.PlatformStore) error) error
}

PlatformTransactor mirrors the store's platform-scoped transaction.

type Service

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

Service reads and updates the system settings for the platform facade.

func NewService

func NewService(deps Deps) *Service

NewService builds the system settings service.

func (*Service) GetCurrencyConfig

func (s *Service) GetCurrencyConfig(ctx context.Context) (*dto.CurrencyConfig, error)

GetCurrencyConfig returns the stored currency settings, the exchange-rate provider's access key masked.

func (*Service) GetInviteConfig

func (s *Service) GetInviteConfig(ctx context.Context) (*dto.InviteConfig, error)

GetInviteConfig returns the stored invitation settings.

func (*Service) GetNodeConfig

func (s *Service) GetNodeConfig(ctx context.Context) (*dto.NodeConfig, error)

GetNodeConfig returns the stored node settings, the outbound credentials masked. A malformed DNS or outbound document is reported as an error instead of taking the process down.

func (*Service) GetNodeMultiplier

func (s *Service) GetNodeMultiplier(ctx context.Context) (*dto.GetNodeMultiplierResponse, error)

GetNodeMultiplier returns the stored node traffic multiplier periods. A malformed document is reported as an error.

func (*Service) GetPrivacyPolicyConfig

func (s *Service) GetPrivacyPolicyConfig(ctx context.Context) (*dto.PrivacyPolicyConfig, error)

GetPrivacyPolicyConfig returns the stored privacy policy, which lives in the tos settings category.

func (*Service) GetRegisterConfig

func (s *Service) GetRegisterConfig(ctx context.Context) (*dto.RegisterConfig, error)

GetRegisterConfig returns the stored registration settings.

func (*Service) GetSiteConfig

func (s *Service) GetSiteConfig(ctx context.Context) (*dto.SiteConfig, error)

GetSiteConfig returns the stored site settings.

func (*Service) GetSubscribeConfig

func (s *Service) GetSubscribeConfig(ctx context.Context) (*dto.SubscribeConfig, error)

GetSubscribeConfig returns the stored subscription settings.

func (*Service) GetTosConfig

func (s *Service) GetTosConfig(ctx context.Context) (*dto.TosConfig, error)

GetTosConfig returns the stored terms of service.

func (*Service) GetVerifyCodeConfig

func (s *Service) GetVerifyCodeConfig(ctx context.Context) (*dto.VerifyCodeConfig, error)

GetVerifyCodeConfig returns the stored verification code settings.

func (*Service) GetVerifyConfig

func (s *Service) GetVerifyConfig(ctx context.Context) (*dto.VerifyConfig, error)

GetVerifyConfig returns the stored verification settings, the Turnstile secret masked. It only reads: the running configuration is re-initialized when the settings are updated.

func (*Service) PreViewNodeMultiplier

func (s *Service) PreViewNodeMultiplier(_ context.Context) (*dto.PreViewNodeMultiplierResponse, error)

PreViewNodeMultiplier reports the node traffic multiplier in effect now.

func (*Service) SetNodeMultiplier

func (s *Service) SetNodeMultiplier(ctx context.Context, req *dto.SetNodeMultiplierRequest) error

SetNodeMultiplier stores the node traffic multiplier periods, with the audit row of the change, and reloads the node subsystem, which evaluates them.

func (*Service) SettingTelegramBot

func (s *Service) SettingTelegramBot(ctx context.Context) error

SettingTelegramBot reloads the Telegram bot from its stored settings. The reload re-registers the webhook and the command menu, so it is recorded like a settings change; a trail that cannot be written is logged, the reload being what the administrator asked for.

func (*Service) UpdateCurrencyConfig

func (s *Service) UpdateCurrencyConfig(ctx context.Context, req *dto.CurrencyConfig) error

UpdateCurrencyConfig stores the currency settings and, once they are stored, reloads the currency subsystem: a failed write must not reload a configuration that did not change. A masked access key keeps the stored one.

func (*Service) UpdateInviteConfig

func (s *Service) UpdateInviteConfig(ctx context.Context, req *dto.InviteConfig) error

UpdateInviteConfig stores the invitation settings and reloads the invite subsystem.

func (*Service) UpdateNodeConfig

func (s *Service) UpdateNodeConfig(ctx context.Context, req *dto.NodeConfig) error

UpdateNodeConfig stores the node settings, kept in the server settings category, and reloads the node subsystem. Masked outbound credentials keep the stored ones.

func (*Service) UpdatePrivacyPolicyConfig

func (s *Service) UpdatePrivacyPolicyConfig(ctx context.Context, req *dto.PrivacyPolicyConfig) error

UpdatePrivacyPolicyConfig stores the privacy policy in the tos settings category. No running subsystem reads it, so nothing is reloaded.

func (*Service) UpdateRegisterConfig

func (s *Service) UpdateRegisterConfig(ctx context.Context, req *dto.RegisterConfig) error

UpdateRegisterConfig stores the registration settings and reloads the register subsystem.

func (*Service) UpdateSiteConfig

func (s *Service) UpdateSiteConfig(ctx context.Context, req *dto.SiteConfig) error

UpdateSiteConfig stores the site settings, every value as written, and reloads the site subsystem.

func (*Service) UpdateSubscribeConfig

func (s *Service) UpdateSubscribeConfig(ctx context.Context, req *dto.SubscribeConfig) error

UpdateSubscribeConfig stores the subscription settings. A new subscribe path needs the HTTP routes rebuilt, so the server restarts in the background instead of reloading the subscribe subsystem; a failed restart is only logged, the settings being stored.

func (*Service) UpdateTosConfig

func (s *Service) UpdateTosConfig(ctx context.Context, req *dto.TosConfig) error

UpdateTosConfig stores the terms of service. No running subsystem reads them, so nothing is reloaded.

func (*Service) UpdateVerifyCodeConfig

func (s *Service) UpdateVerifyCodeConfig(ctx context.Context, req *dto.VerifyCodeConfig) error

UpdateVerifyCodeConfig stores the verification code settings and reloads the verify subsystem, which enforces them.

func (*Service) UpdateVerifyConfig

func (s *Service) UpdateVerifyConfig(ctx context.Context, req *dto.VerifyConfig) error

UpdateVerifyConfig stores the verification settings and reloads the verify subsystem from them. A masked Turnstile secret keeps the stored one.

type SettingsStore added in v1.21.0

type SettingsStore interface {
	SettingsWriter
	AuditWriter
}

SettingsStore is what one settings update reaches inside its transaction: the settings it writes and the audit trail it records the change in.

type SettingsTransactor added in v1.21.0

type SettingsTransactor interface {
	InSettingsTx(ctx context.Context, fn func(SettingsStore) error) error
}

SettingsTransactor runs the writes of one settings update in a single transaction, so an update and its audit row are stored whole or not at all.

func NewSettingsTransactor added in v1.21.0

func NewSettingsTransactor(store PlatformTransactor) SettingsTransactor

NewSettingsTransactor runs the settings writes in platform-scoped transactions of store, on its system settings and system log repositories.

type SettingsWriter added in v1.21.0

type SettingsWriter interface {
	UpdateValueByCategoryKey(ctx context.Context, category, key, value string, valueType ...string) error
}

SettingsWriter is what a settings update writes inside its transaction: the stored value of each setting.

Jump to

Keyboard shortcuts

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