-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ENH] clean up component channels #2429
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
e4f3450
to
ba9fd7f
Compare
ba9fd7f
to
3c7d4c8
Compare
@@ -116,7 +117,7 @@ impl WorkerServer { | |||
Ok(()) | |||
} | |||
|
|||
pub(crate) fn set_dispatcher(&mut self, dispatcher: Box<dyn Receiver<TaskMessage>>) { | |||
pub(crate) fn set_dispatcher(&mut self, dispatcher: ComponentHandle<Dispatcher>) { |
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.
I'm fine keeping this as Box<dyn Receiver<TaskMessage>>
if that style is preferred
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.
i prefer this! nice cleanup
a398448
to
e3ab429
Compare
self.sender | ||
.send(wrap(message, tracing_context)) | ||
.await | ||
.map_err(|_| ChannelError::SendError) |
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.
was hoping to get rid of this struct and make it a type alias, but there's 3 separate places that would have to implement the same wrapping code here in that case
(and while these 4 lines are straightforward, the upcoming .request()
method will be more complex and should really only be defined once)
@@ -42,7 +43,7 @@ pub(crate) struct CompactionManager { | |||
blockfile_provider: BlockfileProvider, | |||
hnsw_index_provider: HnswIndexProvider, | |||
// Dispatcher | |||
dispatcher: Option<Box<dyn Receiver<TaskMessage>>>, | |||
dispatcher: Option<ComponentHandle<Dispatcher>>, |
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 looks so much nicer
@@ -95,7 +96,7 @@ impl CompactionManager { | |||
compaction_job: &CompactionJob, | |||
) -> Result<CompactionResponse, Box<dyn ChromaError>> { | |||
let dispatcher = match self.dispatcher { | |||
Some(ref dispatcher) => dispatcher, | |||
Some(ref dispatcher) => dispatcher.clone(), |
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.
do we need to clone here?
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.
yes, because CompactOrchestrator takes ownership
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.
Nice - have some ignorable / disagreeable nits but I think the locking changes we should make and ideally stop() doesn't have to be async then
fa17e4e
to
d764517
Compare
d764517
to
5223f71
Compare
This is a small refactor to clean up internal types around component channels. Changes include:
.clone()
dShould make the implementation of #2428 cleaner.