Open
Conversation
Split the combined Worker struct into separate Job (serialized payload) and Worker (processing logic) types. Workers now receive app context via FromContext trait instead of through the generic Context<T> parameter.
Cron jobs are enqueued with empty JSON, so the args type must be
deserializable from {}. This was previously validated at startup
via validate_cron_worker but was lost during the Job/Worker split.
Consolidate should_resurrect to live only on the Job trait, removing the duplicate from Worker. Worker::to_config now reads resurrect from Args::should_resurrect() via an Args: Job bound.
- Skip positional placeholders (starting with digit) and deduplicate named placeholders - Use emit_error instead of abort in FromContext expansion to allow continued compilation
Rename job_envelope::Job struct to JobData to avoid collision with the new worker::Job trait. Also simplify the digit check in placeholder extraction.
- Remove Processable/BoxedProcessable from public exports (internal only)
- Use Job::worker_name() instead of duplicate type_name::<W>() in config
- Remove redundant to_value(json!({})) double serialization in new_cron
- Use schedules map directly instead of building intermediate HashSet in catalog()
- Rename #[oxanus(args = ...)] attribute to #[oxanus(job = ...)]
- Default job type to {WorkerName}Job when not explicitly set
- Rename BoundJob.args field to BoundJob.job
- Remove explicit job attribute from examples/tests where convention matches
- Update MIGRATION.md and README to reflect new convention
The queue field in #[oxanus(cron(...))] was Optional, causing a runtime panic when omitted. Making it required moves this to a compile error.
FooWorker now defaults to FooJob instead of FooWorkerJob. The macro strips a trailing "Worker" from the struct name before appending "Job".
Allow max_retries and retry_delay to vary based on job data by passing &job to both Worker trait methods.
…ob-worker # Conflicts: # Cargo.lock # oxanus-web/Cargo.toml # oxanus/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces Job/Worker separation — job data (the serialized payload) is now defined in a separate struct from the worker (the processing logic).
Jobtrait (data) +Worker<Args>trait (processing) replace the old combinedWorkertraitJobContextreplacesContext<T>— no more generic context parameterContextValue::new(x)replacesContext::value(x)FromContexttrait for injecting app state into workers (auto-derived for unit and single-field structs)#[oxanus(job = MyJobType)]attribute on#[derive(oxanus::Worker)]— defaults to{WorkerName}Jobby conventionqueueis now required at compile time — previously compiled but panicked at runtime when omittedProcessable/BoxedProcessableremoved from public API (internal only)job_envelope::Jobstruct renamed toJobDatato avoid collision with the newJobtraitMIGRATION.mdMigration
Workertrait combines data + processingJobtrait (data) +Worker<Args>trait (processing)Context<T>(generic over app context)JobContext(no generic)Context::value(x)ContextValue::new(x)#[derive(Serialize, Deserialize, oxanus::Worker)]on one struct#[derive(Serialize, Deserialize)]on job,#[derive(oxanus::Worker)]on workerconfig.register_worker::<W>()config.register_worker::<W, J>()storage.enqueue(queue, MyWorker { .. })storage.enqueue(queue, MyJob { .. })See
MIGRATION.mdfor the full step-by-step guide.Test plan
Note
High Risk
Large, breaking refactor across core scheduling/execution, macro expansion, and public APIs (
enqueue,register_worker, context), with potential for subtle runtime/migration regressions despite broad test updates.Overview
Introduces a breaking Job/Worker split: job payloads now implement a new
Jobtrait, processing logic moves toWorker<Args>, andprocessreceives(&Args, &JobContext)instead of&Context<T>.Updates the runtime and registration pipeline to construct workers from app state via
FromContext(newContextValue::newwrapper), register workers asregister_worker::<W, A>(), and enqueue only job structs (withjob_envelope::Jobrenamed toJobData). Cron configuration is tightened soqueueis required at compile time and cron args must deserialize from{}.Refreshes macros, docs, examples, benches, web UI, and tests for the new API, and adds
MIGRATION.mdplus version bumps to0.10.0.Reviewed by Cursor Bugbot for commit f07f433. Bugbot is set up for automated code reviews on this repo. Configure here.