Skip to content

Commit a8e6c48

Browse files
committed
Refactored flag_utils.py away
1 parent 230ac51 commit a8e6c48

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

sentry_sdk/feature_flags.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
import sentry_sdk
2+
from sentry_sdk._lru_cache import LRUCache
3+
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from typing import TypedDict
8+
9+
FlagData = TypedDict("FlagData", {"flag": str, "result": bool})
10+
11+
12+
DEFAULT_FLAG_CAPACITY = 100
13+
14+
15+
class FlagBuffer:
16+
17+
def __init__(self, capacity):
18+
# type: (int) -> None
19+
self.buffer = LRUCache(capacity)
20+
self.capacity = capacity
21+
22+
def clear(self):
23+
# type: () -> None
24+
self.buffer = LRUCache(self.capacity)
25+
26+
def get(self):
27+
# type: () -> list[FlagData]
28+
return [{"flag": key, "result": value} for key, value in self.buffer.get_all()]
29+
30+
def set(self, flag, result):
31+
# type: (str, bool) -> None
32+
self.buffer.set(flag, result)
233

334

435
def add_feature_flag(flag, result):

sentry_sdk/flag_utils.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)