Documentation
¶
Index ¶
- func CloseNoSQL(ctx context.Context) error
- func NoSQLCollection(name string) nosql.Collection
- func SetDB(conn *DB)
- func SetNoSQL(driver nosql.Driver)
- func Transaction(fn func(tx *DB) error) error
- type App
- func (a *App) Boot() error
- func (a *App) NamedMiddleware() map[string]router.Middleware
- func (a *App) OnBoot(fn func(*App))
- func (a *App) OnShutdown(fn func(*App))
- func (a *App) OnStart(fn func(*App))
- func (a *App) Plugin(name string) Plugin
- func (a *App) PluginConfig(name string) map[string]any
- func (a *App) Plugins() []Plugin
- func (a *App) Register(p Provider)
- func (a *App) Run() error
- func (a *App) RunTLS(certFile, keyFile string) error
- func (a *App) Shutdown() error
- func (a *App) Use(plugins ...Plugin)
- type BasePlugin
- type DB
- type HasBindings
- type HasCommands
- type HasConfig
- type HasEvents
- type HasHealthChecks
- type HasMiddleware
- type HasMigrations
- type HasRoutes
- type HasSchedule
- type HasShutdown
- type HasViews
- type NoSQL
- type Plugin
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseNoSQL ¶
CloseNoSQL closes the default NoSQL connection.
func NoSQLCollection ¶
func NoSQLCollection(name string) nosql.Collection
NoSQLCollection is a convenience that returns a Collection handle from the default NoSQL connection.
coll := nimbus.NoSQLCollection("users")
coll.InsertOne(ctx, user)
func SetDB ¶
func SetDB(conn *DB)
SetDB is called by the framework (or hosting app) to make the database connection globally available to application code as *nimbus.DB.
func SetNoSQL ¶
SetNoSQL is called by the framework (or hosting app) to make the NoSQL connection globally available as *nimbus.NoSQL.
func Transaction ¶
Transaction runs fn inside a database transaction. It automatically commits if no error is returned, or rolls back if an error occurs.
Types ¶
type App ¶
type App struct {
Config *config.Config
Router *router.Router
Server *stdhttp.Server
Container *container.Container
Events *events.Dispatcher
Scheduler *schedule.Scheduler
Health *health.Checker
// contains filtered or unexported fields
}
App is the core Nimbus application (AdonisJS-style).
func (*App) Boot ¶
Boot runs the full initialisation sequence:
- Provider Register (all)
- Plugin Register (all) — bind services
- Plugin DefaultConfig collected
- Provider Boot (all)
- Plugin Boot (all)
- Plugin capabilities applied (routes, middleware, views)
func (*App) NamedMiddleware ¶
func (a *App) NamedMiddleware() map[string]router.Middleware
NamedMiddleware returns the merged map of named middleware from all plugins. Use in start/kernel.go or start/routes.go.
func (*App) OnBoot ¶
OnBoot registers a callback that runs after providers/plugins have been booted and plugin routes/middleware have been applied, but before the server starts listening.
func (*App) OnShutdown ¶
OnShutdown registers a callback that runs during graceful shutdown, before plugin HasShutdown hooks are executed.
func (*App) OnStart ¶
OnStart registers a callback that runs right before the HTTP server begins serving requests (after Boot and listen/port selection).
func (*App) PluginConfig ¶
PluginConfig returns the merged default config for a plugin, or nil.
func (*App) RunTLS ¶
RunTLS starts the HTTP server with TLS. If the configured port is busy, it automatically picks a free port. Listens for SIGINT/SIGTERM and gracefully shuts down to release the port.
type BasePlugin ¶
BasePlugin provides a no-op implementation of the Plugin interface. Embed it in your plugin struct so you only need to override the methods you care about.
type MyPlugin struct {
nimbus.BasePlugin
}
func (*BasePlugin) Boot ¶
func (b *BasePlugin) Boot(_ *App) error
func (*BasePlugin) Name ¶
func (b *BasePlugin) Name() string
func (*BasePlugin) Register ¶
func (b *BasePlugin) Register(_ *App) error
func (*BasePlugin) Version ¶
func (b *BasePlugin) Version() string
type DB ¶
DB is Nimbus's high-level database handle. Controllers and services can depend on *nimbus.DB instead of importing gorm. It is defined as a type alias so that *nimbus.DB and *lucid.DB are identical types, but applications should reference the nimbus.DB name.
func Begin ¶
func Begin() *DB
Begin starts a manual database transaction. The caller is responsible for calling Commit() or Rollback() on the returned *DB.
func Connection ¶
Connection returns a named database connection from the connection manager. If the named connection exists, it returns it. Otherwise, falls back to the default connection.
db := nimbus.Connection("analytics")
db.Find(&events)
type HasBindings ¶
HasBindings allows a plugin to declare container bindings that are automatically registered during the Register phase. Use this to bind SDK clients, API wrappers, or any service the app can resolve.
func (p *StripePlugin) Bindings(c *container.Container) {
c.Singleton("stripe", func() (*stripe.Client, error) {
return stripe.New(os.Getenv("STRIPE_KEY"))
})
}
type HasCommands ¶
HasCommands allows a plugin to register CLI commands (Artisan-style). Commands are added to the Nimbus CLI and available via `nimbus <cmd>`.
func (p *SentryPlugin) Commands() []cli.Command {
return []cli.Command{&SentryTestCommand{}}
}
type HasConfig ¶
HasConfig allows a plugin to declare default configuration values. The map is keyed by config name and merged into the application's configuration at boot time.
type HasEvents ¶
HasEvents allows a plugin to declare event listeners that are registered on the application's event dispatcher during boot.
func (p *AuditPlugin) Listeners() map[string][]events.Listener {
return map[string][]events.Listener{
"user.created": {p.onUserCreated},
"order.placed": {p.onOrderPlaced},
}
}
type HasHealthChecks ¶
HasHealthChecks allows a plugin to report health status. Registered checks are added to the application's health checker.
func (p *RedisPlugin) HealthChecks() map[string]health.Check {
return map[string]health.Check{
"redis": func(ctx context.Context) error {
return p.client.Ping(ctx).Err()
},
}
}
type HasMiddleware ¶
type HasMiddleware interface {
Middleware() map[string]router.Middleware
}
HasMiddleware allows a plugin to expose named middleware that can be assigned to routes or groups in start/kernel.go or start/routes.go.
type HasMigrations ¶
HasMigrations allows a plugin to provide database migrations that are collected and can be run alongside application migrations.
type HasRoutes ¶
HasRoutes allows a plugin to mount its own HTTP routes onto the application router during boot.
type HasSchedule ¶
HasSchedule allows a plugin to register periodic background tasks. The scheduler runs automatically when the app starts.
func (p *TelemetryPlugin) Schedule(s *schedule.Scheduler) {
s.Every(5*time.Minute, "telemetry-flush", p.flush)
}
type HasShutdown ¶
type HasShutdown interface {
Shutdown() error
}
HasShutdown allows a plugin to run cleanup logic when the application is shutting down (e.g. closing connections, flushing buffers).
type HasViews ¶
HasViews allows a plugin to supply an embedded filesystem of .nimbus templates that are layered into the view engine.
type NoSQL ¶
NoSQL is Nimbus's high-level NoSQL handle. It wraps nosql.Driver so controllers depend on *nimbus.NoSQL instead of the lower-level nosql package directly.
func GetNoSQL ¶
func GetNoSQL() *NoSQL
GetNoSQL returns the global NoSQL handle, or nil if not initialised.
func NoSQLConnection ¶
NoSQLConnection returns a named NoSQL connection wrapped in *nimbus.NoSQL. Falls back to the default NoSQL connection if the name isn't registered.
store := nimbus.NoSQLConnection("mongo")
store.Collection("users").FindOne(ctx, filter, &user)
type Plugin ¶
type Plugin interface {
// Name returns the plugin's unique identifier (e.g. "stripe", "sentry").
Name() string
// Version returns the semantic version string (e.g. "1.0.0").
Version() string
// Register is called first for all plugins. Bind services into
// app.Container here. Do not resolve other services yet.
Register(app *App) error
// Boot is called after every plugin (and provider) has registered.
// Safe to resolve container bindings and perform initialisation
// that depends on other services.
Boot(app *App) error
}
Plugin is the base contract every Nimbus plugin must satisfy. A plugin has a name, a version, and two lifecycle hooks that mirror the Provider pattern (Register → Boot).
Plugins may optionally implement one or more capability interfaces to hook into the framework at well-defined points. This design allows integrating anything — Stripe, Sentry, MongoDB, WhatsApp, etc.
Directories
¶
| Path | Synopsis |
|---|---|
|
socialite
Package socialite provides OAuth2-based social authentication (similar to Laravel Socialite).
|
Package socialite provides OAuth2-based social authentication (similar to Laravel Socialite). |
|
cmd
|
|
|
nimbus
command
Package main - plugin install command and registry.
|
Package main - plugin install command and registry. |
|
Package edge provides an edge function runtime for Nimbus.
|
Package edge provides an edge function runtime for Nimbus. |
|
Package events provides a lightweight pub/sub event dispatcher for Nimbus.
|
Package events provides a lightweight pub/sub event dispatcher for Nimbus. |
|
Package http re-exports commonly used net/http symbols so that consumers only need a single import: "github.com/CodeSyncr/nimbus/http".
|
Package http re-exports commonly used net/http symbols so that consumers only need a single import: "github.com/CodeSyncr/nimbus/http". |
|
internal
|
|
|
repl
Package repl provides an interactive Go REPL.
|
Package repl provides an interactive Go REPL. |
|
clause
Package clause re-exports GORM clause builders under the Nimbus lucid module.
|
Package clause re-exports GORM clause builders under the Nimbus lucid module. |
|
logger
Package logger re-exports GORM's logger types under the Nimbus lucid module.
|
Package logger re-exports GORM's logger types under the Nimbus lucid module. |
|
Package metrics provides a lightweight, Prometheus-compatible metrics collector for Nimbus applications.
|
Package metrics provides a lightweight, Prometheus-compatible metrics collector for Nimbus applications. |
|
Package openapi provides full OpenAPI 3.0 specification generation from Nimbus router routes.
|
Package openapi provides full OpenAPI 3.0 specification generation from Nimbus router routes. |
|
packages
|
|
|
plugins
|
|
|
admin
Package admin is a resource-based CRUD admin panel for Nimbus, modeled on Laravel Nova / Filament.
|
Package admin is a resource-based CRUD admin panel for Nimbus, modeled on Laravel Nova / Filament. |
|
cashier
Package cashier is a multi-gateway billing plugin for Nimbus, modeled on Laravel Cashier but gateway-agnostic.
|
Package cashier is a multi-gateway billing plugin for Nimbus, modeled on Laravel Cashier but gateway-agnostic. |
|
cashier/contracts
Package contracts defines the payment-gateway contract and the shared value types every gateway and the manager operate on.
|
Package contracts defines the payment-gateway contract and the shared value types every gateway and the manager operate on. |
|
cashier/events
Package events defines canonical, gateway-agnostic payment events and maps each gateway's raw webhook types onto them — so paywall logic (grant/revoke) is written once regardless of which gateway delivered the event.
|
Package events defines canonical, gateway-agnostic payment events and maps each gateway's raw webhook types onto them — so paywall logic (grant/revoke) is written once regardless of which gateway delivered the event. |
|
cashier/gateways
Package gateways holds the concrete payment gateways (Stripe, Razorpay, PayU, …).
|
Package gateways holds the concrete payment gateways (Stripe, Razorpay, PayU, …). |
|
cashier/models
Package models holds the persisted Cashier tables (transactions, subscriptions) and their migrations.
|
Package models holds the persisted Cashier tables (transactions, subscriptions) and their migrations. |
|
passport
Package passport is an OAuth2 authorization server for Nimbus, modeled on Laravel Passport.
|
Package passport is an OAuth2 authorization server for Nimbus, modeled on Laravel Passport. |
|
passport/models
Package models holds the persisted Passport (OAuth2 server) tables: clients, authorization codes, access tokens, and refresh tokens.
|
Package models holds the persisted Passport (OAuth2 server) tables: clients, authorization codes, access tokens, and refresh tokens. |
|
pulse
Package pulse provides lightweight application monitoring for Nimbus applications.
|
Package pulse provides lightweight application monitoring for Nimbus applications. |
|
Package schedule provides a lightweight cron-style task scheduler for Nimbus.
|
Package schedule provides a lightweight cron-style task scheduler for Nimbus. |
|
Package scheduler is DEPRECATED.
|
Package scheduler is DEPRECATED. |
|
Package search provides full-text search capabilities similar to Laravel Scout.
|
Package search provides full-text search capabilities similar to Laravel Scout. |
|
Package serverless adapts a Nimbus application (any http.Handler, such as app.Router) to serverless invocation models — starting with AWS Lambda.
|
Package serverless adapts a Nimbus application (any http.Handler, such as app.Router) to serverless invocation models — starting with AWS Lambda. |
|
Package shield provides AI-powered request protection middleware for Nimbus.
|
Package shield provides AI-powered request protection middleware for Nimbus. |
|
Package studio provides a built-in admin panel for Nimbus applications.
|
Package studio provides a built-in admin panel for Nimbus applications. |
|
browser
Package browser is a Dusk-style end-to-end testing harness for Nimbus.
|
Package browser is a Dusk-style end-to-end testing harness for Nimbus. |