diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-10-05 14:43:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 14:43:14 +0100 |
commit | f31f8e63198cfe46af48d788dbb294aba9155e5a (patch) | |
tree | 603352c2adac33e3348be771f54f4c8d130eb582 /synapse/events/__init__.py | |
parent | Update manhole documentation for async/await. (#8462) (diff) | |
download | synapse-f31f8e63198cfe46af48d788dbb294aba9155e5a.tar.xz |
Remove stream ordering from Metadata dict (#8452)
There's no need for it to be in the dict as well as the events table. Instead, we store it in a separate attribute in the EventInternalMetadata object, and populate that on load. This means that we can rely on it being correctly populated for any event which has been persited to the database.
Diffstat (limited to 'synapse/events/__init__.py')
-rw-r--r-- | synapse/events/__init__.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py index dc49df0812..7a51d0a22f 100644 --- a/synapse/events/__init__.py +++ b/synapse/events/__init__.py @@ -97,13 +97,16 @@ class DefaultDictProperty(DictProperty): class _EventInternalMetadata: - __slots__ = ["_dict"] + __slots__ = ["_dict", "stream_ordering"] def __init__(self, internal_metadata_dict: JsonDict): # we have to copy the dict, because it turns out that the same dict is # reused. TODO: fix that self._dict = dict(internal_metadata_dict) + # the stream ordering of this event. None, until it has been persisted. + self.stream_ordering = None # type: Optional[int] + outlier = DictProperty("outlier") # type: bool out_of_band_membership = DictProperty("out_of_band_membership") # type: bool send_on_behalf_of = DictProperty("send_on_behalf_of") # type: str @@ -113,7 +116,6 @@ class _EventInternalMetadata: redacted = DictProperty("redacted") # type: bool txn_id = DictProperty("txn_id") # type: str token_id = DictProperty("token_id") # type: str - stream_ordering = DictProperty("stream_ordering") # type: int # XXX: These are set by StreamWorkerStore._set_before_and_after. # I'm pretty sure that these are never persisted to the database, so shouldn't |