Yuvipanda has submitted this change and it was merged.

Change subject: Ensure that queues do not get too long
......................................................................


Ensure that queues do not get too long

Change-Id: Icfb0689a03d5c2db8171ab375eb1ac5371db1aeb
---
M config.yaml.sample
M src/publish-clients.lua
M src/stream-receiver.py
3 files changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Yuvipanda: Verified; Looks good to me, approved



diff --git a/config.yaml.sample b/config.yaml.sample
index a311a3a..e379015 100644
--- a/config.yaml.sample
+++ b/config.yaml.sample
@@ -8,3 +8,4 @@
 stream_receiver:
     redis_prefix: "some-long-prefix-that-was-generated-by-openssl"
     clients_key: "key-to-use-to-store-clients-list"
+    max_queue_length: 512
diff --git a/src/publish-clients.lua b/src/publish-clients.lua
index 24a4926..e6efb02 100644
--- a/src/publish-clients.lua
+++ b/src/publish-clients.lua
@@ -2,5 +2,6 @@
 local count = table.getn(keys)
 for index, key in pairs(keys) do
     redis.call('lpush', key, ARGV[1])
+    redis.call('ltrim', key, 0, ARGV[2])
 end
 return count
diff --git a/src/stream-receiver.py b/src/stream-receiver.py
index fc0bde8..1ba641b 100644
--- a/src/stream-receiver.py
+++ b/src/stream-receiver.py
@@ -19,6 +19,7 @@
 REDIS_HOST = config['redis']['host']
 PREFIX = config['stream_receiver']['redis_prefix']
 CLIENTS_KEY = config['stream_receiver']['clients_key']
+MAX_QUEUE_LENGTH = config['stream_receiver']['max_queue_length']
 
 logging.basicConfig(format='%(asctime)s %(message)s', 
filename=os.path.expanduser('~/logs/stream-receiver'), level=logging.INFO)
 
@@ -43,7 +44,7 @@
     stdin, stdout, stderr = ssh.exec_command('gerrit stream-events')
     line = stdout.readline()
     while line:
-        count = publish_clients(keys=[make_key(CLIENTS_KEY)], args=[line])
+        count = publish_clients(keys=[make_key(CLIENTS_KEY)], args=[line, 
MAX_QUEUE_LENGTH])
         logging.info('Pushed to %s clients', count)
         line = stdout.readline()
     stdout.close()

-- 
To view, visit https://gerrit.wikimedia.org/r/76496
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icfb0689a03d5c2db8171ab375eb1ac5371db1aeb
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/gerrit-to-redis
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to