aa-ledger 0.9.9.1__py3-none-any.whl → 0.9.9.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.3.dist-info}/METADATA +15 -7
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.3.dist-info}/RECORD +26 -24
- ledger/__init__.py +1 -1
- ledger/decorators.py +15 -80
- ledger/locale/cs_CZ/LC_MESSAGES/django.po +16 -305
- ledger/locale/de/LC_MESSAGES/django.mo +0 -0
- ledger/locale/de/LC_MESSAGES/django.po +95 -372
- ledger/locale/django.pot +334 -304
- ledger/locale/en/LC_MESSAGES/django.po +972 -0
- ledger/locale/es/LC_MESSAGES/django.po +16 -305
- ledger/locale/fr_FR/LC_MESSAGES/django.po +16 -305
- ledger/locale/it_IT/LC_MESSAGES/django.po +16 -305
- ledger/locale/ja/LC_MESSAGES/django.po +16 -305
- ledger/locale/ko_KR/LC_MESSAGES/django.po +16 -305
- ledger/locale/nl_NL/LC_MESSAGES/django.po +16 -305
- ledger/locale/pl_PL/LC_MESSAGES/django.po +16 -305
- ledger/locale/ru/LC_MESSAGES/django.po +16 -305
- ledger/locale/sk/LC_MESSAGES/django.po +16 -305
- ledger/locale/uk/LC_MESSAGES/django.po +16 -305
- ledger/locale/zh_Hans/LC_MESSAGES/django.po +16 -305
- ledger/migrations/0017_alter_eveentity_category_alter_eveentity_eve_id_and_more.py +43 -0
- ledger/models/general.py +3 -3
- ledger/tasks.py +7 -0
- ledger/tests/test_decarators.py +33 -94
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.3.dist-info}/WHEEL +0 -0
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aa-ledger
|
|
3
|
-
Version: 0.9.9.
|
|
3
|
+
Version: 0.9.9.3
|
|
4
4
|
Summary: Character and Corporation statistics, including detailed information on ESS, Ratting, Trading, Mining, and other activities.
|
|
5
5
|
Project-URL: Changelog, https://github.com/Geuthur/aa-ledger/blob/master/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://github.com/Geuthur/aa-ledger/blob/master/README.md
|
|
@@ -720,8 +720,9 @@ Description-Content-Type: text/markdown
|
|
|
720
720
|

|
|
721
721
|
[](https://results.pre-commit.ci/latest/github/Geuthur/aa-ledger/master)
|
|
722
722
|
[](https://github.com/psf/black)
|
|
723
|
-
[](https://github.com/Geuthur/aa-ledger/actions/workflows/autotester.yml)
|
|
724
724
|
[](https://codecov.io/gh/Geuthur/aa-ledger)
|
|
725
|
+
[](https://weblate.voices-of-war.de/engage/allianceauth/)
|
|
725
726
|
|
|
726
727
|
[](https://ko-fi.com/W7W810Q5J4)
|
|
727
728
|
|
|
@@ -741,6 +742,8 @@ ______________________________________________________________________
|
|
|
741
742
|
- [Step 5 - Setting up Permissions](#step5)
|
|
742
743
|
- [Step 6 - (Optional) Settings](#step6)
|
|
743
744
|
- [Highlights](#highlights)
|
|
745
|
+
- [Translations](#translations)
|
|
746
|
+
- [Contributing](#contributing)
|
|
744
747
|
|
|
745
748
|
## Features<a name="features"></a>
|
|
746
749
|
|
|
@@ -890,8 +893,13 @@ Advanced Settings: Stale Status for Each Section
|
|
|
890
893
|

|
|
891
894
|

|
|
892
895
|
|
|
893
|
-
>
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
896
|
+
## Translations<a name="translations"></a>
|
|
897
|
+
|
|
898
|
+
[](https://weblate.voices-of-war.de/engage/allianceauth/)
|
|
899
|
+
|
|
900
|
+
Help us translate this app into your language or improve existing translations. Join our team!"
|
|
901
|
+
|
|
902
|
+
## Contributing <a name="contributing"></a>
|
|
903
|
+
|
|
904
|
+
You want to improve the project?
|
|
905
|
+
Please ensure you read the [contribution guidelines](https://github.com/Geuthur/aa-taxsystem/blob/master/CONTRIBUTING.md)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
ledger/__init__.py,sha256=
|
|
1
|
+
ledger/__init__.py,sha256=pl-C0WnKkv2TuyYfbM9B9iSjmGcFbt_b-QMyCOFHxfk,207
|
|
2
2
|
ledger/admin.py,sha256=wp6nLps1tTGHznyHBLMoRnwjnYZW1RfXOnw4TfwRWhM,9408
|
|
3
3
|
ledger/app_settings.py,sha256=r9CcNaBDo6kFOlYXXlRx3aTq1xErDz_JwJy7vM-mJNk,1363
|
|
4
4
|
ledger/apps.py,sha256=XQxXGP-1xvmQqTRJYrVIuUgCwUPOdEW3iSZaxTOYvT0,442
|
|
5
5
|
ledger/auth_hooks.py,sha256=yaOoOqfHqKoqcDm4eA-_wejIxvNIEcGa_glwHK-Sul0,1454
|
|
6
6
|
ledger/checks.py,sha256=Sq-tfUyc_OElBi9Xj71DuJXBbRU0Zqu1XDSbEtp3bPI,1474
|
|
7
7
|
ledger/constants.py,sha256=WBS7yuhBcEW9nWdj4Ieit-PolUQP_Uz393QBZFNUmvs,3662
|
|
8
|
-
ledger/decorators.py,sha256=
|
|
8
|
+
ledger/decorators.py,sha256=HCC79YwIqwFQd0Kw4dLtVcUHOqBW7V2sypb6h6TNoaQ,2177
|
|
9
9
|
ledger/errors.py,sha256=8VMvWzlpjilvC6h9WSUhBtz19oN_shRoradq5sp-G-8,495
|
|
10
10
|
ledger/forms.py,sha256=DUVd2s6D9rdyhYxoM0VXlA5PODywmpKUw5FfTBJft-w,269
|
|
11
11
|
ledger/hooks.py,sha256=ofua_eHg_ikCxaql8O7c3itSx2FyUhpeXJNH39asncA,15
|
|
12
12
|
ledger/providers.py,sha256=Ggmna3W-izQdB0AwcTkJ6tijoFFHJt-VFRwT-n1Pvhw,303
|
|
13
|
-
ledger/tasks.py,sha256=
|
|
13
|
+
ledger/tasks.py,sha256=7w1vFrD9Md2Um7_NGOiwZMXsgydoNLKaJxxV07_PtZ8,14894
|
|
14
14
|
ledger/urls.py,sha256=Zs6kkBmEdsVC7ZA2rOYjTtnfT6etQu_d4pZmPyUQg08,8419
|
|
15
15
|
ledger/api/__init__.py,sha256=GtiQ3H7rMKu_i63rp5GpHieHzVH-fWtFRHnZ6s9wS_k,655
|
|
16
16
|
ledger/api/helpers.py,sha256=SyoARfjY3hxlhbnXbVKmpbMsFXvH6k1lF2QiBmynaP0,4199
|
|
@@ -36,33 +36,34 @@ ledger/helpers/discord.py,sha256=D59TBtPHAldCCWi2j_z1CzuW6140aP2kHYvgzgYwuP0,442
|
|
|
36
36
|
ledger/helpers/etag.py,sha256=7x4balvYOypaC0jKlBbjRuETn6ol3gMBTL_363b7iVA,7421
|
|
37
37
|
ledger/helpers/ref_type.py,sha256=BnRypVpSZmBaJbULWh9URJDlHrDnqRDoynd_nDSmdCo,16413
|
|
38
38
|
ledger/locale/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
-
ledger/locale/django.pot,sha256=
|
|
39
|
+
ledger/locale/django.pot,sha256=DNwWziWMV_KoMO1cztLtos5A3bgc6aDQDtlgsLa3DlQ,26836
|
|
40
40
|
ledger/locale/cs_CZ/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
41
|
-
ledger/locale/cs_CZ/LC_MESSAGES/django.po,sha256=
|
|
42
|
-
ledger/locale/de/LC_MESSAGES/django.mo,sha256=
|
|
43
|
-
ledger/locale/de/LC_MESSAGES/django.po,sha256=
|
|
41
|
+
ledger/locale/cs_CZ/LC_MESSAGES/django.po,sha256=t4zOmyU4olRysuGqYtaoHyn8Orp52jB5CUsKuqNHcUw,8505
|
|
42
|
+
ledger/locale/de/LC_MESSAGES/django.mo,sha256=rDOXk4Xvewkagcm6DEQI-27mia_rKqypaUlJD41qObU,12151
|
|
43
|
+
ledger/locale/de/LC_MESSAGES/django.po,sha256=kvpy-noYUUhzmTYtbE_1T1yf0_zOMIC3bJ0H0dJhLGg,13204
|
|
44
|
+
ledger/locale/en/LC_MESSAGES/django.po,sha256=lJms0nrI0ff0q-8znAGdwgeEZtAypyJVBbZ0Ellcz_o,26837
|
|
44
45
|
ledger/locale/es/LC_MESSAGES/django.mo,sha256=N1pb17IfLd0ASiKO8d68-B4ygSpDkhKOCs8YTzMXQo0,380
|
|
45
|
-
ledger/locale/es/LC_MESSAGES/django.po,sha256=
|
|
46
|
+
ledger/locale/es/LC_MESSAGES/django.po,sha256=eRbGLE-1I4RhaQp4iXPC3JmixA4aOdMixJbybfHN4Bo,8552
|
|
46
47
|
ledger/locale/fr_FR/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
47
|
-
ledger/locale/fr_FR/LC_MESSAGES/django.po,sha256=
|
|
48
|
+
ledger/locale/fr_FR/LC_MESSAGES/django.po,sha256=t4zOmyU4olRysuGqYtaoHyn8Orp52jB5CUsKuqNHcUw,8505
|
|
48
49
|
ledger/locale/it_IT/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
49
|
-
ledger/locale/it_IT/LC_MESSAGES/django.po,sha256=
|
|
50
|
+
ledger/locale/it_IT/LC_MESSAGES/django.po,sha256=t4zOmyU4olRysuGqYtaoHyn8Orp52jB5CUsKuqNHcUw,8505
|
|
50
51
|
ledger/locale/ja/LC_MESSAGES/django.mo,sha256=XMj5I8Aah7EGpU-KfFOr25hoOxxLT5dfmjror1-uc8g,373
|
|
51
|
-
ledger/locale/ja/LC_MESSAGES/django.po,sha256=
|
|
52
|
+
ledger/locale/ja/LC_MESSAGES/django.po,sha256=Du2iLaidsixOSJ1OnsM4s35Et1YEZ3AP8VHrVyTwcxo,8545
|
|
52
53
|
ledger/locale/ko_KR/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
53
|
-
ledger/locale/ko_KR/LC_MESSAGES/django.po,sha256=
|
|
54
|
+
ledger/locale/ko_KR/LC_MESSAGES/django.po,sha256=t4zOmyU4olRysuGqYtaoHyn8Orp52jB5CUsKuqNHcUw,8505
|
|
54
55
|
ledger/locale/nl_NL/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
55
|
-
ledger/locale/nl_NL/LC_MESSAGES/django.po,sha256=
|
|
56
|
+
ledger/locale/nl_NL/LC_MESSAGES/django.po,sha256=t4zOmyU4olRysuGqYtaoHyn8Orp52jB5CUsKuqNHcUw,8505
|
|
56
57
|
ledger/locale/pl_PL/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
57
|
-
ledger/locale/pl_PL/LC_MESSAGES/django.po,sha256=
|
|
58
|
+
ledger/locale/pl_PL/LC_MESSAGES/django.po,sha256=t4zOmyU4olRysuGqYtaoHyn8Orp52jB5CUsKuqNHcUw,8505
|
|
58
59
|
ledger/locale/ru/LC_MESSAGES/django.mo,sha256=hs3OUHIMDSoIE9PjzkBNf97lqqo84dp6fQ_nZOMq2us,518
|
|
59
|
-
ledger/locale/ru/LC_MESSAGES/django.po,sha256=
|
|
60
|
+
ledger/locale/ru/LC_MESSAGES/django.po,sha256=DDPN0lUBSatTeDJH7UbqFlOKg5lMr1P3OcuOxEAqSr8,8696
|
|
60
61
|
ledger/locale/sk/LC_MESSAGES/django.mo,sha256=TRRRHrYeiLCvDNFGFTmkHmuh25TerdFy4jNVwPsWkzA,455
|
|
61
|
-
ledger/locale/sk/LC_MESSAGES/django.po,sha256=
|
|
62
|
+
ledger/locale/sk/LC_MESSAGES/django.po,sha256=Gx67Haqv19YmaxnZyvzll6XHPWXosVLC01C-QuItkoY,8630
|
|
62
63
|
ledger/locale/uk/LC_MESSAGES/django.mo,sha256=db3vApZ7nY3-IsGkDVAV5ckHkmwj9XGdsaB-jj90uLE,602
|
|
63
|
-
ledger/locale/uk/LC_MESSAGES/django.po,sha256=
|
|
64
|
+
ledger/locale/uk/LC_MESSAGES/django.po,sha256=iDL4l8Xdemb2IdfZW_-Kn0QNIGsnIL3l-MG8dVe8SAU,8783
|
|
64
65
|
ledger/locale/zh_Hans/LC_MESSAGES/django.mo,sha256=XMj5I8Aah7EGpU-KfFOr25hoOxxLT5dfmjror1-uc8g,373
|
|
65
|
-
ledger/locale/zh_Hans/LC_MESSAGES/django.po,sha256=
|
|
66
|
+
ledger/locale/zh_Hans/LC_MESSAGES/django.po,sha256=Du2iLaidsixOSJ1OnsM4s35Et1YEZ3AP8VHrVyTwcxo,8545
|
|
66
67
|
ledger/managers/character_audit_manager.py,sha256=UoI1aeyLLkEDo9KBgtgYYmJXtPXmxld9ARDQlcNk6Bg,6797
|
|
67
68
|
ledger/managers/character_journal_manager.py,sha256=2uEkVZ_Sp-iP68rL8s7Ia0uiT-UXHNQslxF3RfqWPdY,17482
|
|
68
69
|
ledger/managers/character_mining_manager.py,sha256=zh5wFs4RnhOTfua5AmgVeGuZFvl4pU7VuEAcaUilUGI,8182
|
|
@@ -86,11 +87,12 @@ ledger/migrations/0013_delete_events.py,sha256=BR2PfSF0dHOe3is4eKvhNlqCxjez83PXJ
|
|
|
86
87
|
ledger/migrations/0014_alter_corporationaudit_options_alter_general_options_and_more.py,sha256=K7JMWeE4akYlkST7oQX_ssZeZ9ysRYKFVqBZ6a7mViM,1537
|
|
87
88
|
ledger/migrations/0015_rename_character_characteraudit_eve_character.py,sha256=oGYc79nssnwQ1f-bCoxY7sIuWELoEewBQSWjxH2l-vc,468
|
|
88
89
|
ledger/migrations/0016_characterminingledger_price_per_unit.py,sha256=THcwqd372z0hch68hYLsy0kzA0fae6Cz4PpVaXWyEuQ,519
|
|
90
|
+
ledger/migrations/0017_alter_eveentity_category_alter_eveentity_eve_id_and_more.py,sha256=Daxv0_ki29Vb3j0J2Bb1OZFyT8WImmZS019XnApQEXQ,1222
|
|
89
91
|
ledger/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
92
|
ledger/models/__init__.py,sha256=iXAtnde1Znz1dGaFv6fAHM1bB8Ky3IuoU_U2VZoaIVc,274
|
|
91
93
|
ledger/models/characteraudit.py,sha256=4bbu9QuP8WTwxq-AZYHgi1I5OU_KjQV-1IqOQ5pOvsk,17683
|
|
92
94
|
ledger/models/corporationaudit.py,sha256=T1rleBk4cVEEj9rjrhZBn4KTsZGqIWdrhyTmZ1fm_qQ,11377
|
|
93
|
-
ledger/models/general.py,sha256=
|
|
95
|
+
ledger/models/general.py,sha256=VOuEQYvFhtDF52TB2lyLgLf1lrqJ4c7nlT9Yfmqh-VI,6660
|
|
94
96
|
ledger/models/planetary.py,sha256=XFgMYJXsYK5DBmcB7mRINP3mRD54BxTvtCLH8uCZmAA,10538
|
|
95
97
|
ledger/static/ledger/css/cards.css,sha256=eOCl9XDNJLgnXE5a84SJveu2Q5T_ZjCHD9sqhbxOxyI,2996
|
|
96
98
|
ledger/static/ledger/css/ledger.css,sha256=KA1RtKb45Q7cvzI5l0kKWm9Y4ZBizJBq69o8BEHsUZc,2056
|
|
@@ -161,7 +163,7 @@ ledger/templatetags/ledger.py,sha256=TRpJjT0YnLDzHkwf0aMKYKl9EwxJK-1QH32OKyyhtMQ
|
|
|
161
163
|
ledger/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
162
164
|
ledger/tests/test_admin.py,sha256=URLocRx_WiF1_DQwcba4EB6Qu18sfl2-gpZS1HZnvAU,8843
|
|
163
165
|
ledger/tests/test_auth_hook.py,sha256=QTheohS7syk-Hs7FZmCK4emIZhH68TfuOpLrJ1mV0LM,2007
|
|
164
|
-
ledger/tests/test_decarators.py,sha256=
|
|
166
|
+
ledger/tests/test_decarators.py,sha256=PMYA4K154z3q1r-ebuDEUqaPPsh0gf1rWIj1wJdEX_k,3095
|
|
165
167
|
ledger/tests/test_discord_installed.py,sha256=Tf-y1-RduOcxpgLNu4dDOBQKmRwJWkwx3I6JVh51Pyo,1001
|
|
166
168
|
ledger/tests/test_tasks.py,sha256=YDcklSh_QrlVaoR9CtjLM6j-241uGFXa37BizSoktd4,8576
|
|
167
169
|
ledger/tests/test_templatetags.py,sha256=KfKF1DGU8e9QofeQwai69xIvRYiaI7cEdiNrnvflUz0,1881
|
|
@@ -224,7 +226,7 @@ ledger/views/character/character_ledger.py,sha256=A8n3ela-Yv4PicXwR8c_YUpIn81WNw
|
|
|
224
226
|
ledger/views/character/planetary.py,sha256=zfcyxfs8x7B6DTZ4tViI8aO8fty94JhphTb9bd73Xr8,4459
|
|
225
227
|
ledger/views/corporation/add_corp.py,sha256=1SLMITOZ5GdBuk4VSkduaxiS5mNgP9aObsJ1SwYMUOQ,1837
|
|
226
228
|
ledger/views/corporation/corporation_ledger.py,sha256=CcRg1B1-GilF4M-6b_xlY2Qmufutoy5HRLOZgmlePzU,7357
|
|
227
|
-
aa_ledger-0.9.9.
|
|
228
|
-
aa_ledger-0.9.9.
|
|
229
|
-
aa_ledger-0.9.9.
|
|
230
|
-
aa_ledger-0.9.9.
|
|
229
|
+
aa_ledger-0.9.9.3.dist-info/METADATA,sha256=aM5f5PG0ArNttfQ-Gh3WPKsh3Z538ZPP2Mm8iymA7Ro,50785
|
|
230
|
+
aa_ledger-0.9.9.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
231
|
+
aa_ledger-0.9.9.3.dist-info/licenses/LICENSE,sha256=2oHuqnDfrjCrYAM1--Wyhv8jO3VBpnrq8zkABGzB8N8,35109
|
|
232
|
+
aa_ledger-0.9.9.3.dist-info/RECORD,,
|
ledger/__init__.py
CHANGED
ledger/decorators.py
CHANGED
|
@@ -4,14 +4,15 @@ Decorators
|
|
|
4
4
|
|
|
5
5
|
# Standard Library
|
|
6
6
|
import time
|
|
7
|
-
import uuid
|
|
8
7
|
from functools import wraps
|
|
9
8
|
|
|
9
|
+
# Django
|
|
10
|
+
from django.core.cache import cache
|
|
11
|
+
|
|
10
12
|
# Alliance Auth
|
|
11
13
|
from allianceauth.services.hooks import get_extension_logger
|
|
12
14
|
|
|
13
15
|
# Alliance Auth (External Libs)
|
|
14
|
-
from app_utils.allianceauth import get_redis_client
|
|
15
16
|
from app_utils.esi import fetch_esi_status
|
|
16
17
|
from app_utils.logging import LoggerAddTag
|
|
17
18
|
|
|
@@ -21,57 +22,16 @@ from ledger.app_settings import IS_TESTING
|
|
|
21
22
|
|
|
22
23
|
logger = LoggerAddTag(get_extension_logger(__name__), __title__)
|
|
23
24
|
|
|
25
|
+
# Use shared ESI status route rate limit from app_settings
|
|
26
|
+
ESI_STATUS_ROUTE_RATE_LIMIT = 5
|
|
27
|
+
ESI_STATUS_KEY = "esi-is-available-status"
|
|
24
28
|
|
|
25
|
-
def _esi_cache_available(redis_client, cache_key):
|
|
26
|
-
"""Return True if ESI availability cache is present. Handles Redis errors."""
|
|
27
|
-
try:
|
|
28
|
-
if redis_client.get(cache_key):
|
|
29
|
-
return True
|
|
30
|
-
except Exception: # pylint: disable=broad-except
|
|
31
|
-
# If Redis is flaky, fall through to live check
|
|
32
|
-
logger.debug("Error reading ESI cache, will attempt live check.")
|
|
33
|
-
return False
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def _acquire_lock(redis_client, lock_key, token, lock_ttl):
|
|
37
|
-
"""Try to acquire a short-lived lock in Redis. Returns True on success."""
|
|
38
|
-
try:
|
|
39
|
-
return redis_client.set(lock_key, token, nx=True, ex=lock_ttl)
|
|
40
|
-
except Exception: # pylint: disable=broad-except
|
|
41
|
-
logger.exception("Failed to acquire ESI status lock, will attempt live check.")
|
|
42
|
-
return False
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"""
|
|
50
|
-
waited = 0.0
|
|
51
|
-
poll_interval = 0.1
|
|
52
|
-
max_wait = float(lock_ttl) - 0.1
|
|
53
|
-
while waited < max_wait:
|
|
54
|
-
try:
|
|
55
|
-
# If cache was set while waiting, proceed.
|
|
56
|
-
if _esi_cache_available(redis_client, cache_key):
|
|
57
|
-
logger.debug("ESI status became available in cache while waiting.")
|
|
58
|
-
return False, True
|
|
59
|
-
|
|
60
|
-
# If the lock expired or was released, try to acquire it.
|
|
61
|
-
if not redis_client.get(lock_key):
|
|
62
|
-
try:
|
|
63
|
-
acquired = redis_client.set(lock_key, token, nx=True, ex=lock_ttl)
|
|
64
|
-
if acquired:
|
|
65
|
-
# We acquired the lock and will perform the check
|
|
66
|
-
return True, False
|
|
67
|
-
except Exception: # pylint: disable=broad-except
|
|
68
|
-
logger.debug("Failed to re-acquire lock while waiting for holder.")
|
|
69
|
-
except Exception: # pylint: disable=broad-except
|
|
70
|
-
logger.debug("Error polling ESI cache while waiting for lock holder.")
|
|
71
|
-
time.sleep(poll_interval)
|
|
72
|
-
waited += poll_interval
|
|
73
|
-
|
|
74
|
-
return False, False
|
|
30
|
+
def get_esi_available_cache() -> bool:
|
|
31
|
+
"""Return True if ESI availability cache is present."""
|
|
32
|
+
if cache.get(ESI_STATUS_KEY):
|
|
33
|
+
return True
|
|
34
|
+
return False
|
|
75
35
|
|
|
76
36
|
|
|
77
37
|
def when_esi_is_available(func):
|
|
@@ -83,42 +43,17 @@ def when_esi_is_available(func):
|
|
|
83
43
|
|
|
84
44
|
@wraps(func)
|
|
85
45
|
def outer(*args, **kwargs):
|
|
86
|
-
# During tests we skip ESI checks
|
|
87
|
-
if IS_TESTING:
|
|
88
|
-
return func(*args, **kwargs)
|
|
89
46
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# Prevent hammering ESI status endpoint
|
|
94
|
-
if _esi_cache_available(redis_client, cache_key):
|
|
95
|
-
logger.debug("ESI status cached as available.")
|
|
47
|
+
# During tests we skip ESI checks
|
|
48
|
+
if IS_TESTING or get_esi_available_cache():
|
|
49
|
+
logger.debug("Skipping ESI check (testing mode or cache present).")
|
|
96
50
|
return func(*args, **kwargs)
|
|
97
51
|
|
|
98
|
-
# Try to acquire a short-lived lock so only one process checks ESI
|
|
99
|
-
token = str(uuid.uuid4())
|
|
100
|
-
lock_key = "esi_status_lock"
|
|
101
|
-
lock_ttl = 5
|
|
102
|
-
acquired = _acquire_lock(redis_client, lock_key, token, lock_ttl)
|
|
103
|
-
|
|
104
|
-
# If we didn't get the lock, wait a short time for cache or lock
|
|
105
|
-
if not acquired:
|
|
106
|
-
acquired, cache_available = _wait_for_lock_or_cache(
|
|
107
|
-
redis_client, cache_key, lock_key, token, lock_ttl
|
|
108
|
-
)
|
|
109
|
-
if cache_available:
|
|
110
|
-
return func(*args, **kwargs)
|
|
111
|
-
|
|
112
52
|
# Check ESI status
|
|
113
53
|
if fetch_esi_status().is_ok:
|
|
114
54
|
logger.debug("ESI is available, proceeding.")
|
|
115
|
-
|
|
116
|
-
try:
|
|
117
|
-
redis_client.setex(cache_key, 5, "1")
|
|
118
|
-
except Exception: # pylint: disable=broad-except
|
|
119
|
-
logger.debug("Failed to set ESI availability cache.")
|
|
55
|
+
cache.set(ESI_STATUS_KEY, "1", timeout=ESI_STATUS_ROUTE_RATE_LIMIT)
|
|
120
56
|
return func(*args, **kwargs)
|
|
121
|
-
|
|
122
57
|
return None # function will not run
|
|
123
58
|
|
|
124
59
|
return outer
|