Documentation
ΒΆ
Overview ΒΆ
Package kernel is the root package for Aisphere Kernel.
Runtime capabilities are implemented in focused subpackages such as core, errorx, logx, contextx, and httpx.
Index ΒΆ
- Constants
- func MetricsFromContext(ctx context.Context) metricsx.Manager
- func NewContext(ctx context.Context, s AppInfo) context.Context
- type App
- type AppInfo
- type Option
- func AfterStart(fn func(context.Context) error) Option
- func AfterStop(fn func(context.Context) error) Option
- func BeforeStart(fn func(context.Context) error) Option
- func BeforeStop(fn func(context.Context) error) Option
- func Context(ctx context.Context) Option
- func Endpoint(endpoints ...*url.URL) Option
- func ID(id string) Option
- func Logger(logger *slog.Logger) Option
- func LogxLogger(logger logx.Logger) Option
- func Metadata(md map[string]string) Option
- func Metrics(manager metricsx.Manager) Option
- func MetricsPath(path string) Option
- func MetricsPprof(enabled bool) Option
- func MetricsSystem(enabled bool) Option
- func Name(name string) Option
- func PrometheusMetrics(addr string) Option
- func Registrar(r registry.Registrar) Option
- func RegistrarTimeout(t time.Duration) Option
- func Server(srv ...transport.Server) Option
- func Signal(sigs ...os.Signal) Option
- func StopTimeout(t time.Duration) Option
- func Version(version string) Option
Constants ΒΆ
const Release = "v0.0.0-baseline"
Release is the current kernel version.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func MetricsFromContext ΒΆ added in v0.0.6
MetricsFromContext returns the metrics manager injected by kernel.App, or a no-op manager when metrics are disabled. This keeps lifecycle hooks and component setup code independent from the concrete metrics package bootstrap.
Types ΒΆ
type App ΒΆ
type App struct {
// contains filtered or unexported fields
}
App is an application components lifecycle manager.
type AppInfo ΒΆ
type AppInfo interface {
ID() string
Name() string
Version() string
Metadata() map[string]string
Endpoint() []string
}
AppInfo is application context value.
type Option ΒΆ
type Option func(o *options)
Option is an application option.
func AfterStart ΒΆ
AfterStart run funcs after app starts
func BeforeStart ΒΆ
BeforeStart run funcs before app starts
func BeforeStop ΒΆ
BeforeStop run funcs before app stops
func Logger ΒΆ
Logger installs the application's slog logger before any lifecycle hooks or transport servers start. It also becomes logx's package default so lower-level components initialized by hooks can write to the same sink.
func LogxLogger ΒΆ added in v0.0.5
LogxLogger installs the application's logx logger before any lifecycle hooks or transport servers start. Prefer this option for new Kernel applications so dbx/cachex/authn/authz/objectstorex can share the same logger without depending on slog directly.
func Metrics ΒΆ added in v0.0.6
Metrics installs a shared metrics manager before lifecycle hooks or transport servers start. The manager is injected into kernel contexts so hooks can call metricsx.FromContext(ctx) and pass the same manager into dbx/cachex/s3/authn/authz.
func MetricsPath ΒΆ added in v0.0.6
MetricsPath changes the admin metrics path used by PrometheusMetrics. Empty or malformed values fall back to /metrics.
func MetricsPprof ΒΆ added in v0.0.6
MetricsPprof controls whether kernel's built-in metrics admin server also exposes /debug/pprof/*. It is disabled by default to avoid exposing profiling endpoints unintentionally in production.
func MetricsSystem ΒΆ added in v0.0.6
MetricsSystem controls whether standard Go runtime metrics are registered. It defaults to true when Metrics or PrometheusMetrics is used.
func PrometheusMetrics ΒΆ added in v0.0.6
PrometheusMetrics creates a Prometheus-backed metrics manager during kernel.New and optionally exposes it on a small admin HTTP server. Pass an empty addr to create and inject the manager without starting an extra server.
Typical production setup:
app := kernel.New(
kernel.Name("aihub"),
kernel.Version(version),
kernel.PrometheusMetrics(":9090"), // GET http://127.0.0.1:9090/metrics
)
func RegistrarTimeout ΒΆ
RegistrarTimeout with registrar timeout.
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
Package accessx provides a small authn + authz + audit facade for handlers.
|
Package accessx provides a small authn + authz + audit facade for handlers. |
|
Package auditx defines durable audit recording contracts.
|
Package auditx defines durable audit recording contracts. |
|
Package authn cached.go β cache decorator for Authenticator + TokenService.
|
Package authn cached.go β cache decorator for Authenticator + TokenService. |
|
callback
Package callback contains reusable HTTP helpers for browser based authn callback flows.
|
Package callback contains reusable HTTP helpers for browser based authn callback flows. |
|
casdoor
Package casdoor adapts the official Casdoor Go SDK to Kernel authn contracts.
|
Package casdoor adapts the official Casdoor Go SDK to Kernel authn contracts. |
|
Package authz defines Kernel's authorization boundary.
|
Package authz defines Kernel's authorization boundary. |
|
spicedb
Package spicedb contains SpiceDB adapter contracts and configuration for authz.
|
Package spicedb contains SpiceDB adapter contracts and configuration for authz. |
|
Package cachex provides the unified cache API for Aisphere Kernel.
|
Package cachex provides the unified cache API for Aisphere Kernel. |
|
redis
Package redis registers the "redis" driver for cachex.
|
Package redis registers the "redis" driver for cachex. |
|
cmd
|
|
|
kernel
module
|
|
|
protoc-gen-go-errors
module
|
|
|
protoc-gen-go-http
module
|
|
|
Package configx provides the unified configuration API for Aisphere Kernel.
|
Package configx provides the unified configuration API for Aisphere Kernel. |
|
Package contextx provides business-facing request context utilities for Aisphere Kernel.
|
Package contextx provides business-facing request context utilities for Aisphere Kernel. |
|
Package dbx provides the unified, batteries-included database API for Aisphere Kernel.
|
Package dbx provides the unified, batteries-included database API for Aisphere Kernel. |
|
mysql
Package mysql registers the "mysql" driver for dbx.
|
Package mysql registers the "mysql" driver for dbx. |
|
postgres
Package postgres registers the "postgres" driver for dbx.
|
Package postgres registers the "postgres" driver for dbx. |
|
proto
Package proto defines the protobuf codec.
|
Package proto defines the protobuf codec. |
|
Package errorx defines Aisphere Kernel's shared error semantics.
|
Package errorx defines Aisphere Kernel's shared error semantics. |
|
examples
|
|
|
authn-casdoor
command
Command authn-casdoor exercises Kernel authn against a real local Casdoor.
|
Command authn-casdoor exercises Kernel authn against a real local Casdoor. |
|
authz-spicedb
command
Command authz-spicedb exercises Kernel authz against a real local SpiceDB.
|
Command authz-spicedb exercises Kernel authz against a real local SpiceDB. |
|
cachex-basic
command
Package main demonstrates basic cachex usage with Redis.
|
Package main demonstrates basic cachex usage with Redis. |
|
configx-basic
command
|
|
|
configx-env
command
Package main demonstrates configx layered file + env override.
|
Package main demonstrates configx layered file + env override. |
|
configx-watch
command
Package main demonstrates configx Watch hot reload.
|
Package main demonstrates configx Watch hot reload. |
|
contextx-basic
command
Package main demonstrates contextx basic usage.
|
Package main demonstrates contextx basic usage. |
|
dbx-basic
command
Package main demonstrates the basic dbx flow with Postgres, mirroring aisphere-hub's skill.go patterns.
|
Package main demonstrates the basic dbx flow with Postgres, mirroring aisphere-hub's skill.go patterns. |
|
dbx-scenarios
command
Package main is a comprehensive scenario validator for dbx.
|
Package main is a comprehensive scenario validator for dbx. |
|
errorx-basic
command
|
|
|
errorx-http
command
Package main demonstrates a complete HTTP handler that returns errorx errors.
|
Package main demonstrates a complete HTTP handler that returns errorx errors. |
|
logx-basic
command
Package main demonstrates logx basic usage.
|
Package main demonstrates logx basic usage. |
|
logx-http
command
Package main demonstrates logx in a complete HTTP server with access log middleware, panic recovery, request-scoped fields, and dynamic level control.
|
Package main demonstrates logx in a complete HTTP server with access log middleware, panic recovery, request-scoped fields, and dynamic level control. |
|
metricsx-basic
command
Package main demonstrates metricsx basic usage.
|
Package main demonstrates metricsx basic usage. |
|
objectstorex-basic
command
Package main demonstrates basic objectstorex usage with Minio.
|
Package main demonstrates basic objectstorex usage with Minio. |
|
internal
|
|
|
group
Package group provides a sample lazy load container.
|
Package group provides a sample lazy load container. |
|
Package logx is the Aisphere Kernel logging package.
|
Package logx is the Aisphere Kernel logging package. |
|
Package metricsx provides business-facing metrics for Aisphere Kernel.
|
Package metricsx provides business-facing metrics for Aisphere Kernel. |
|
Package objectstorex provides the unified object storage API for Aisphere Kernel.
|
Package objectstorex provides the unified object storage API for Aisphere Kernel. |
|
minio
Package minio registers the "minio" driver for objectstorex.
|
Package minio registers the "minio" driver for objectstorex. |
|
Package securityx groups external configuration for authn, authz and auditx.
|
Package securityx groups external configuration for authn, authz and auditx. |