mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:16:07 -04:00
Add parse_row method to replication stream class
This will allow individual stream classes to override how a row is parsed.
This commit is contained in:
parent
91c3513668
commit
f570916a3e
3 changed files with 19 additions and 3 deletions
|
@ -115,6 +115,21 @@ class Stream(object):
|
|||
ROW_TYPE = None # The type of the row
|
||||
_LIMITED = True # Whether the update function takes a limit
|
||||
|
||||
@classmethod
|
||||
def parse_row(cls, row):
|
||||
"""Parse a row received over replication
|
||||
|
||||
By default, assumes that the row data is an array object and passes its contents
|
||||
to the constructor of the ROW_TYPE for this stream.
|
||||
|
||||
Args:
|
||||
row: row data from the incoming RDATA command, after json decoding
|
||||
|
||||
Returns:
|
||||
ROW_TYPE object for this stream
|
||||
"""
|
||||
return cls.ROW_TYPE(*row)
|
||||
|
||||
def __init__(self, hs):
|
||||
# The token from which we last asked for updates
|
||||
self.last_token = self.current_token()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue