Skip to content

API Index

SymbolDescription
NewRuntime(modules ...Module) *RuntimeCreate and run the service
Runtime.Run()Start the runtime, block until shutdown
ModuleInterface: Init(ctx) error, Shutdown(ctx) error
SyncModuleAdds Start(ctx) error
AsyncModuleAdds StartAsync(ctx) error
ConfigurableAdds ConfigPath() string, LoadConfig(*koanf.Koanf) error
NamedModuleAdds Name() string
NamedBaseEmbed to satisfy NamedModule
NewNamedBase(name string) NamedBaseConstructor for NamedBase
SyncCtxEmbed to get RuntimeCtx() context.Context in Start
GetInjector(ctx) do.InjectorRetrieve the DI injector from context
WithInjector(ctx, injector) context.ContextAttach a DI injector to a context
Provide[T](ctx, fn)Register a DI provider
ProvideValue[T](ctx, value)Register an already-constructed value in DI
Invoke[T](ctx) (T, error)Resolve a dependency from the context injector
HotReloadableAdds OnReload(*koanf.Koanf); wired by the runtime for config reloads
ValidatableModuleAdds ValidateReload(*koanf.Koanf) error; can veto a config hot-reload before it is committed
SymbolDescription
NewModule(opts ...Option) *ModuleConfig module
WithConfigDirs(dirs ...string) OptionSet search directories for config files
WithConfigName(name string) OptionSet config file base name (default: "lakta")
WithArgs(args []string) OptionEnable CLI flag overrides (os.Args[1:])
WithEnvPrefix(prefix string) OptionSet env var prefix (default: "LAKTA_")
WithDebounceDelay(d time.Duration) OptionDebounce window for fsnotify hot-reload events
Bind[T](path ...string) ModuleBind a config sub-tree to a typed struct; adds as a module
Get[T](ctx) *TRead the current bound value (atomic, zero-alloc)
GetBinding[T](ctx) *Binding[T]Access the binding to register OnChange callbacks
ModulePath(category, type, instance string) stringGenerate a modules.<category>.<type>.<instance> path
UnmarshalKoanf[C](c *C, k *koanf.Koanf, path string) errorDecode a config sub-tree into a typed struct (used in LoadConfig)
Passthrough[T]map[string]any field type that captures extra keys for raw passthrough
TLSEmbeddable file-path TLS config (cert_file/key_file/ca_file/client_ca_file/client_auth); builds server/client *tls.Config
ValidatableAdds Validate() error; bound configs are validated on load/reload
ReloadNotifierSubscribe to hot-reload events
ReloadNotifier.OnReload(fn)Register a reload callback
ReloadNotifier.OnValidate(fn)Register a validator that can veto a reload before commit
SymbolDescription
NewHarness(t) *HarnessInjector-backed context for unit tests
Harness.WithData(map) *HarnessSeed koanf config from a map
Harness.WithKoanf(*koanf.Koanf) *HarnessSeed koanf config from a Koanf instance
Harness.Ctx() context.ContextAccess the test context
WithProvider[T](h, fn)Register a DI provider (free generic function)
NewRuntimeHarness(t, modules...) *RuntimeHarnessFull runtime in goroutine
RuntimeHarness.Shutdown()Gracefully stop the runtime
NewMockModule() *MockModuleBasic module mock
NewMockSyncModule() *MockSyncModuleSyncModule mock with BlockStart chan
NewMockAsyncModule() *MockAsyncModuleAsyncModule mock
NewMockProviderModule() *MockProviderModuleModule mock that registers a DI provider
MapProvidermap[string]any implementing koanf.Provider for seeding config
WaitForAddr(t, m) net.AddrBlock until a module reports its listen address

Lakta uses github.com/Vilsol/slox (external package):

SymbolDescription
slox.Info(ctx, msg, attrs...)Log at Info level
slox.Debug(ctx, msg, attrs...)Log at Debug level
slox.Warn(ctx, msg, attrs...)Log at Warn level
slox.Error(ctx, msg, attrs...)Log at Error level
slox.FromContext(ctx) *slog.LoggerExtract logger from context
slox.WithContext(ctx, logger) context.ContextInject logger into context