diff options
author | Erik Johnston <erik@matrix.org> | 2014-10-31 17:48:05 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-10-31 17:48:05 +0000 |
commit | b63691f6e205b4e2d2a990ff04318e4daf731e2c (patch) | |
tree | aa7a80d740c7ba8f7f5ce9fe28dc32c523746d53 /synapse/streams | |
parent | Coturn's timestamps are in seconds, not milliseconds (diff) | |
parent | Bump version numbers and change log (diff) | |
download | synapse-b63691f6e205b4e2d2a990ff04318e4daf731e2c.tar.xz |
Merge branch 'release-v0.4.2' of github.com:matrix-org/synapse v0.4.2
Diffstat (limited to 'synapse/streams')
-rw-r--r-- | synapse/streams/config.py | 23 | ||||
-rw-r--r-- | synapse/streams/events.py | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/synapse/streams/config.py b/synapse/streams/config.py index 6483ce2e25..527507e5cd 100644 --- a/synapse/streams/config.py +++ b/synapse/streams/config.py @@ -22,6 +22,19 @@ import logging logger = logging.getLogger(__name__) +class SourcePaginationConfig(object): + + """A configuration object which stores pagination parameters for a + specific event source.""" + + def __init__(self, from_key=None, to_key=None, direction='f', + limit=0): + self.from_key = from_key + self.to_key = to_key + self.direction = 'f' if direction == 'f' else 'b' + self.limit = int(limit) + + class PaginationConfig(object): """A configuration object which stores pagination parameters.""" @@ -82,3 +95,13 @@ class PaginationConfig(object): "<PaginationConfig from_tok=%s, to_tok=%s, " "direction=%s, limit=%s>" ) % (self.from_token, self.to_token, self.direction, self.limit) + + def get_source_config(self, source_name): + keyname = "%s_key" % source_name + + return SourcePaginationConfig( + from_key=getattr(self.from_token, keyname), + to_key=getattr(self.to_token, keyname) if self.to_token else None, + direction=self.direction, + limit=self.limit, + ) diff --git a/synapse/streams/events.py b/synapse/streams/events.py index 41715436b0..fb698d2d71 100644 --- a/synapse/streams/events.py +++ b/synapse/streams/events.py @@ -35,7 +35,7 @@ class NullSource(object): return defer.succeed(0) def get_pagination_rows(self, user, pagination_config, key): - return defer.succeed(([], pagination_config.from_token)) + return defer.succeed(([], pagination_config.from_key)) class EventSources(object): |