TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/platforma-dev/platforma/llms.txt
Use this file to discover all available pages before exploring further.
application package provides the core Application type that manages startup tasks, services, databases, and health checks throughout your application’s lifecycle.
Application Type
TheApplication type orchestrates the lifecycle of your application, managing startup tasks, services, databases, and health monitoring.
Constructor
Creates and returns a new Application instance.
Methods
RegisterService
Registers a named service with the application. Services are started concurrently when the application runs.
RegisterDatabase
Adds a database to the application for lifecycle management.
RegisterRepository
Registers a repository with a specific database. Repositories implementing the migrator interface will have their migrations applied.
RegisterDomain
Registers a domain repository in the specified database. The domain must implement the Domain interface.
OnStart
Registers a startup task that runs before services start.
OnStartFunc
Registers a startup task using a function.
Health
Returns the current health status of the application and all registered services.
Run
Parses CLI arguments and executes the appropriate command.Supported commands:
run- Starts all registered servicesmigrate- Runs database migrations--help,-h- Displays usage information
ErrUnknownCommand if an unknown command is provided.Interfaces
Runner
The Runner interface defines tasks that can be executed with context.Executes the task with the given context and returns an error if any.
RunnerFunc
A function type that implements the Runner interface.Domain
The Domain interface describes a domain module that exposes its repository.Returns the repository associated with this domain.
Healthchecker
Represents a service that can perform health checks.Returns the health status of the service. The returned value can be any serializable type.
Types
StartupTaskConfig
Configuration options for a startup task.Name of the startup task for logging and identification.
If true, the application will terminate if this startup task fails. If false, the error is logged and execution continues.
Errors
ErrUnknownCommand
Run().
ErrDatabaseMigrationFailed
migrate command.
ErrStartupTaskFailed
AbortOnError: true fails.
Helpers
HealthCheckHandler
An HTTP handler that serves application health information as JSON.Creates a health check HTTP handler for the application.Parameters:
app(*Application): The application instance to check health for
- Application start time
- Service statuses (NOT_STARTED, STARTED, ERROR)
- Service start/stop times
- Error messages for failed services
- Custom health data from Healthchecker implementations