fix subscriber names, update default config

pull/20/head
Raphaël Vinot 2014-08-20 15:54:21 +02:00
parent 2485ba5df2
commit a68f5b6a0e
7 changed files with 11 additions and 9 deletions

View File

@ -30,6 +30,7 @@ class Redis_Queues(object):
self.subscriber_name = subscriber_name
self.sub_channel = self.config.get(conf_section, conf_channel)
self.redis_channel = self.sub_channel + self.subscriber_name
# Redis Queue
config_section = "Redis_Queues"
@ -61,7 +62,7 @@ class Redis_Queues(object):
self.pub_socket.send('{} {}'.format(self.pub_channel, msg))
def redis_rpop(self):
return self.r_queues.rpop(self.sub_channel + self.subscriber_name)
return self.r_queues.rpop(self.redis_channel)
def redis_queue_shutdown(self, is_queue=False):
if is_queue:
@ -72,7 +73,6 @@ class Redis_Queues(object):
return self.r_queues.srem('SHUTDOWN_FLAGS', flag)
def redis_queue_subscribe(self, publisher):
self.redis_channel = self.sub_channel + self.subscriber_name
publisher.info("Suscribed to channel {}".format(self.sub_channel))
while True:
msg = self.sub_socket.recv()

View File

@ -50,13 +50,12 @@ if __name__ == "__main__":
config_section = 'PubSub_Words'
config_channel = 'channel_0'
subscriber_name = 'pubcateg'
subscriber_name = 'categ'
h = Helper.Redis_Queues(config_section, config_channel, subscriber_name)
# Publisher
pub_config_section = 'PubSub_Categ'
h.zmq_pub(pub_config_section, None)
# SCRIPT PARSER #

View File

@ -11,7 +11,7 @@ if __name__ == "__main__":
config_section = 'PubSub_Categ'
config_channel = 'channel_0'
subscriber_name = 'creditcard_categ'
subscriber_name = 'cards'
h = Helper.Redis_Queues(config_section, config_channel, subscriber_name)
h.zmq_sub(config_section)

View File

@ -10,7 +10,7 @@ if __name__ == "__main__":
config_section = 'PubSub_Categ'
config_channel = 'channel_1'
subscriber_name = 'mails_categ'
subscriber_name = 'emails'
h = Helper.Redis_Queues(config_section, config_channel, subscriber_name)
h.zmq_sub(config_section)

View File

@ -27,7 +27,7 @@ if __name__ == "__main__":
config_section = 'PubSub_Categ'
config_channel = 'channel_2'
subscriber_name = 'onion_categ'
subscriber_name = 'tor'
h = Helper.Redis_Queues(config_section, config_channel, subscriber_name)
h.zmq_sub(config_section)

View File

@ -11,7 +11,7 @@ if __name__ == "__main__":
config_section = 'PubSub_Categ'
config_channel = 'channel_3'
subscriber_name = 'web_categ'
subscriber_name = 'urls'
h = Helper.Redis_Queues(config_section, config_channel, subscriber_name)
h.zmq_sub(config_section)

View File

@ -56,7 +56,10 @@ channel_0 = words
[PubSub_Categ]
adress = tcp://127.0.0.1:5003
#Channels are dynamic (1 channel per categ)
channel_0 = creditcard_categ
channel_1 = mails_categ
channel_2 = onion_categ
channel_3 = web_categ
[PubSub_Url]
adress = tcp://127.0.0.1:5004