-
Notifications
You must be signed in to change notification settings - Fork 1
Queue and Worker Registry #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| #[derive(oxanus::Registry)] | ||
| struct ComponentRegistry(oxanus::ComponentRegistry<WorkerContext, WorkerError>); |
There was a problem hiding this comment.
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.
| 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>() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
ComponentRegistryhas 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_configto construct the config object.This removes the need to manually register and thus wouldn't "forget" about them.