julee.repositories.memory.policy¶
Memory implementation of PolicyRepository.
This module provides an in-memory implementation of the PolicyRepository protocol that follows the Clean Architecture patterns defined in the Fun-Police Framework. It handles policy storage in memory dictionaries, ensuring idempotency and proper error handling.
The implementation uses Python dictionaries to store policy data, making it ideal for testing scenarios where external dependencies should be avoided. All operations are still async to maintain interface compatibility.
Attributes¶
Classes¶
Memory implementation of PolicyRepository using Python dictionaries. |
Module Contents¶
- class julee.repositories.memory.policy.MemoryPolicyRepository[source]¶
Bases:
julee.domain.repositories.policy.PolicyRepository,julee.repositories.memory.base.MemoryRepositoryMixin[julee.domain.models.policy.Policy]Memory implementation of PolicyRepository using Python dictionaries.
This implementation stores policy data in memory using a dictionary keyed by policy_id. This provides a lightweight, dependency-free option for testing.
- async generate_id()[source]¶
Generate a unique policy identifier.
- Returns:
Unique policy ID string
- Return type:
str
- async get(policy_id)[source]¶
Retrieve a policy by ID.
- Parameters:
policy_id (str) – Unique policy identifier
- Returns:
Policy if found, None otherwise
- Return type:
- async get_many(policy_ids)[source]¶
Retrieve multiple policies by ID.
- Parameters:
policy_ids (list[str]) – List of unique policy identifiers
- Returns:
Dict mapping policy_id to Policy (or None if not found)
- Return type:
dict[str, julee.domain.models.policy.Policy | None]
- async save(policy)[source]¶
Save a policy.
- Parameters:
policy (julee.domain.models.policy.Policy) – Complete Policy to save
- storage_dict: dict[str, julee.domain.models.policy.Policy][source]¶