chronosos

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package chronosos provides the ChronosOS control plane server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.4.0

type Option func(*Server)

Option configures a Server during construction. Options are applied by NewWithOptions before routes are registered.

func WithAPIKeyAuth added in v0.4.0

func WithAPIKeyAuth(cfg auth.APIKeyConfig) Option

WithAPIKeyAuth enables API-key authentication using the given config. Health and metrics endpoints are always exempt.

func WithApproval added in v0.4.0

func WithApproval(svc *approval.Service) Option

WithApproval injects a preconfigured approval service (e.g. store-backed and authorized via approval.WithStore/WithAuthorizer). The default is an in-memory service.

func WithAuthMiddleware added in v0.4.0

func WithAuthMiddleware(mw func(http.Handler) http.Handler) Option

WithAuthMiddleware installs a custom authentication middleware. Passing a nil middleware disables authentication (the default).

func WithCORS added in v0.4.0

func WithCORS(cfg middleware.CORSConfig) Option

WithCORS overrides the CORS configuration.

func WithJWTAuth added in v0.4.0

func WithJWTAuth(cfg auth.JWTConfig) Option

WithJWTAuth enables JWT bearer-token authentication using the given config. Health and metrics endpoints are always exempt.

func WithLogger added in v0.4.0

func WithLogger(l *log.Logger) Option

WithLogger sets the request logger. A nil logger disables request logging.

func WithMaxBodyBytes added in v0.4.0

func WithMaxBodyBytes(n int64) Option

WithMaxBodyBytes overrides the maximum JSON request body size enforced via http.MaxBytesReader.

func WithMaxHeaderBytes added in v0.4.0

func WithMaxHeaderBytes(n int) Option

WithMaxHeaderBytes overrides the maximum request header size.

func WithRateLimit added in v0.4.0

func WithRateLimit(cfg middleware.RateLimitConfig) Option

WithRateLimit overrides the rate-limit configuration.

func WithRateLimiter added in v0.4.0

func WithRateLimiter(l middleware.Limiter) Option

WithRateLimiter selects the rate-limit backend. Passing a store-backed middleware.Limiter shares limits across replicas; nil keeps the per-process default.

func WithScheduler added in v0.4.0

func WithScheduler(r scheduler.Runner) Option

WithScheduler injects a scheduler implementation. The default is the in-process scheduler; pass a store-backed scheduler.StoreScheduler for exactly-once firing across replicas.

func WithStructuredLogging added in v0.4.0

func WithStructuredLogging(l *logging.Logger) Option

WithStructuredLogging installs structured JSON request logging (with a per-request correlation id) as the outermost middleware. A nil logger leaves structured logging disabled.

func WithTimeouts added in v0.4.0

func WithTimeouts(read, readHeader, write, idle time.Duration) Option

WithTimeouts overrides the http.Server timeouts. A zero value for any timeout leaves it unbounded (use with care).

func WithoutCORS added in v0.4.0

func WithoutCORS() Option

WithoutCORS disables the CORS middleware.

func WithoutRateLimit added in v0.4.0

func WithoutRateLimit() Option

WithoutRateLimit disables the rate-limit middleware.

type Server

type Server struct {
	Addr            string
	Store           storage.Storage
	Broker          *stream.Broker
	Auth            *auth.Service
	Trace           *trace.Collector
	Approval        *approval.Service
	Metrics         *metrics.Registry
	Scheduler       scheduler.Runner
	ShutdownTimeout time.Duration
	// contains filtered or unexported fields
}

Server is the ChronosOS control plane.

To feed the Metrics registry from execution, add hooks.NewPrometheusHook(s.Metrics) to the hook chain of the agents you run (agents live outside the control plane, so this is wired at agent construction). The registry is exposed at /metrics regardless.

func New

func New(addr string, store storage.Storage) *Server

New creates a new ChronosOS server with safe defaults: no authentication, CORS and rate limiting enabled, panic recovery enabled, and hardened http.Server timeouts. The signature is stable; use NewWithOptions to customize behavior.

func NewWithOptions added in v0.4.0

func NewWithOptions(addr string, store storage.Storage, opts ...Option) *Server

NewWithOptions creates a new ChronosOS server, applying the given options after defaults are set and before routes are registered.

func (*Server) Handler added in v0.4.0

func (s *Server) Handler() http.Handler

Handler composes the middleware chain around the mux. Requests flow through the chain in the order: recovery -> request-logging -> CORS -> rate-limit -> auth, then reach the route handlers.

func (*Server) SetReady added in v0.3.0

func (s *Server) SetReady(ready bool)

SetReady marks the server as ready to accept traffic.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start begins serving the control plane with graceful shutdown support. It blocks until either the context is canceled or a SIGTERM/SIGINT is received.

Directories

Path Synopsis
Package approval provides human-in-the-loop approval workflows for the ChronosOS control plane.
Package approval provides human-in-the-loop approval workflows for the ChronosOS control plane.
Package auth provides authentication and RBAC for ChronosOS.
Package auth provides authentication and RBAC for ChronosOS.
interfaces
discord
Package discord provides a Discord bot interface for Chronos agents.
Package discord provides a Discord bot interface for Chronos agents.
slack
Package slack provides a Slack bot interface for Chronos agents.
Package slack provides a Slack bot interface for Chronos agents.
telegram
Package telegram provides a Telegram bot interface for Chronos agents.
Package telegram provides a Telegram bot interface for Chronos agents.
Package logging provides structured JSON-line logging with correlation and tenant identifiers carried through context.
Package logging provides structured JSON-line logging with correlation and tenant identifiers carried through context.
Package metrics provides Prometheus-format metrics collection and export.
Package metrics provides Prometheus-format metrics collection and export.
Package middleware provides HTTP middleware for ChronosOS.
Package middleware provides HTTP middleware for ChronosOS.
Package scheduler provides cron-based scheduling for agent runs.
Package scheduler provides cron-based scheduling for agent runs.
Package trace provides execution tracing and audit logging.
Package trace provides execution tracing and audit logging.
Package webhook provides a generic webhook interface for receiving external events.
Package webhook provides a generic webhook interface for receiving external events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL