• v1.0.0 b452ba53c8

    Rene Nochebuena released this 2026-05-29 09:47:12 -06:00 | 0 commits to main since this release

    v1.0.0

    code.nochebuena.dev/einherjar/worker


    Architecture Decisions Resolved

    Decision Outcome
    Unbounded vs bounded pool Bounded — BufferSize cap prevents unbounded memory growth under load spikes
    Dispatch behavior when full Returns false — caller decides whether to drop, queue elsewhere, or return an error
    TaskTimeout Optional (0=no deadline) — avoids imposing a default that breaks slow-but-valid tasks
    Shutdown Drain within ShutdownTimeout — in-flight tasks are allowed to complete

    API

    import "code.nochebuena.dev/einherjar/worker"
    
    // Types
    type Task func(ctx context.Context) error
    
    // Interfaces
    type Provider interface {
        Dispatch(task Task) bool
        Len() int
    }
    type Component interface {
        lifecycle.Component
        observability.Identifiable
        Provider
    }
    
    // Config
    type Config struct {
        PoolSize        int           `env:"EINHERJAR_WORKER_POOL_SIZE"        envDefault:"5"`
        BufferSize      int           `env:"EINHERJAR_WORKER_BUFFER_SIZE"      envDefault:"100"`
        TaskTimeout     time.Duration `env:"EINHERJAR_WORKER_TASK_TIMEOUT"     envDefault:"0s"`
        ShutdownTimeout time.Duration `env:"EINHERJAR_WORKER_SHUTDOWN_TIMEOUT" envDefault:"30s"`
    }
    func DefaultConfig() Config
    
    // Constructor
    func New(logger logging.Logger, cfg Config) Component
    

    Install

    go get code.nochebuena.dev/einherjar/worker@v1.0.0
    

    Dependencies

    Module Version Role
    code.nochebuena.dev/einherjar/contracts v1.0.0 lifecycle.Component, observability.Identifiable, logging.Logger
    Downloads