fast-feature-storage-inmemory 0.0.1__tar.gz

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.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: fast-feature-storage-inmemory
3
+ Version: 0.0.1
4
+ Summary: In-memory storage backend for fast-feature (zero dependencies).
5
+ Author: byunjuneseok
6
+ Author-email: byunjuneseok <byunjuneseok@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Framework :: AsyncIO
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Typing :: Typed
17
+ Requires-Dist: fast-feature-core==0.0.1
18
+ Requires-Python: >=3.10
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "fast-feature-storage-inmemory"
3
+ version = "0.0.1"
4
+ description = "In-memory storage backend for fast-feature (zero dependencies)."
5
+ license = "Apache-2.0"
6
+ requires-python = ">=3.10"
7
+ authors = [
8
+ { name = "byunjuneseok", email = "byunjuneseok@gmail.com" },
9
+ ]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Framework :: AsyncIO",
13
+ "Intended Audience :: Developers",
14
+ "License :: OSI Approved :: Apache Software License",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Typing :: Typed",
20
+ ]
21
+ dependencies = [
22
+ "fast-feature-core==0.0.1",
23
+ ]
24
+
25
+ [build-system]
26
+ requires = ["uv_build>=0.11.17,<0.12.0"]
27
+ build-backend = "uv_build"
28
+
29
+ [tool.uv.build-backend]
30
+ module-name = "fast_feature.storage.inmemory"
31
+
32
+ [tool.uv.sources]
33
+ fast-feature-core = { workspace = true }
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from .repository import InMemoryFlagRepository
4
+
5
+ __all__ = ["InMemoryFlagRepository"]
@@ -0,0 +1,40 @@
1
+ from __future__ import annotations
2
+
3
+ import copy
4
+ from collections.abc import Iterable
5
+
6
+ from fast_feature.core import Flag, FlagAlreadyExistsError, FlagNotFoundError, FlagRepository
7
+
8
+
9
+ class InMemoryFlagRepository(FlagRepository):
10
+ """A dict-backed repository. Values are deep-copied so stored flags are
11
+ isolated from later mutation of the caller's objects."""
12
+
13
+ def __init__(self, flags: Iterable[Flag] | None = None) -> None:
14
+ self._flags: dict[str, Flag] = {}
15
+ for flag in flags or ():
16
+ self._flags[flag.key] = copy.deepcopy(flag)
17
+
18
+ async def get(self, key: str) -> Flag | None:
19
+ flag = self._flags.get(key)
20
+ return copy.deepcopy(flag) if flag is not None else None
21
+
22
+ async def list_all(self) -> list[Flag]:
23
+ return [copy.deepcopy(self._flags[key]) for key in sorted(self._flags)]
24
+
25
+ async def create(self, flag: Flag) -> Flag:
26
+ if flag.key in self._flags:
27
+ raise FlagAlreadyExistsError(flag.key)
28
+ self._flags[flag.key] = copy.deepcopy(flag)
29
+ return copy.deepcopy(flag)
30
+
31
+ async def update(self, flag: Flag) -> Flag:
32
+ if flag.key not in self._flags:
33
+ raise FlagNotFoundError(flag.key)
34
+ self._flags[flag.key] = copy.deepcopy(flag)
35
+ return copy.deepcopy(flag)
36
+
37
+ async def delete(self, key: str) -> None:
38
+ if key not in self._flags:
39
+ raise FlagNotFoundError(key)
40
+ del self._flags[key]