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
Provide[T](ctx, fn)Register a DI provider
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_")
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
ReloadNotifierSubscribe to hot-reload events
ReloadNotifier.OnReload(fn)Register a reload callback
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

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