2828
2929MAX_EVENTS_BEHIND = 500000
3030
31- BackfillStreamRow = namedtuple (
32- "BackfillStreamRow" ,
33- (
34- "event_id" , # str
35- "room_id" , # str
36- "type" , # str
37- "state_key" , # str, optional
38- "redacts" , # str, optional
39- "relates_to" , # str, optional
40- ),
41- )
42- PresenceStreamRow = namedtuple (
43- "PresenceStreamRow" ,
44- (
45- "user_id" , # str
46- "state" , # str
47- "last_active_ts" , # int
48- "last_federation_update_ts" , # int
49- "last_user_sync_ts" , # int
50- "status_msg" , # str
51- "currently_active" , # bool
52- ),
53- )
54- TypingStreamRow = namedtuple (
55- "TypingStreamRow" , ("room_id" , "user_ids" ) # str # list(str)
56- )
57- ReceiptsStreamRow = namedtuple (
58- "ReceiptsStreamRow" ,
59- (
60- "room_id" , # str
61- "receipt_type" , # str
62- "user_id" , # str
63- "event_id" , # str
64- "data" , # dict
65- ),
66- )
67- PushRulesStreamRow = namedtuple ("PushRulesStreamRow" , ("user_id" ,)) # str
68- PushersStreamRow = namedtuple (
69- "PushersStreamRow" ,
70- ("user_id" , "app_id" , "pushkey" , "deleted" ), # str # str # str # bool
71- )
72-
73-
74- @attr .s
75- class CachesStreamRow :
76- """Stream to inform workers they should invalidate their cache.
77-
78- Attributes:
79- cache_func: Name of the cached function.
80- keys: The entry in the cache to invalidate. If None then will
81- invalidate all.
82- invalidation_ts: Timestamp of when the invalidation took place.
83- """
84-
85- cache_func = attr .ib (type = str )
86- keys = attr .ib (type = Optional [List [Any ]])
87- invalidation_ts = attr .ib (type = int )
88-
89-
90- PublicRoomsStreamRow = namedtuple (
91- "PublicRoomsStreamRow" ,
92- (
93- "room_id" , # str
94- "visibility" , # str
95- "appservice_id" , # str, optional
96- "network_id" , # str, optional
97- ),
98- )
99-
100-
101- @attr .s
102- class DeviceListsStreamRow :
103- entity = attr .ib (type = str )
104-
105-
106- ToDeviceStreamRow = namedtuple ("ToDeviceStreamRow" , ("entity" ,)) # str
107- TagAccountDataStreamRow = namedtuple (
108- "TagAccountDataStreamRow" , ("user_id" , "room_id" , "data" ) # str # str # dict
109- )
110- AccountDataStreamRow = namedtuple (
111- "AccountDataStream" , ("user_id" , "room_id" , "data_type" ) # str # str # str
112- )
113- GroupsStreamRow = namedtuple (
114- "GroupsStreamRow" ,
115- ("group_id" , "user_id" , "type" , "content" ), # str # str # str # dict
116- )
117- UserSignatureStreamRow = namedtuple ("UserSignatureStreamRow" , ("user_id" )) # str
118-
11931
12032class Stream (object ):
12133 """Base class for the streams.
@@ -234,6 +146,18 @@ class BackfillStream(Stream):
234146 or it went from being an outlier to not.
235147 """
236148
149+ BackfillStreamRow = namedtuple (
150+ "BackfillStreamRow" ,
151+ (
152+ "event_id" , # str
153+ "room_id" , # str
154+ "type" , # str
155+ "state_key" , # str, optional
156+ "redacts" , # str, optional
157+ "relates_to" , # str, optional
158+ ),
159+ )
160+
237161 NAME = "backfill"
238162 ROW_TYPE = BackfillStreamRow
239163
@@ -246,6 +170,19 @@ def __init__(self, hs):
246170
247171
248172class PresenceStream (Stream ):
173+ PresenceStreamRow = namedtuple (
174+ "PresenceStreamRow" ,
175+ (
176+ "user_id" , # str
177+ "state" , # str
178+ "last_active_ts" , # int
179+ "last_federation_update_ts" , # int
180+ "last_user_sync_ts" , # int
181+ "status_msg" , # str
182+ "currently_active" , # bool
183+ ),
184+ )
185+
249186 NAME = "presence"
250187 ROW_TYPE = PresenceStreamRow
251188
@@ -260,6 +197,10 @@ def __init__(self, hs):
260197
261198
262199class TypingStream (Stream ):
200+ TypingStreamRow = namedtuple (
201+ "TypingStreamRow" , ("room_id" , "user_ids" ) # str # list(str)
202+ )
203+
263204 NAME = "typing"
264205 ROW_TYPE = TypingStreamRow
265206
@@ -273,6 +214,17 @@ def __init__(self, hs):
273214
274215
275216class ReceiptsStream (Stream ):
217+ ReceiptsStreamRow = namedtuple (
218+ "ReceiptsStreamRow" ,
219+ (
220+ "room_id" , # str
221+ "receipt_type" , # str
222+ "user_id" , # str
223+ "event_id" , # str
224+ "data" , # dict
225+ ),
226+ )
227+
276228 NAME = "receipts"
277229 ROW_TYPE = ReceiptsStreamRow
278230
@@ -289,6 +241,8 @@ class PushRulesStream(Stream):
289241 """A user has changed their push rules
290242 """
291243
244+ PushRulesStreamRow = namedtuple ("PushRulesStreamRow" , ("user_id" ,)) # str
245+
292246 NAME = "push_rules"
293247 ROW_TYPE = PushRulesStreamRow
294248
@@ -309,6 +263,11 @@ class PushersStream(Stream):
309263 """A user has added/changed/removed a pusher
310264 """
311265
266+ PushersStreamRow = namedtuple (
267+ "PushersStreamRow" ,
268+ ("user_id" , "app_id" , "pushkey" , "deleted" ), # str # str # str # bool
269+ )
270+
312271 NAME = "pushers"
313272 ROW_TYPE = PushersStreamRow
314273
@@ -326,6 +285,21 @@ class CachesStream(Stream):
326285 the cache on the workers
327286 """
328287
288+ @attr .s
289+ class CachesStreamRow :
290+ """Stream to inform workers they should invalidate their cache.
291+
292+ Attributes:
293+ cache_func: Name of the cached function.
294+ keys: The entry in the cache to invalidate. If None then will
295+ invalidate all.
296+ invalidation_ts: Timestamp of when the invalidation took place.
297+ """
298+
299+ cache_func = attr .ib (type = str )
300+ keys = attr .ib (type = Optional [List [Any ]])
301+ invalidation_ts = attr .ib (type = int )
302+
329303 NAME = "caches"
330304 ROW_TYPE = CachesStreamRow
331305
@@ -342,6 +316,16 @@ class PublicRoomsStream(Stream):
342316 """The public rooms list changed
343317 """
344318
319+ PublicRoomsStreamRow = namedtuple (
320+ "PublicRoomsStreamRow" ,
321+ (
322+ "room_id" , # str
323+ "visibility" , # str
324+ "appservice_id" , # str, optional
325+ "network_id" , # str, optional
326+ ),
327+ )
328+
345329 NAME = "public_rooms"
346330 ROW_TYPE = PublicRoomsStreamRow
347331
@@ -359,6 +343,10 @@ class DeviceListsStream(Stream):
359343 told about a device update.
360344 """
361345
346+ @attr .s
347+ class DeviceListsStreamRow :
348+ entity = attr .ib (type = str )
349+
362350 NAME = "device_lists"
363351 ROW_TYPE = DeviceListsStreamRow
364352
@@ -375,6 +363,8 @@ class ToDeviceStream(Stream):
375363 """New to_device messages for a client
376364 """
377365
366+ ToDeviceStreamRow = namedtuple ("ToDeviceStreamRow" , ("entity" ,)) # str
367+
378368 NAME = "to_device"
379369 ROW_TYPE = ToDeviceStreamRow
380370
@@ -391,6 +381,10 @@ class TagAccountDataStream(Stream):
391381 """Someone added/removed a tag for a room
392382 """
393383
384+ TagAccountDataStreamRow = namedtuple (
385+ "TagAccountDataStreamRow" , ("user_id" , "room_id" , "data" ) # str # str # dict
386+ )
387+
394388 NAME = "tag_account_data"
395389 ROW_TYPE = TagAccountDataStreamRow
396390
@@ -407,6 +401,10 @@ class AccountDataStream(Stream):
407401 """Global or per room account data was changed
408402 """
409403
404+ AccountDataStreamRow = namedtuple (
405+ "AccountDataStream" , ("user_id" , "room_id" , "data_type" ) # str # str # str
406+ )
407+
410408 NAME = "account_data"
411409 ROW_TYPE = AccountDataStreamRow
412410
@@ -432,6 +430,11 @@ async def update_function(self, from_token, to_token, limit):
432430
433431
434432class GroupServerStream (Stream ):
433+ GroupsStreamRow = namedtuple (
434+ "GroupsStreamRow" ,
435+ ("group_id" , "user_id" , "type" , "content" ), # str # str # str # dict
436+ )
437+
435438 NAME = "groups"
436439 ROW_TYPE = GroupsStreamRow
437440
@@ -448,6 +451,8 @@ class UserSignatureStream(Stream):
448451 """A user has signed their own device with their user-signing key
449452 """
450453
454+ UserSignatureStreamRow = namedtuple ("UserSignatureStreamRow" , ("user_id" )) # str
455+
451456 NAME = "user_signature"
452457 ROW_TYPE = UserSignatureStreamRow
453458
0 commit comments