[experimental] plugin: add bank info lookup helper function #371
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.
Problem
There are multiple spots in the plugin code where we need to look up user/bank information, and the code isn't super easy to read because a map iterator needs to be declared and used to look up the information in a map. IMHO, It might be easier to read and understand what is going on if this lookup was moved to a helper function.
This PR is just a proposal to see if others would agree that this might be an improvement - if others feel it looks/reads better as before, then I can just close this. 🙂 It creates a helper function,
get_bank_info ()
, that accepts abank_info
map struct iterator, userid, and a bank parameter and performs this lookup in the map. It returns a pair: a return code as well as the iterator to the user/bank map.In the spots where this new helper function is called, the same logic is retained that handles validating the user/bank information passed in, i.e rejecting the job or raising a job exception because the user/bank information passed in cannot be validated.
It might also be helpful to have a general validation function like this as a result of the conversation in flux-framework/flux-core#5409 since there's talk of potentially having a callback for job updates; it could be helpful to just call this function. 🤷♂️