Documentation
¶
Overview ¶
Package sum provides an applications framework for Go.
Index ¶
- Variables
- func Bucket[C, M any](k Key, provider grub.BucketProvider, name string, ...) error
- func Config[T any](ctx context.Context, k Key, provider fig.SecretProvider) error
- func Database[C, M any](k Key, db *sqlx.DB, table, keyCol string, renderer astql.Renderer, ...) error
- func Freeze(k Key)
- func MustUse[T any](ctx context.Context) T
- func Store[C, M any](k Key, provider grub.StoreProvider, name string, ...) error
- func Use[T any](ctx context.Context) (T, error)
- type Event
- func NewDebugEvent[T any](signal capitan.Signal) Event[T]
- func NewErrorEvent[T any](signal capitan.Signal) Event[T]
- func NewEvent[T any](signal capitan.Signal, level capitan.Severity) Event[T]
- func NewInfoEvent[T any](signal capitan.Signal) Event[T]
- func NewWarnEvent[T any](signal capitan.Signal) Event[T]
- type Guard
- type Handle
- type Key
- type Service
- func (s *Service) Catalog() *scio.Scio
- func (s *Service) Config() ServiceConfig
- func (s *Service) Engine() *rocco.Engine
- func (s *Service) Handle(endpoints ...rocco.Endpoint)
- func (s *Service) Run() error
- func (s *Service) Shutdown(ctx context.Context) error
- func (s *Service) Start() error
- func (s *Service) Tag(name, description string)
- type ServiceConfig
- type ServiceInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = slush.ErrNotFound ErrAccessDenied = slush.ErrAccessDenied ErrInvalidKey = slush.ErrInvalidKey )
Error re-exports from slush.
var ( SignalRegistered capitan.Signal = slush.SignalRegistered SignalAccessed capitan.Signal = slush.SignalAccessed SignalDenied capitan.Signal = slush.SignalDenied SignalNotFound capitan.Signal = slush.SignalNotFound )
Signal re-exports from slush.
var ( KeyInterface capitan.Key = slush.KeyInterface KeyImpl capitan.Key = slush.KeyImpl KeyError capitan.Key = slush.KeyError )
Field key re-exports from slush.
Functions ¶
func Bucket ¶
func Bucket[C, M any](k Key, provider grub.BucketProvider, name string, factory func(*grub.Bucket[M]) C) error
Bucket creates a grub.Bucket[M], passes it to the factory to obtain a C implementation, registers C with the service locator, and registers the atomic with scio.
func Config ¶
Config loads configuration of type T via fig and registers it with the service locator. Pass nil for provider if secrets are not needed. Retrieve the configuration later with Use[T](ctx).
func Database ¶
func Database[C, M any](k Key, db *sqlx.DB, table, keyCol string, renderer astql.Renderer, factory func(*grub.Database[M]) C) error
Database creates a grub.Database[M], passes it to the factory to obtain a C implementation, registers C with the service locator, and registers the atomic with scio.
func Freeze ¶
func Freeze(k Key)
Freeze prevents further service registration. Panics if key is invalid.
func MustUse ¶
MustUse retrieves a service by its contract type T. Panics if the service is not registered or a guard fails.
Types ¶
type Event ¶
type Event[T any] struct { // Signal is the underlying capitan signal. Signal capitan.Signal // Key is the typed key for extracting event data. Key capitan.GenericKey[T] // contains filtered or unexported fields }
Event provides bidirectional access to a signal with typed data. Use Emit to dispatch events and Listen to register callbacks.
func NewDebugEvent ¶
NewDebugEvent creates an Event that emits at Debug level.
func NewErrorEvent ¶
NewErrorEvent creates an Event that emits at Error level.
func NewEvent ¶
NewEvent creates an Event with the given signal and severity level. The variant is derived automatically from T via sentinel.
func NewInfoEvent ¶
NewInfoEvent creates an Event that emits at Info level.
func NewWarnEvent ¶
NewWarnEvent creates an Event that emits at Warn level.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps a rocco engine and scio catalog, providing application lifecycle.
func New ¶
func New(cfg ServiceConfig) *Service
New creates or returns the singleton Service. Subsequent calls return the existing instance, ignoring the provided config.
func (*Service) Config ¶
func (s *Service) Config() ServiceConfig
Config returns the service configuration.
func (*Service) Run ¶
Run starts the service and blocks until a shutdown signal is received. Handles SIGINT and SIGTERM, then performs graceful shutdown with a 30 second timeout.
type ServiceConfig ¶
ServiceConfig defines the service configuration.
type ServiceInfo ¶
type ServiceInfo = slush.ServiceInfo
ServiceInfo describes a registered service for enumeration.