Documentation
¶
Index ¶
- func RegisterRuntimeExtension(ext RuntimeExtension)
- type GRPCServer
- type GracefulGRPCServer
- type HTTPRuntime
- func (r *HTTPRuntime) APIMux() *http.ServeMux
- func (r *HTTPRuntime) Handler() http.Handler
- func (r *HTTPRuntime) Health() *HealthRegistry
- func (r *HTTPRuntime) Metrics() *telemetry.HTTPMetrics
- func (r *HTTPRuntime) RootMux() *http.ServeMux
- func (r *HTTPRuntime) Shutdown(ctx context.Context) error
- func (r *HTTPRuntime) Startup(ctx context.Context) error
- type HTTPRuntimeConfig
- type HealthCheck
- type HealthCheckResult
- type HealthDependency
- type HealthPhase
- type HealthRegistry
- func (r *HealthRegistry) MarkShuttingDown()
- func (r *HealthRegistry) MarkStarted()
- func (r *HealthRegistry) RegisterCheck(name string, fn HealthCheck, phases ...HealthPhase)
- func (r *HealthRegistry) RegisterDependency(name string, dependency HealthDependency, phases ...HealthPhase)
- func (r *HealthRegistry) RegisterHandlers(mux *http.ServeMux)
- func (r *HealthRegistry) RegisterLiveness(name string, fn HealthCheck)
- func (r *HealthRegistry) RegisterReadiness(name string, fn HealthCheck)
- func (r *HealthRegistry) RegisterStartup(name string, fn HealthCheck)
- type HealthReport
- type Options
- type Runner
- type RuntimeExtension
- type ShutdownHook
- type StartupHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRuntimeExtension ¶
func RegisterRuntimeExtension(ext RuntimeExtension)
RegisterRuntimeExtension registers a server runtime extension.
Duplicate names are ignored to keep registration idempotent.
Types ¶
type GRPCServer ¶
type GRPCServer interface {
Start() error
Stop()
}
GRPCServer abstracts product-specific gRPC implementation.
type GracefulGRPCServer ¶
type GracefulGRPCServer interface {
GRPCServer
GracefulStop(context.Context) error
}
GracefulGRPCServer optionally supports context-aware graceful shutdown.
type HTTPRuntime ¶
type HTTPRuntime struct {
// contains filtered or unexported fields
}
HTTPRuntime wires shared health, metrics, routes, and extension lifecycle.
func MustNewHTTPRuntime ¶
func MustNewHTTPRuntime(cfg HTTPRuntimeConfig) *HTTPRuntime
MustNewHTTPRuntime is a convenience helper for bootstrapping examples/tests.
func NewHTTPRuntime ¶
func NewHTTPRuntime(cfg HTTPRuntimeConfig) (*HTTPRuntime, error)
NewHTTPRuntime creates a DenseCloud-owned shared HTTP runtime assembly.
func (*HTTPRuntime) APIMux ¶
func (r *HTTPRuntime) APIMux() *http.ServeMux
APIMux returns the /v1 API sub-mux owned by the runtime.
func (*HTTPRuntime) Handler ¶
func (r *HTTPRuntime) Handler() http.Handler
Handler returns the fully assembled root handler.
func (*HTTPRuntime) Health ¶
func (r *HTTPRuntime) Health() *HealthRegistry
Health returns the runtime's shared health registry.
func (*HTTPRuntime) Metrics ¶
func (r *HTTPRuntime) Metrics() *telemetry.HTTPMetrics
Metrics returns the runtime's shared HTTP metrics collector.
func (*HTTPRuntime) RootMux ¶
func (r *HTTPRuntime) RootMux() *http.ServeMux
RootMux returns the root mux owned by the runtime.
type HTTPRuntimeConfig ¶
type HTTPRuntimeConfig struct {
ServiceName string
RootMux *http.ServeMux
APIMux *http.ServeMux
APIBasePath string
RootMiddleware []func(http.Handler) http.Handler
APIMiddleware []func(http.Handler) http.Handler
Health *HealthRegistry
Metrics *telemetry.HTTPMetrics
MetricsPath string
DisableHealthRoutes bool
DisableMetricsRoute bool
DisableRegisteredExtensions bool
StartupHooks []StartupHook
ShutdownHooks []ShutdownHook
}
HTTPRuntimeConfig defines DenseCloud's shared HTTP chassis assembly.
type HealthCheck ¶
HealthCheck verifies runtime liveness/readiness/startup conditions.
type HealthCheckResult ¶
type HealthCheckResult struct {
Name string `json:"name"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
HealthCheckResult captures the state of a named health check.
type HealthDependency ¶
HealthDependency is implemented by dependencies that can self-check.
type HealthPhase ¶
type HealthPhase string
HealthPhase describes a shared DenseCloud health lifecycle phase.
const ( HealthPhaseLive HealthPhase = "live" HealthPhaseReady HealthPhase = "ready" HealthPhaseStartup HealthPhase = "startup" )
type HealthRegistry ¶
type HealthRegistry struct {
// contains filtered or unexported fields
}
HealthRegistry owns DenseCloud's shared health lifecycle contract.
func NewHealthRegistry ¶
func NewHealthRegistry() *HealthRegistry
NewHealthRegistry creates a registry with conservative startup defaults.
func (*HealthRegistry) MarkShuttingDown ¶
func (r *HealthRegistry) MarkShuttingDown()
MarkShuttingDown flips readiness to fail-close mode.
func (*HealthRegistry) MarkStarted ¶
func (r *HealthRegistry) MarkStarted()
MarkStarted flips startup/readiness into serviceable mode.
func (*HealthRegistry) RegisterCheck ¶
func (r *HealthRegistry) RegisterCheck(name string, fn HealthCheck, phases ...HealthPhase)
RegisterCheck registers the same check across one or more phases.
func (*HealthRegistry) RegisterDependency ¶
func (r *HealthRegistry) RegisterDependency(name string, dependency HealthDependency, phases ...HealthPhase)
RegisterDependency registers a dependency health check across one or more phases.
func (*HealthRegistry) RegisterHandlers ¶
func (r *HealthRegistry) RegisterHandlers(mux *http.ServeMux)
RegisterHandlers mounts the standard DenseCloud health endpoints.
func (*HealthRegistry) RegisterLiveness ¶
func (r *HealthRegistry) RegisterLiveness(name string, fn HealthCheck)
RegisterLiveness adds a liveness check.
func (*HealthRegistry) RegisterReadiness ¶
func (r *HealthRegistry) RegisterReadiness(name string, fn HealthCheck)
RegisterReadiness adds a readiness check.
func (*HealthRegistry) RegisterStartup ¶
func (r *HealthRegistry) RegisterStartup(name string, fn HealthCheck)
RegisterStartup adds a startup check.
type HealthReport ¶
type HealthReport struct {
Status string `json:"status"`
Phase string `json:"phase"`
Checks []HealthCheckResult `json:"checks,omitempty"`
}
HealthReport is the JSON payload returned by health endpoints.
type Options ¶
type Options struct {
HTTPServer *http.Server
GRPCServer GRPCServer
EnableGRPC bool
ShutdownTimeout time.Duration
StartupHooks []StartupHook
ShutdownHooks []ShutdownHook
}
Options define shared server runtime behavior.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner starts/stops HTTP and optional gRPC with signal-aware graceful shutdown.
func (*Runner) RunBlocking ¶
RunBlocking runs until signal, context cancellation, or server error.
type RuntimeExtension ¶
type RuntimeExtension interface {
// Name returns a stable extension identifier.
Name() string
// APIMiddleware returns middleware to apply to /v1 API routes.
APIMiddleware() []func(http.Handler) http.Handler
// RegisterRoutes lets the extension mount HTTP handlers.
//
// rootMux is the top-level server mux, apiMux is the /v1 sub-mux.
RegisterRoutes(rootMux, apiMux *http.ServeMux)
// Startup runs before serving traffic.
Startup(ctx context.Context) error
// Shutdown runs during graceful termination.
Shutdown(ctx context.Context) error
}
RuntimeExtension is an optional server extension that can inject middleware, routes, and startup/shutdown hooks at runtime.
Implementations are typically registered from separate modules via init().
func RuntimeExtensions ¶
func RuntimeExtensions() []RuntimeExtension
RuntimeExtensions returns a snapshot of all registered extensions.
type ShutdownHook ¶
ShutdownHook allows apps to close domain resources during shutdown.
type StartupHook ¶
StartupHook allows apps to initialize shared runtime resources before serving.