diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-10-30 11:13:58 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-10-30 11:13:58 +0000 |
commit | 7c063995123297dfd569f68e0f195cad7fa327c5 (patch) | |
tree | 2ce0eb2215707808c689ac9ea9787fff8a9c7664 /synapse/streams/config.py | |
parent | Pep8 and a few doc strings (diff) | |
parent | Fix pep8 warnings (diff) | |
download | synapse-7c063995123297dfd569f68e0f195cad7fa327c5.tar.xz |
Merge branch 'develop' into request_logging
Conflicts: synapse/config/logger.py
Diffstat (limited to 'synapse/streams/config.py')
-rw-r--r-- | synapse/streams/config.py | 23 |
1 files changed, 23 insertions, 0 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, + ) |