From 651658e507831a22b7dc44c06f7bddfb577f58f7 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Tue, 9 Aug 2022 19:02:48 +1000 Subject: [PATCH] JOINs and PARTs have been observed with up to 30sec difference it turns out to be completely undocumented what the max delay is. so let's assume 45s. anything > 60s might cause problems due to matching messages being more than 1 batch apart. --- chat_archiver/chat_archiver/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chat_archiver/chat_archiver/main.py b/chat_archiver/chat_archiver/main.py index 1d62172..e09b278 100644 --- a/chat_archiver/chat_archiver/main.py +++ b/chat_archiver/chat_archiver/main.py @@ -29,11 +29,14 @@ import prometheus_client as prom # How long each batch is BATCH_INTERVAL = 60 -# These are known to arrive up to 10s after their actual time +# These are known to arrive up to MAX_DELAY after their actual time DELAYED_COMMANDS = [ "JOIN", "PART", ] +# This isn't documented, but we've observed up to 30sec of delay, so we pad a little extra +# and hope it's good enough. +MAX_DELAY = 45 COMMANDS = DELAYED_COMMANDS + [ "PRIVMSG", @@ -247,9 +250,9 @@ class Archiver(object): time_range = 3 * ESTIMATED_TIME_PADDING if data['command'] in DELAYED_COMMANDS: - # might have happened 10s sooner than otherwise indicated. - timestamp -= 10 - time_range += 10 + # might have happened MAX_DELAY sooner than otherwise indicated. + timestamp -= MAX_DELAY + time_range += MAX_DELAY self.logger.debug("Message time determined as {} + up to {}".format(timestamp, time_range)) data['time'] = timestamp