Skip to content

Conversation

@tyt2y3
Copy link
Collaborator

@tyt2y3 tyt2y3 commented Jan 8, 2026

ComponentRegistry has to be in scope when Queue and Worker are derived, in which they will automatically be registered to it.

Then on runtime we can use ComponentRegistry::build_config to construct the config object.

This removes the need to manually register and thus wouldn't "forget" about them.

INFO oxanus::registry: Registering foo::QueueThrottled
INFO oxanus::registry: Registering foo::QueueTwo
INFO oxanus::registry: Registering foo::QueueOne
INFO oxanus::registry: Registering foo::WorkerInstant2
INFO oxanus::registry: Registering foo::WorkerInstant
INFO oxanus::registry: Registering foo::Worker2Sec
INFO oxanus::registry: Registering foo::Worker1Sec
INFO oxanus::launcher: Starting worker (namespace: oxanus)

Comment on lines +4 to +5
#[derive(oxanus::Registry)]
struct ComponentRegistry(oxanus::ComponentRegistry<WorkerContext, WorkerError>);
Copy link
Collaborator Author

@tyt2y3 tyt2y3 Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ComponentRegistry is a unique type owned by user's crate.

Each ComponentRegistry is unique, and would only contain types that's registered to it statically.

The derive macros generate register_component!(ComponentRegistry, TestWorker) under the hood.

Comment on lines -83 to -90
let config = oxanus::Config::new(&storage.clone())
.register_queue::<QueueOne>()
.register_queue::<QueueTwo>()
.register_queue::<QueueThrottled>()
.register_worker::<Worker1Sec>()
.register_worker::<Worker2Sec>()
.register_worker::<WorkerInstant>()
.register_worker::<WorkerInstant2>()
Copy link
Collaborator Author

@tyt2y3 tyt2y3 Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On runtime, build_config would iterate all queues and workers and build the config object.

Manual register is no longer needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the best minimal example

Base automatically changed from cron-worker to main January 10, 2026 12:25
@tyt2y3 tyt2y3 merged commit 02ecb23 into main Jan 10, 2026
2 checks passed
@tyt2y3 tyt2y3 deleted the registry branch January 10, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants