Skip to content

Implement TaskSpec registry pattern as task-type source of truth #258

@tayebmokni

Description

@tayebmokni

Summary

Implement the TaskSpec task-registry pattern from §3.1. The map registry[taskType] -> TaskSpec{Type, Queue, MaxRetry, Timeout, RetryDelay, UniqueTTL, Idempotent, HumanName} is the single source of truth for queue assignment, retry policy, timeout, and idempotency strategy. Enqueue API resolves the spec and applies its options unless explicitly overridden. The §3 catalog table is encoded here.

Design reference

  • docs/12-jobs-cron.md §3 (Task type catalog) and §3.1 (Registry pattern)

Acceptance criteria

  • internal/jobs/tasktypes.go exports TaskSpec struct and Spec(taskType) (TaskSpec, bool)
  • The §3 catalog encoded: email.send, email.password_reset, email.verify, email.comment_notify, webhook.deliver, cache.invalidate.tag_fanout, cache.warmup, media.variant.generate, media.video.transcode, media.thumbnail.extract, media.cleanup.orphans, media.cleanup.cold_variants, revalidate.next, migrate.batch.posts/media/users, migrate.verify, audit.archive, auth.session.cleanup, auth.token.cleanup, auth.brute_force.unlock, search.reindex.post/term/comment/full, revisions.purge, autosave.purge, rum.aggregate, plugin.activate/deactivate/uninstall.cleanup, plugin.cron.tick, webhook.retry.dlq.scan
  • Helper exp(base, max) produces the §5.1 jittered exponential backoff func
  • Per-type Idempotent flag drives the compensation requirement in handlers
  • Enqueue helper resolves spec, applies Queue/MaxRetry/Timeout/RetryDelay/UniqueTTL, allows explicit overrides
  • Lint: handler registration must reference a name that exists in the registry
  • Unit tests confirm every registry entry's queue exists in the queue topology (Stand up Asynq server skeleton with seven weighted queues #256)

Dependencies

#256

Complexity

M

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:jobsBackground jobs, cronphase:P1-cms-corePhase 1 — CMS Corepriority:P1Important — should land in phaseskill:goGo programmingtype:featNew feature or implementation task

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions