Documentation
¶
Index ¶
- Constants
- func NewCmdServe(props *props.Props) *setup.Command
- func Refresher(ctx context.Context, p *props.Props, log *slog.Logger, interval time.Duration) (*indexer.Service, func() error, error)
- func RestartPolicy() controls.RestartPolicy
- func RunServe(ctx context.Context, p *props.Props, _ *ServeOptions, _ []string) error
- type Config
- type IndexConfig
- type ServeOptions
- type Service
Constants ¶
const MinRefreshInterval = time.Minute
MinRefreshInterval is the shortest accepted refresh interval.
Every refresh clones the repositories that moved. A minute would put the bot in a permanent clone loop against the forge, which is a denial of service aimed at the project's own infrastructure.
Variables ¶
This section is empty.
Functions ¶
func Refresher ¶
func Refresher( ctx context.Context, p *props.Props, log *slog.Logger, interval time.Duration, ) (*indexer.Service, func() error, error)
Refresher builds the scheduled index refresher.
It goes through the same session the `index` commands open, so the scheduled and manual routes run one code path and cannot drift into disagreeing about what is indexed or where the index lives.
A failure here fails startup, deliberately. Building the provider makes no network call, so it can only fail on a configuration an operator can fix in seconds — and this project already refuses a bad configuration before anything binds or connects. A forge that is merely unreachable is a different thing: it surfaces later as a failed refresh, and is degraded rather than fatal.
func RestartPolicy ¶
func RestartPolicy() controls.RestartPolicy
Backs off rather than hammering.
A gateway that cannot connect will not connect harder for being asked more often, and Discord rate-limits identify. Retrying belongs here, in the supervisor, rather than inside the service — a service that retries silently hides its own failure from the thing meant to be watching it. RestartPolicy is the supervision policy for a gateway service.
func RunServe ¶
RunServe runs the daemon until the context is cancelled.
The command owns wiring and nothing else: configuration in, services registered, controller started, shutdown awaited. Every decision worth testing lives in pkg/ingest, where it can be exercised against a fake provider rather than a live gateway.
Types ¶
type Config ¶
type Config struct {
ingest.Config
Index IndexConfig
}
Config is everything the daemon needs.
The ingest configuration is embedded rather than named, so the guilds and health sections keep reading as they did before the index arrived.
func ConfigFromStore ¶
ConfigFromStore reads the ingest configuration from the live store.
func LoadConfig ¶
LoadConfig reads, defaults and validates the ingest configuration.
Validation happens here rather than at first use so a misconfiguration is reported before anything connects or binds. An operator should see "the allowlist is empty", not a connection error three layers downstream of it.
type IndexConfig ¶
type IndexConfig struct {
// RefreshInterval is how often the corpus is re-read.
RefreshInterval time.Duration
}
IndexConfig is the resolved index configuration.
Deliberately does not carry index.path. That key has one reader — session.DBPath — shared with the `index` commands, and a second reader here would be the drift this whole wiring exists to avoid: `serve` refreshing one database while `index status` reports another.
type ServeOptions ¶
type ServeOptions struct{}
type Service ¶
Service is a named ingest service, ready to register with a controller.