Commit f3801996 authored by lixiaofang's avatar lixiaofang

auto_vest

parent 96c25e9a
......@@ -23,8 +23,7 @@ from kafka.structs import TopicPartition
def kafka_consum(topic_name=None):
topic_name = settings.KAFKA_TOPIC_NAME if not topic_name else topic_name
consumser_obj = KafkaConsumer(topic_name, auto_offset_reset='largest',
bootstrap_servers=[settings.KAFKA_BROKER_LIST], enable_auto_commit=True,
consumser_obj = KafkaConsumer(topic_name, bootstrap_servers=[settings.KAFKA_BROKER_LIST], enable_auto_commit=True,
auto_commit_interval_ms=1, group_id="vest")
consumser_obj.subscribe([topic_name, ])
try:
......@@ -42,7 +41,7 @@ def kafka_consum(topic_name=None):
card_info = json.loads(msg.value)
if card_info['card_type'] == "auto_vest":
logging.info("消费到新数据了[%s,%s,%s,%s],get card_info:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key), card_info))
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key), card_info))
redis_client.hset(redis_topic_partition_name, msg.partition, msg.offset)
# 代表当天数据
current_push_time = card_info['current_push_time']
......@@ -92,8 +91,8 @@ def kafka_consum(topic_name=None):
card_info["have_comment_number"] += 1
is_success = comment(card_info)
logging.info("comment [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
# 调完接口后需要再次去拿新的push_time的时间
auto_comment_user(card_info)
......@@ -103,8 +102,8 @@ def kafka_consum(topic_name=None):
card_info["have_click_number"] += 1
is_success = click(card_info)
logging.info("click [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
auto_click_user(card_info)
......@@ -115,8 +114,8 @@ def kafka_consum(topic_name=None):
card_info["have_follow_number"] += 1
is_success = follow(card_info)
logging.info("follow [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
auto_follow_user(card_info)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment