Skip to content

Commit 6f52384

Browse files
committed
add fair semaphore
1 parent 3be98cd commit 6f52384

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/service-library/src/servicelib/redis/_semaphore_lua.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,19 @@ def _load_script(script_name: str) -> str:
2626
return script_file.read_text(encoding="utf-8").strip()
2727

2828

29+
# TODO: old
2930
ACQUIRE_SEMAPHORE_SCRIPT: Final[str] = _load_script("acquire_semaphore")
3031
RELEASE_SEMAPHORE_SCRIPT: Final[str] = _load_script("release_semaphore")
3132
RENEW_SEMAPHORE_SCRIPT: Final[str] = _load_script("renew_semaphore")
3233
COUNT_SEMAPHORE_SCRIPT: Final[str] = _load_script("count_semaphore")
3334

34-
SCRIPT_BAD_EXIT_CODE: Final[int] = 255
35+
# fair semaphore scripts (token pool based)
36+
ACQUIRE_FAIR_SEMAPHORE_V2_SCRIPT: Final[str] = _load_script("acquire_fair_semaphore_v2")
37+
RELEASE_FAIR_SEMAPHORE_V2_SCRIPT: Final[str] = _load_script("release_fair_semaphore_v2")
38+
CLEANUP_FAIR_SEMAPHORE_V2_SCRIPT: Final[str] = _load_script("cleanup_fair_semaphore_v2")
39+
RENEW_FAIR_SEMAPHORE_V2_SCRIPT: Final[str] = _load_script("renew_fair_semaphore_v2")
40+
COUNT_FAIR_SEMAPHORE_V2_SCRIPT: Final[str] = _load_script("count_fair_semaphore_v2")
41+
42+
3543
SCRIPT_OK_EXIT_CODE: Final[int] = 0
44+
SCRIPT_BAD_EXIT_CODE: Final[int] = 255

0 commit comments

Comments
 (0)