eventsourcing 9.3.4__py3-none-any.whl → 9.4.0__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.
Potentially problematic release.
This version of eventsourcing might be problematic. Click here for more details.
- eventsourcing/__init__.py +0 -1
- eventsourcing/application.py +115 -188
- eventsourcing/cipher.py +9 -10
- eventsourcing/compressor.py +2 -6
- eventsourcing/cryptography.py +91 -0
- eventsourcing/dispatch.py +52 -11
- eventsourcing/domain.py +733 -690
- eventsourcing/interface.py +39 -32
- eventsourcing/persistence.py +412 -287
- eventsourcing/popo.py +136 -44
- eventsourcing/postgres.py +404 -187
- eventsourcing/projection.py +428 -0
- eventsourcing/sqlite.py +167 -55
- eventsourcing/system.py +253 -341
- eventsourcing/tests/__init__.py +3 -0
- eventsourcing/tests/application.py +195 -129
- eventsourcing/tests/domain.py +19 -37
- eventsourcing/tests/persistence.py +533 -235
- eventsourcing/tests/postgres_utils.py +12 -9
- eventsourcing/utils.py +39 -47
- {eventsourcing-9.3.4.dist-info → eventsourcing-9.4.0.dist-info}/LICENSE +1 -1
- {eventsourcing-9.3.4.dist-info → eventsourcing-9.4.0.dist-info}/METADATA +14 -13
- eventsourcing-9.4.0.dist-info/RECORD +26 -0
- {eventsourcing-9.3.4.dist-info → eventsourcing-9.4.0.dist-info}/WHEEL +1 -1
- eventsourcing-9.3.4.dist-info/RECORD +0 -24
- {eventsourcing-9.3.4.dist-info → eventsourcing-9.4.0.dist-info}/AUTHORS +0 -0
eventsourcing/interface.py
CHANGED
|
@@ -3,50 +3,50 @@ from __future__ import annotations
|
|
|
3
3
|
import json
|
|
4
4
|
from abc import ABC, abstractmethod
|
|
5
5
|
from base64 import b64decode, b64encode
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import TYPE_CHECKING, Generic
|
|
7
7
|
from uuid import UUID
|
|
8
8
|
|
|
9
9
|
from eventsourcing.application import NotificationLog, Section, TApplication
|
|
10
10
|
from eventsourcing.persistence import Notification
|
|
11
11
|
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from collections.abc import Sequence
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
class NotificationLogInterface(ABC):
|
|
14
|
-
"""
|
|
15
|
-
Abstract base class for obtaining serialised
|
|
17
|
+
"""Abstract base class for obtaining serialised
|
|
16
18
|
sections of a notification log.
|
|
17
19
|
"""
|
|
18
20
|
|
|
19
21
|
@abstractmethod
|
|
20
22
|
def get_log_section(self, section_id: str) -> str:
|
|
21
|
-
"""
|
|
22
|
-
Returns a serialised :class:`~eventsourcing.application.Section`
|
|
23
|
+
"""Returns a serialised :class:`~eventsourcing.application.Section`
|
|
23
24
|
from a notification log.
|
|
24
25
|
"""
|
|
25
26
|
|
|
26
27
|
@abstractmethod
|
|
27
28
|
def get_notifications(
|
|
28
|
-
self,
|
|
29
|
+
self,
|
|
30
|
+
start: int | None,
|
|
31
|
+
limit: int,
|
|
32
|
+
topics: Sequence[str] = (),
|
|
33
|
+
*,
|
|
34
|
+
inclusive_of_start: bool = True,
|
|
29
35
|
) -> str:
|
|
30
|
-
"""
|
|
31
|
-
Returns a serialised list of :class:`~eventsourcing.persistence.Notification`
|
|
36
|
+
"""Returns a serialised list of :class:`~eventsourcing.persistence.Notification`
|
|
32
37
|
objects from a notification log.
|
|
33
38
|
"""
|
|
34
39
|
|
|
35
40
|
|
|
36
41
|
class NotificationLogJSONService(NotificationLogInterface, Generic[TApplication]):
|
|
37
|
-
"""
|
|
38
|
-
Presents serialised sections of a notification log.
|
|
39
|
-
"""
|
|
42
|
+
"""Presents serialised sections of a notification log."""
|
|
40
43
|
|
|
41
44
|
def __init__(self, app: TApplication):
|
|
42
|
-
"""
|
|
43
|
-
Initialises service with given application.
|
|
44
|
-
"""
|
|
45
|
+
"""Initialises service with given application."""
|
|
45
46
|
self.app = app
|
|
46
47
|
|
|
47
48
|
def get_log_section(self, section_id: str) -> str:
|
|
48
|
-
"""
|
|
49
|
-
Returns JSON serialised :class:`~eventsourcing.application.Section`
|
|
49
|
+
"""Returns JSON serialised :class:`~eventsourcing.application.Section`
|
|
50
50
|
from a notification log.
|
|
51
51
|
"""
|
|
52
52
|
section = self.app.notification_log[section_id]
|
|
@@ -68,10 +68,18 @@ class NotificationLogJSONService(NotificationLogInterface, Generic[TApplication]
|
|
|
68
68
|
)
|
|
69
69
|
|
|
70
70
|
def get_notifications(
|
|
71
|
-
self,
|
|
71
|
+
self,
|
|
72
|
+
start: int | None,
|
|
73
|
+
limit: int,
|
|
74
|
+
topics: Sequence[str] = (),
|
|
75
|
+
*,
|
|
76
|
+
inclusive_of_start: bool = True,
|
|
72
77
|
) -> str:
|
|
73
78
|
notifications = self.app.notification_log.select(
|
|
74
|
-
start=start,
|
|
79
|
+
start=start,
|
|
80
|
+
limit=limit,
|
|
81
|
+
topics=topics,
|
|
82
|
+
inclusive_of_start=inclusive_of_start,
|
|
75
83
|
)
|
|
76
84
|
return json.dumps(
|
|
77
85
|
[
|
|
@@ -88,19 +96,14 @@ class NotificationLogJSONService(NotificationLogInterface, Generic[TApplication]
|
|
|
88
96
|
|
|
89
97
|
|
|
90
98
|
class NotificationLogJSONClient(NotificationLog):
|
|
91
|
-
"""
|
|
92
|
-
Presents deserialized sections of a notification log.
|
|
93
|
-
"""
|
|
99
|
+
"""Presents deserialized sections of a notification log."""
|
|
94
100
|
|
|
95
101
|
def __init__(self, interface: NotificationLogInterface):
|
|
96
|
-
"""
|
|
97
|
-
Initialises log with a given interface.
|
|
98
|
-
"""
|
|
102
|
+
"""Initialises log with a given interface."""
|
|
99
103
|
self.interface = interface
|
|
100
104
|
|
|
101
105
|
def __getitem__(self, section_id: str) -> Section:
|
|
102
|
-
"""
|
|
103
|
-
Returns a :class:`Section` of
|
|
106
|
+
"""Returns a :class:`Section` of
|
|
104
107
|
:class:`~eventsourcing.persistence.Notification` objects
|
|
105
108
|
from the notification log.
|
|
106
109
|
"""
|
|
@@ -123,13 +126,14 @@ class NotificationLogJSONClient(NotificationLog):
|
|
|
123
126
|
|
|
124
127
|
def select(
|
|
125
128
|
self,
|
|
126
|
-
start: int,
|
|
129
|
+
start: int | None,
|
|
127
130
|
limit: int,
|
|
128
|
-
|
|
131
|
+
stop: int | None = None,
|
|
129
132
|
topics: Sequence[str] = (),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
*,
|
|
134
|
+
inclusive_of_start: bool = True,
|
|
135
|
+
) -> list[Notification]:
|
|
136
|
+
"""Returns a selection of
|
|
133
137
|
:class:`~eventsourcing.persistence.Notification` objects
|
|
134
138
|
from the notification log.
|
|
135
139
|
"""
|
|
@@ -143,7 +147,10 @@ class NotificationLogJSONClient(NotificationLog):
|
|
|
143
147
|
)
|
|
144
148
|
for item in json.loads(
|
|
145
149
|
self.interface.get_notifications(
|
|
146
|
-
start=start,
|
|
150
|
+
start=start,
|
|
151
|
+
limit=limit,
|
|
152
|
+
topics=topics,
|
|
153
|
+
inclusive_of_start=inclusive_of_start,
|
|
147
154
|
)
|
|
148
155
|
)
|
|
149
156
|
]
|