adelabdelgawad/rust-fullstack-agents/background-jobs
Claude Code and agent skill by adelabdelgawad/rust-fullstack-agents
- community
Checking that the SKILL.md file is still in the repository.
Schedule and process background jobs in Rust+Leptos+Axum using apalis with a Postgres backend. Trigger keywords: background job, queue, worker, async task, cron, scheduled, apalis, email queue, retry, dead letter.
Install
npx vskill@latest install adelabdelgawad/rust-fullstack-agents/background-jobsSKILL.md
The same SKILL.md was published earlier as adelabdelgawad/rust-fullstack-agents/background-jobs.
Background Jobs
When to Use
- When generating any async work that must run outside the HTTP request cycle (emails,
report generation, webhooks, cleanup tasks).
- When adding a cron job (nightly cleanup, daily digest, hourly sync).
- When a server fn must enqueue work rather than do it synchronously.
- NOT for sub-millisecond in-process work — use
tokio::spawnfor fire-and-forget tasks
that don't need persistence or retry.
Core Patterns
1. Cargo Dependencies
No Redis required. Apalis uses the existing Postgres pool.
2. Job Struct
Every job is a plain serializable struct. Keep it flat — embed only the IDs and scalar data needed to reconstruct context inside the worker.
3. Job Handler Function
Data<T> is apalis's DI; inject it via .data(mailer) on WorkerBuilder.
4. Worker Registration in main.rs
setup() creates the apalis_jobs table if it does not exist. Run it before starting the Monitor.
5. Cron Jobs
6. Dispatching from a Server Fn
Server fns enqueue; workers process. Never process inside a server fn.
7. Retry and Dead Letter Queue
8. Multiple Workers in One Monitor
All workers share the same Monitor. Run the Monitor as a separate tokio::spawn task so it doesn't block the HTTP server from starting:
Anti-Patterns to Block
- Processing long work inside a server fn: blocks the HTTP thread pool; causes
request timeouts. Enqueue via storage.push(...) instead.
- `tokio::spawn` for persistent work: spawned tasks are lost on restart. Use apalis
with Postgres storage for durability.
- Embedding large blobs in job structs: job rows are stored in Postgres. Pass IDs,
not file contents or large strings. Fetch data inside the handler.
- Calling `setup()` inside the handler:
setup()is idempotent but slow. Call once
at startup, not per-request.
- No retry policy: omitting
.retry(...)means transient failures (SMTP timeout,
DB blip) permanently drop the job.
- Sharing one `PostgresStorage` instance across job types without type parameters:
each job type needs its own PostgresStorage<JobType> instance to route correctly.
Verification Hooks
Hook 1 — No long-running work in server fns
Fails when: network I/O or sleep calls appear inside #[server] bodies. Remediation: move to a job struct + handler; enqueue from the server fn.
Hook 2 — setup() called at startup, not per-request
Fails when: setup() is called outside of startup code. Remediation: move to main.rs initialization block.
Hook 3 — Job structs are Serialize + Deserialize
Fails when: a struct in src/jobs/ lacks Serialize/Deserialize derives. Remediation: add #[derive(Serialize, Deserialize)].
Hook 4 — Workers registered in Monitor
Manual check: every job type defined in src/jobs/ must have a corresponding .register(...) call on the Monitor.
References
rust-error-handling—AppError::Internalfor storage push failures in server fns.quality-gates— Step 2 (clippy) will catch unusedData<T>injections.batch-error-resolution— use when adding a new job type triggers cascading type
errors across storage setup and Monitor registration.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/rusty/skills/background-jobs/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/adelabdelgawad/rust-fullstack-agents/background-jobs)