Documentation
¶
Overview ¶
Package worker commits import, chapter, and mail work with application transactions and runs it through the shared PostgreSQL connection pool.
Index ¶
- Constants
- func FinalAttempt(ctx context.Context) bool
- type Option
- type Runtime
- func (r *Runtime) EnqueueChapters(ctx context.Context, tx bun.Tx, mediaItemID, checksum string) error
- func (r *Runtime) EnqueueImport(ctx context.Context, tx bun.Tx, albumID string) error
- func (r *Runtime) EnqueueMail(ctx context.Context, tx bun.Tx, deliveryID string) error
- func (r *Runtime) Start(ctx context.Context) error
- func (r *Runtime) Stop(ctx context.Context) error
Constants ¶
const (
DefaultMailWorkers = 5
)
Variables ¶
This section is empty.
Functions ¶
func FinalAttempt ¶
FinalAttempt tells the import use case whether a failure exhausts automatic retries. Direct execution outside the runtime is a single, final attempt.
Types ¶
type Option ¶
type Option func(*settings)
Option extends the runtime with another task on its own queue.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime shares Bun's pool and never closes it. Stop it before closing Bun.
func New ¶
func New(db *bun.DB, execute func(context.Context, string) error, options ...Option) (*Runtime, error)
New binds the use cases without executing work or starting goroutines.
func (*Runtime) EnqueueChapters ¶
func (r *Runtime) EnqueueChapters(ctx context.Context, tx bun.Tx, mediaItemID, checksum string) error
EnqueueChapters records chapter extraction for one Media Item at one checksum in the caller's transaction. An active task for the same pair is reused, and a task waiting for an automatic retry runs at once instead.
func (*Runtime) EnqueueImport ¶
EnqueueImport records work in the caller's transaction. It never executes the import; the caller must commit before workers can see it.
func (*Runtime) EnqueueMail ¶
EnqueueMail records one delivery attempt in the caller's transaction. Mail jobs are deliberately not unique in River: the delivery record decides whether work remains, and River's required "running" uniqueness would let a job orphaned by a crash block a Curator's deliberate retry until the rescuer runs. A rescued job finds the record already settled and does nothing.