Documentation
¶
Overview ¶
Package sum provides an applications framework for Go.
Index ¶
- Variables
- func Config[T any](ctx context.Context, k Key, provider fig.SecretProvider) error
- func Freeze(k Key)
- func MustUse[T any](ctx context.Context) T
- func Use[T any](ctx context.Context) (T, error)
- type Boundary
- type Bucket
- type Codec
- type Database
- type EncryptAlgo
- type Encryptor
- 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 HashAlgo
- type Hasher
- type Key
- type MaskType
- type Masker
- type Service
- func (s *Service) Catalog() *scio.Scio
- func (s *Service) Engine() *rocco.Engine
- func (s *Service) Handle(endpoints ...rocco.Endpoint)
- func (s *Service) Run(host string, port int) error
- func (s *Service) Shutdown(ctx context.Context) error
- func (s *Service) Start(host string, port int) error
- func (s *Service) Tag(name, description string)
- func (s *Service) WithCodec(codec cereal.Codec) *Service
- func (s *Service) WithEncryptor(algo cereal.EncryptAlgo, enc cereal.Encryptor) *Service
- func (s *Service) WithHasher(algo cereal.HashAlgo, h cereal.Hasher) *Service
- func (s *Service) WithMasker(mt cereal.MaskType, m cereal.Masker) *Service
- type ServiceInfo
- type Store
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 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 Freeze ¶
func Freeze(k Key)
Freeze prevents further service registration. Panics if key is invalid.
Types ¶
type Boundary ¶ added in v0.0.5
Boundary wraps a cereal Processor and auto-registers with the service registry.
type Bucket ¶
Bucket wraps grub.Bucket and registers with scio on creation. Embed this type in your store structs to add custom methods.
type Database ¶
Database wraps grub.Database and registers with scio on creation. Embed this type in your store structs to add custom query methods.
type EncryptAlgo ¶ added in v0.0.5
type EncryptAlgo = cereal.EncryptAlgo
EncryptAlgo is a re-export of cereal.EncryptAlgo.
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() *Service
New creates or returns the singleton Service. Subsequent calls return the existing instance.
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.
func (*Service) WithCodec ¶ added in v0.0.5
WithCodec sets the default codec for cereal processors and the rocco engine.
func (*Service) WithEncryptor ¶ added in v0.0.5
WithEncryptor registers an encryptor for the given algorithm.
func (*Service) WithHasher ¶ added in v0.0.5
WithHasher registers a hasher for the given algorithm.
type ServiceInfo ¶
type ServiceInfo = slush.ServiceInfo
ServiceInfo describes a registered service for enumeration.