Documentation
¶
Overview ¶
Package foundation provides functionality for the Tako framework.
Index ¶
- func Make[T any](app *Application) (T, error)
- type Application
- func (a *Application) BootPending() error
- func (a *Application) BootstrapWith(bootstrappers []Bootstrapper) error
- func (a *Application) CliRegistry() *cli.Registry
- func (a *Application) Commands(cmds ...cli.Command) *Application
- func (a *Application) Config() contracts.Config
- func (a *Application) Container() contracts.Container
- func (a *Application) Context() *tako.Context
- func (a *Application) CreatedAt() time.Time
- func (a *Application) Emit(event string, data any) *Application
- func (a *Application) Events() contracts.EventBus
- func (a *Application) Focus(zoneID string) *Application
- func (a *Application) GetProviders() []ServiceProvider
- func (a *Application) Hooks() *builders.HookBuilder
- func (a *Application) IsRegistered(name string) bool
- func (a *Application) Jobs() contracts.Scheduler
- func (a *Application) Keys() *builders.KeyBuilder
- func (a *Application) Logger() contracts.Logger
- func (a *Application) Make(abstract any) error
- func (a *Application) MarkAsBooted()
- func (a *Application) Mount(renderer contracts.UIRenderer) *Application
- func (a *Application) Mouse() *builders.MouseBuilder
- func (a *Application) OnDestroy(fn func()) *Application
- func (a *Application) Plugins() *plugin.Manager
- func (a *Application) RPC() contracts.RPCBus
- func (a *Application) RegisterProviders(providers ...ServiceProvider) error
- func (a *Application) Router() *router.Router
- func (a *Application) Shutdown()
- func (a *Application) Spawn(fn func(ctx context.Context)) *Application
- func (a *Application) Stack() *router.Stack
- func (a *Application) State() contracts.StateManager
- func (a *Application) Storage() contracts.KVStore
- func (a *Application) UI() contracts.UIManager
- func (a *Application) WithConfig(config contracts.Config) *Application
- func (a *Application) WithEvents(bus contracts.EventBus) *Application
- func (a *Application) WithLogger(logger contracts.Logger) *Application
- func (a *Application) WithStorage(storage contracts.KVStore) *Application
- func (a *Application) WithoutDefaultQuit() *Application
- type Bootstrapper
- type DependsOn
- type Disposable
- type HasManifest
- type PluginManifest
- type ServiceProvider
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Make ¶
func Make[T any](app *Application) (T, error)
Make fluently resolves a service of type T from the application container.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application represents the core foundation engine and dependency holder.
func NewApplication ¶
func NewApplication() *Application
NewApplication creates a new Application with an initialized dependency container.
func (*Application) BootPending ¶
func (a *Application) BootPending() error
BootPending boots any providers that were dynamically registered after the initial boot phase.
func (*Application) BootstrapWith ¶
func (a *Application) BootstrapWith(bootstrappers []Bootstrapper) error
BootstrapWith runs the given bootstrappers sequentially to initialize the application.
func (*Application) CliRegistry ¶
func (a *Application) CliRegistry() *cli.Registry
CliRegistry returns the command registry.
func (*Application) Commands ¶
func (a *Application) Commands(cmds ...cli.Command) *Application
Commands fluently registers one or more CLI commands directly to the application.
func (*Application) Config ¶
func (a *Application) Config() contracts.Config
Config returns the resolved Config from the application context.
func (*Application) Container ¶
func (a *Application) Container() contracts.Container
Container returns the underlying dependency-injection container.
func (*Application) Context ¶
func (a *Application) Context() *tako.Context
Context returns the framework context.
func (*Application) CreatedAt ¶
func (a *Application) CreatedAt() time.Time
CreatedAt returns the time the application was instantiated.
func (*Application) Emit ¶
func (a *Application) Emit(event string, data any) *Application
Emit publishes an event on the Event Bus.
func (*Application) Events ¶
func (a *Application) Events() contracts.EventBus
Events returns the resolved EventBus from the application context.
func (*Application) Focus ¶
func (a *Application) Focus(zoneID string) *Application
Focus sets the focused zone at the current top stack level.
func (*Application) GetProviders ¶
func (a *Application) GetProviders() []ServiceProvider
GetProviders returns all registered service providers.
func (*Application) Hooks ¶
func (a *Application) Hooks() *builders.HookBuilder
Hooks returns a builders.HookBuilder for configuring application hooks fluently.
func (*Application) IsRegistered ¶
func (a *Application) IsRegistered(name string) bool
IsRegistered checks if a provider with the given name has been registered.
func (*Application) Jobs ¶
func (a *Application) Jobs() contracts.Scheduler
Jobs returns the Scheduler from the application context.
func (*Application) Keys ¶
func (a *Application) Keys() *builders.KeyBuilder
Keys returns a builders.KeyBuilder for registering keybindings fluently.
func (*Application) Logger ¶
func (a *Application) Logger() contracts.Logger
Logger returns the resolved Logger from the application context.
func (*Application) Make ¶
func (a *Application) Make(abstract any) error
Make is a shorthand for a.Context().Container().Make() to resolve dependencies.
func (*Application) MarkAsBooted ¶
func (a *Application) MarkAsBooted()
MarkAsBooted marks the application as booted.
func (*Application) Mount ¶
func (a *Application) Mount(renderer contracts.UIRenderer) *Application
Mount fluently registers a custom UI renderer into the IoC container.
func (*Application) Mouse ¶
func (a *Application) Mouse() *builders.MouseBuilder
Mouse returns a builders.MouseBuilder for registering mouse zones and handlers fluently.
func (*Application) OnDestroy ¶
func (a *Application) OnDestroy(fn func()) *Application
OnDestroy registers a callback to be executed when the application shuts down.
func (*Application) Plugins ¶
func (a *Application) Plugins() *plugin.Manager
Plugins returns the plugin manager for this application.
func (*Application) RPC ¶
func (a *Application) RPC() contracts.RPCBus
RPC returns the RPCBus from the application context.
func (*Application) RegisterProviders ¶
func (a *Application) RegisterProviders(providers ...ServiceProvider) error
RegisterProviders registers one or more service providers. Each provider's Register() is called immediately. If the app is already booted, providers are queued for deferred boot.
func (*Application) Router ¶
func (a *Application) Router() *router.Router
Router returns the application's key-routing engine.
func (*Application) Shutdown ¶
func (a *Application) Shutdown()
Shutdown tears down providers (LIFO), cancels context, and runs cleanup. Safe to call multiple times — only the first call executes.
func (*Application) Spawn ¶
func (a *Application) Spawn(fn func(ctx context.Context)) *Application
Spawn starts a background goroutine tied to the framework's lifecycle.
Example ¶
package main
import (
"context"
"fmt"
"gettako.dev/tako/pkg/foundation"
)
func main() {
app := foundation.NewApplication()
// Spawn a background goroutine tied to the application's lifecycle.
// It will automatically be waited for during app.Shutdown()
// up to a maximum timeout of 3 seconds.
app.Spawn(func(ctx context.Context) {
<-ctx.Done()
// Clean up resources when context is canceled
fmt.Println("Background job shutting down cleanly.")
})
app.Shutdown()
}
Output: Background job shutting down cleanly.
func (*Application) Stack ¶
func (a *Application) Stack() *router.Stack
Stack returns the focus stack from the application router.
func (*Application) State ¶
func (a *Application) State() contracts.StateManager
State returns the state manager from the application context.
func (*Application) Storage ¶
func (a *Application) Storage() contracts.KVStore
Storage returns the persistent key-value store from the application context.
func (*Application) UI ¶
func (a *Application) UI() contracts.UIManager
UI returns the high-level layer manager facade (base layer, overlays, dialogs).
func (*Application) WithConfig ¶
func (a *Application) WithConfig(config contracts.Config) *Application
WithConfig fluently registers a custom configuration manager into the IoC container.
func (*Application) WithEvents ¶
func (a *Application) WithEvents(bus contracts.EventBus) *Application
WithEvents fluently registers a custom event bus into the IoC container.
func (*Application) WithLogger ¶
func (a *Application) WithLogger(logger contracts.Logger) *Application
WithLogger fluently registers a custom logger into the IoC container.
func (*Application) WithStorage ¶
func (a *Application) WithStorage(storage contracts.KVStore) *Application
WithStorage fluently registers a custom key-value store into the IoC container.
func (*Application) WithoutDefaultQuit ¶
func (a *Application) WithoutDefaultQuit() *Application
WithoutDefaultQuit disables the framework's default smart quit behaviour on ctrl+c.
type Bootstrapper ¶
type Bootstrapper interface {
Bootstrap(app *Application) error
}
Bootstrapper defines the interface for application boot steps. It allows the application initialization process to be modular and extensible.
type DependsOn ¶
type DependsOn interface {
Dependencies() []string
}
DependsOn is an optional interface. Providers that implement it declare which other providers must be registered before Boot is called. The framework validates (not sorts) — if a dependency is missing, Boot fails with a clear error.
type Disposable ¶
type Disposable interface {
Shutdown() error
}
Disposable is an optional interface. Providers that implement it get their Shutdown method called during application teardown (in LIFO order).
type HasManifest ¶
type HasManifest interface {
Manifest() PluginManifest
}
HasManifest is an optional interface. Providers that implement it are treated as "plugins" and appear in `plugin:list` CLI output. Internal providers should NOT implement this.
type PluginManifest ¶
type PluginManifest struct {
Name string
Version string
Author string
Description string
Repository string
License string
}
PluginManifest holds metadata for external plugins.
type ServiceProvider ¶
type ServiceProvider interface {
Register(app *Application) error
Boot(app *Application) error
}
ServiceProvider is the fundamental building block for all features in Tako. It follows a Two-Phase Lifecycle: Register (bind to container) then Boot (execute logic).