本文整理汇总了Python中pgq.cascade.consumer.CascadedConsumer.process_remote_event方法的典型用法代码示例。如果您正苦于以下问题:Python CascadedConsumer.process_remote_event方法的具体用法?Python CascadedConsumer.process_remote_event怎么用?Python CascadedConsumer.process_remote_event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgq.cascade.consumer.CascadedConsumer
的用法示例。
在下文中一共展示了CascadedConsumer.process_remote_event方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_remote_event
# 需要导入模块: from pgq.cascade.consumer import CascadedConsumer [as 别名]
# 或者: from pgq.cascade.consumer.CascadedConsumer import process_remote_event [as 别名]
def process_remote_event(self, src_curs, dst_curs, ev):
"""Handle cascading events.
"""
if ev.retry:
raise Exception('CascadedWorker must not get retry events')
# non cascade events send to CascadedConsumer to error out
if ev.ev_type[:4] != 'pgq.':
CascadedConsumer.process_remote_event(self, src_curs, dst_curs, ev)
return
# ignore cascade events if not main worker
if not self.main_worker:
return
# check if for right queue
t = ev.ev_type
if ev.ev_extra1 != self.pgq_queue_name and t != "pgq.tick-id":
raise Exception("bad event in queue: "+str(ev))
self.log.debug("got cascade event: %s(%s)" % (t, ev.ev_data))
st = self._worker_state
if t == "pgq.location-info":
node = ev.ev_data
loc = ev.ev_extra2
dead = ev.ev_extra3
q = "select * from pgq_node.register_location(%s, %s, %s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, node, loc, dead])
elif t == "pgq.unregister-location":
node = ev.ev_data
q = "select * from pgq_node.unregister_location(%s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, node])
elif t == "pgq.global-watermark":
if st.sync_watermark:
tick_id = int(ev.ev_data)
self.log.debug('Half-ignoring global watermark %d', tick_id)
self.real_global_wm = tick_id
elif st.process_global_wm:
tick_id = int(ev.ev_data)
q = "select * from pgq_node.set_global_watermark(%s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, tick_id])
elif t == "pgq.tick-id":
tick_id = int(ev.ev_data)
if ev.ev_extra1 == self.pgq_queue_name:
raise Exception('tick-id event for own queue?')
if st.process_tick_event:
q = "select * from pgq_node.set_partition_watermark(%s, %s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, ev.ev_extra1, tick_id])
else:
raise Exception("unknown cascade event: %s" % t)
示例2: process_remote_event
# 需要导入模块: from pgq.cascade.consumer import CascadedConsumer [as 别名]
# 或者: from pgq.cascade.consumer.CascadedConsumer import process_remote_event [as 别名]
def process_remote_event(self, src_curs, dst_curs, ev):
"""Handle cascading events.
"""
# non cascade events send to CascadedConsumer to error out
if ev.ev_type[:4] != 'pgq.':
CascadedConsumer.process_remote_event(self, src_curs, dst_curs, ev)
return
# ignore cascade events if not main worker
if not self.main_worker:
ev.tag_done()
return
# check if for right queue
t = ev.ev_type
if ev.ev_extra1 != self.pgq_queue_name and t != "pgq.tick-id":
raise Exception("bad event in queue: "+str(ev))
self.log.info("got cascade event: %s" % t)
if t == "pgq.location-info":
node = ev.ev_data
loc = ev.ev_extra2
dead = ev.ev_extra3
q = "select * from pgq_node.register_location(%s, %s, %s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, node, loc, dead])
elif t == "pgq.global-watermark":
tick_id = int(ev.ev_data)
q = "select * from pgq_node.set_global_watermark(%s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, tick_id])
elif t == "pgq.tick-id":
tick_id = int(ev.ev_data)
if ev.ev_extra1 == self.pgq_queue_name:
raise Exception('tick-id event for own queue?')
st = self._worker_state
if st.process_tick_event:
q = "select * from pgq_node.set_partition_watermark(%s, %s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, ev.ev_extra1, tick_id])
else:
raise Exception("unknown cascade event: %s" % t)
ev.tag_done()