mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-08-03 12:56:09 -04:00
after a few rethinks, a working implementation of pushers.
This commit is contained in:
parent
88af58d41d
commit
9728c305a3
8 changed files with 158 additions and 73 deletions
|
@ -30,7 +30,7 @@ class Pusher(object):
|
|||
MAX_BACKOFF = 60 * 60 * 1000
|
||||
GIVE_UP_AFTER = 24 * 60 * 60 * 1000
|
||||
|
||||
def __init__(self, _hs, user_name, app_id, app_instance_id,
|
||||
def __init__(self, _hs, user_name, app_id,
|
||||
app_display_name, device_display_name, pushkey, data,
|
||||
last_token, last_success, failing_since):
|
||||
self.hs = _hs
|
||||
|
@ -39,7 +39,6 @@ class Pusher(object):
|
|||
self.clock = self.hs.get_clock()
|
||||
self.user_name = user_name
|
||||
self.app_id = app_id
|
||||
self.app_instance_id = app_instance_id
|
||||
self.app_display_name = app_display_name
|
||||
self.device_display_name = device_display_name
|
||||
self.pushkey = pushkey
|
||||
|
@ -48,6 +47,7 @@ class Pusher(object):
|
|||
self.last_success = last_success # not actually used
|
||||
self.backoff_delay = Pusher.INITIAL_BACKOFF
|
||||
self.failing_since = failing_since
|
||||
self.alive = True
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def start(self):
|
||||
|
@ -65,7 +65,7 @@ class Pusher(object):
|
|||
logger.info("Pusher %s for user %s starting from token %s",
|
||||
self.pushkey, self.user_name, self.last_token)
|
||||
|
||||
while True:
|
||||
while self.alive:
|
||||
from_tok = StreamToken.from_string(self.last_token)
|
||||
config = PaginationConfig(from_token=from_tok, limit='1')
|
||||
chunk = yield self.evStreamHandler.get_stream(
|
||||
|
@ -81,6 +81,9 @@ class Pusher(object):
|
|||
if not single_event:
|
||||
continue
|
||||
|
||||
if not self.alive:
|
||||
continue
|
||||
|
||||
ret = yield self.dispatch_push(single_event)
|
||||
if ret:
|
||||
self.backoff_delay = Pusher.INITIAL_BACKOFF
|
||||
|
@ -142,6 +145,9 @@ class Pusher(object):
|
|||
if self.backoff_delay > Pusher.MAX_BACKOFF:
|
||||
self.backoff_delay = Pusher.MAX_BACKOFF
|
||||
|
||||
def stop(self):
|
||||
self.alive = False
|
||||
|
||||
def dispatch_push(self, p):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue