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)
- func WithToken(ctx context.Context, t Token) context.Context
- 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 Search
- 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 Severity
- type Signal
- type Store
- type Token
Constants ¶
This section is empty.
Variables ¶
var ( Emit = capitan.Emit Debug = capitan.Debug Info = capitan.Info Warn = capitan.Warn Error = capitan.Error )
Emission function re-exports.
var ( NewStringKey = capitan.NewStringKey NewIntKey = capitan.NewIntKey NewInt64Key = capitan.NewInt64Key NewFloat64Key = capitan.NewFloat64Key NewBoolKey = capitan.NewBoolKey NewTimeKey = capitan.NewTimeKey NewDurationKey = capitan.NewDurationKey NewErrorKey = capitan.NewErrorKey )
Field key constructor re-exports.
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.
var ErrTokenRequired = fmt.Errorf("token required")
ErrTokenRequired indicates a service requires a token but none was provided.
var NewSignal = capitan.NewSignal
NewSignal creates a signal with name and description.
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.
func MustUse ¶
MustUse retrieves a service by its contract type T. Panics if the service is not registered or a guard fails.
Types ¶
type Boundary ¶
type Boundary[T any] interface { Send(ctx context.Context, obj T) (T, error) Receive(ctx context.Context, obj T) (T, error) Store(ctx context.Context, obj T) (T, error) Load(ctx context.Context, obj T) (T, error) }
Boundary defines the serialization lifecycle operations for a type.
func NewBoundary ¶
NewBoundary creates a Boundary[T], applies shared capabilities from the Service, and registers it in the service registry under the given key. Panics if cereal.NewProcessor fails (structurally unreachable for valid Cloner types).
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 ¶
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 Handle ¶
Handle configures a registered service with optional guards. Wraps slush.Handle to provide sum-specific conveniences.
func Register ¶
Register registers a service implementation for the contract type T. Returns a Handle for optional guard configuration. Panics if Start has not been called, key is invalid, or registry is frozen.
type Search ¶
Search wraps grub.Search and registers with scio on creation. Embed this type in your store structs to add custom query methods.
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 ¶
WithCodec sets the default codec for cereal processors and the rocco engine.
func (*Service) WithEncryptor ¶
WithEncryptor registers an encryptor for the given algorithm.
func (*Service) WithHasher ¶
WithHasher registers a hasher for the given algorithm.
type ServiceInfo ¶
type ServiceInfo = slush.ServiceInfo
ServiceInfo describes a registered service for enumeration.
func Services ¶
func Services(k Key) ([]ServiceInfo, error)
Services returns information about all registered services. Returns ErrInvalidKey if the key is invalid.
type Store ¶
Store wraps grub.Store and registers with scio on creation. Embed this type in your store structs to add custom methods.