-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add new ModuleRuntime::list_with_details
#503
Conversation
Some of the existing code used `ModuleRuntime::list` to list all modules, then called `Module::runtime_state` for each of them. This can fail if a module is deleted after it's returned in the `list` result and before its `runtime_state` is called. The new `list_with_details` API filters out those modules whose `runtime_state` fails with `NotFound`.
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.
LGTM
.map(|module| module.runtime_state().map(|state| (module, state))), | ||
) | ||
}).flatten() | ||
.then(Ok::<_, Error>) // Ok(_) -> Ok(Ok(_)), Err(_) -> Ok(Err(_)), ! -> Err(_) |
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.
Took a while for me to understand what's going on there! :)
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.
Looks good. Curious though as to why you decided to change the implementation from using a Stream
impl to a combinator based one.
I'd written the custom impl because I'd forgotten about the "lift with |
Ah. Got it. |
Some of the existing code used
ModuleRuntime::list
to list all modules,then called
Module::runtime_state
for each of them. This can fail if amodule is deleted after it's returned in the
list
result and beforeits
runtime_state
is called.The new
list_with_details
API filters out those modules whoseruntime_state
fails withNotFound
.