Add configuration for lease maintenance behavior
Fixes #169 (closed)
Probably done but I'm going to integrate it w/ GridSync before saying so for sure.
Per discussion elsewhere, GridSync also/instead needs a different integration point for answering the question it has. So this is probably fine as-is (and maybe also not useful in the near term - but still maybe useful in the long term, and at least not harmful right now).
Merge request reports
Activity
Created by: codecov[bot]
Codecov Report
Merging #255 (96b752a9) into main (fe9341a9) will increase coverage by
0.09%
. The diff coverage is97.29%
. Current head 96b752a9 differs from pull request most recent head 53967252. Consider uploading reports for the commit 53967252 to get more accurate results@@ Coverage Diff @@ ## main #255 +/- ## ========================================== + Coverage 94.40% 94.49% +0.09% ========================================== Files 49 50 +1 Lines 4144 4195 +51 Branches 532 537 +5 ========================================== + Hits 3912 3964 +52 + Misses 190 187 -3 - Partials 42 44 +2
Impacted Files Coverage Δ src/_zkapauthorizer/tests/strategies.py 95.73% <83.33%> (-0.77%)
src/_zkapauthorizer/_plugin.py 87.23% <100.00%> (+0.27%)
src/_zkapauthorizer/config.py 100.00% <100.00%> (ø)
src/_zkapauthorizer/lease_maintenance.py 95.89% <100.00%> (+2.45%)
...rc/_zkapauthorizer/tests/test_lease_maintenance.py 96.37% <100.00%> (+1.60%)
src/_zkapauthorizer/tests/test_plugin.py 100.00% <100.00%> (ø)
src/_zkapauthorizer/tests/test_storage_server.py 43.96% <0.00%> (-1.08%)
src/_zkapauthorizer/tests/test_model.py 92.44% <0.00%> (-0.45%)
src/_zkapauthorizer/tests/test_storage_protocol.py 91.32% <0.00%> (+0.03%)
... and 2 more
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update fe9341a...5396725. Read the comment docs.75 ) 76 77 78 def _read_duration(cfg, option, default): 79 """ 80 Read an integer number of seconds from the ZKAPAuthorizer section of a 81 Tahoe-LAFS config. 82 83 :param cfg: The Tahoe-LAFS config object to consult. 84 :param option: The name of the option to read. 85 86 :return: ``None`` if the option is missing, otherwise the parsed duration 87 as a ``timedelta``. 88 """ 89 # type: (_Config, str) -> Optional[timedelta] 90 section_name = u"storageclient.plugins.privatestorageio-zkapauthz-v1" Created by: tomprince
This feels like a weird place for this constant. I'd prefer if this were passed in from
_plugin
. (If we had infinite time, I'd likely suggest having an object wrapping the node config, that reads from a particular section, but it probably isn't worth the effort here yet).
2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 """ 16 Helpers for reading values from the Tahoe-LAFS configuration. 17 """ Could be, yea. Since this project started it has become clear that two different plugins may have made more sense than a single plugin with such a tightly coupled implementation. We could probably try to keep the pieces as separate as possible until a more definitive decoupling happens. I'll keep it in mind for future development.
75 ) 76 77 78 def _read_duration(cfg, option, default): 79 """ 80 Read an integer number of seconds from the ZKAPAuthorizer section of a 81 Tahoe-LAFS config. 82 83 :param cfg: The Tahoe-LAFS config object to consult. 84 :param option: The name of the option to read. 85 86 :return: ``None`` if the option is missing, otherwise the parsed duration 87 as a ``timedelta``. 88 """ 89 # type: (_Config, str) -> Optional[timedelta] 90 section_name = u"storageclient.plugins.privatestorageio-zkapauthz-v1"