mrc-ide / rrq

:runner::runner::runner: Lightweight Redis queues
https://mrc-ide.github.io/rrq/
Other
24 stars 4 forks source link

Proof-of-concept free function interface #103

Closed richfitz closed 8 months ago

richfitz commented 8 months ago

This is a small chunk carved out of an impossibly big PR that migrated most of the functions, just showing the principle.

The idea is that the big God Class is a pain to document and a pain for users. It also fits poorly with our emerging hipercow workflows and it's hard to get meaningful chained error messages out of cli with. So instead we might look at having tonnes of free functions, so the obj$task_times(...) method will become rrq_task_times(..., controller = obj).

For use in things like hintr, passing around an explicit controller is not that annoying, so we'll do that. For use with hipercow we will automatically register a controller when the user sets up their cluster configuration and they can just omit the controller = argument.

This PR creates a simple rrq_controller2 object for now (just a list, with a print method to make this a bit opaque), along with a simple default setting/clearing function. There's an internal get_controller function that tries to do the right thing with arguments and defaults that we'll use basically everywhere. Then I've migrated over a single method task_list as rrq_task_list, along with its docs. The method version uses the new free function.

Note that no tests have changed (though there are a few new ones in this PR). This will be the pattern for follow-on PRs; I will move great tracts of the package over with the same pattern and any code using the God Class will be unaffected. Then we can put a single deprecation warning into get_controller and bump the minor version number and update code.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (9ba6cc6) 99.65% compared to head (c2c2300) 99.65%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #103 +/- ## ======================================= Coverage 99.65% 99.65% ======================================= Files 28 30 +2 Lines 2008 2040 +32 ======================================= + Hits 2001 2033 +32 Misses 7 7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.