Replies: 3 comments 6 replies
-
Would you use the first map like And then the second map would be like |
Beta Was this translation helpful? Give feedback.
-
Overall this sounds great! I'm not immediately sold on this:
I just doesn't strike me as an easy-win type scenario, it seems like the information stored is different. I might change my mind if I knew the code better though! |
Beta Was this translation helpful? Give feedback.
-
Going to close this discussion as the work to improve the priority plugin with the new external classes and functions has now been pretty much completed. |
Beta Was this translation helpful? Give feedback.
-
I've been playing around with improving the priority plugin over the last couple weeks, and it would be helpful for me to outline a strategy to plan how to improve the plugin over a series of pull requests that are concise and easy to review/manage. It would also be nice to step through this outline process with a partner and have another set of eyes on the design process. I'll most likely rely on @jameshcorbett to help me with this. 😄
As I see it now, the plugin suffers from a couple design decisions that I made when the plugin was first written that are the most primed for improvement:
struct bank_info
to represent a user/bank object (a user can belong to multiple banks and have different attributes & limits within each bank they belong to). This can be moved to a class that is defined elsewhere and#include
d in the plugin.I've stepped through the plugin and tried to mark which stuff can be abstracted out:
plugin.query
Below is my proposal for the steps of how I was planning on going through this improvement process for the plugin:
Association
since that is what we define as the combination of a user who belongs to a certain bank in the flux-accounting DB. This would replace the use of thebank_info
struct throughout the plugin. This can be proposed as one PR. (this has been converted to an issue plugin: create newAssociation
class #411)job.validate
In this callback, a manual lookup of a user/bank is performed using a combination of iterators that access the plugin's internal map. This sort of lookup of a user/bank is repeated numerous times throughout the plugin code.
Instead, I think I can create an external function that lives in
accounting.cpp
that does this lookup, and replace the manual lookups invalidate_cb ()
and similar callbacks with calls to this new external function. This new external function can return an address of the association in the plugin's internal map orNULL
on failure, andvalidate_cb ()
can either continue on with its job validation using this address, or reject the job on failure (because it can't find the association passed in).The other small improvement that comes with using this new external function is reading the different validation steps in the callback become a little easier to read, i.e
bank_it->second.active == 0
becomesassociation->active == 0
since we don't have to use an iterator here in the callback.This callback could also use some improvements to its comments and function description.
job.validate
#415plugin.query
This callback, designed to create a JSON object containing the contents of the plugin's data structure which contains all accounting information, uses a number of helper functions that iterate through this map and construct JSON objects of each user/bank combination. It was mentioned in #403 that these functions could be made a method as part of the new user_bank_info class.
iswas proposed in plugin: move helper functions forplugin.query
callback #417job.new
This callback can also be improved by converting the manual lookups of associations to just using external lookup functions.
job.new
#421The multiple maps that deal with user/bank information (
users
andusers_def_bank
) could be condensed into one map. This can be proposed as one PR.Documentation that is specific to flux-accounting information as it relates to the plugin should be added, i.e the structure of the proposed
Association
class and its attributes and methods. This can be proposed as one or more PRs.Any feedback or suggestions are more than welcome as I go through this improvement process!! I think multiple issues could be created to track each piece of work that is proposed above.
Beta Was this translation helpful? Give feedback.
All reactions