worker

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package worker starts the background job runner and registers all job handlers.

Index

Constants

View Source
const (
	JobAccounting   = "accounting"
	JobEmailReceipt = "email_receipt"
	JobStockAlert   = "stock_alert"
)

Job name constants — must match handler registrations in NewRunner.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountingPayload

type AccountingPayload struct {
	EventName string         `json:"event_name"`
	Payload   map[string]any `json:"payload"`
}

AccountingPayload is the job body for accounting journal creation (Phase 8).

type EmailReceiptPayload

type EmailReceiptPayload struct {
	OrderID       string `json:"order_id"`
	CompanyID     string `json:"company_id"`
	ReceiptNumber string `json:"receipt_number"`
	Total         int64  `json:"total"`
}

EmailReceiptPayload carries the minimum order info needed to send a receipt.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner wraps a goqite jobs.Runner with all registered job handlers.

func NewRunner

func NewRunner(
	q *goqite.Queue,
	log *slog.Logger,
	accountingSvc *accounting.Service,
	registry *plugin.Registry,
) *Runner

NewRunner creates a Runner with all job handlers registered. accountingSvc may be nil when the accounting repo is not configured (tests). registry may be nil if no plugin directory is configured.

func (*Runner) Start

func (r *Runner) Start(ctx context.Context)

Start begins polling the queue. Blocks until ctx is canceled.

type StockAlertPayload

type StockAlertPayload struct {
	ProductID string  `json:"product_id"`
	CompanyID string  `json:"company_id"`
	Quantity  float64 `json:"quantity"`
	ValueLost int64   `json:"value_lost"`
}

StockAlertPayload carries the product info emitted after a waste movement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL