Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:4331602
Created Dec 18, 2012

What would you like to do?
example metrics worker in Python using pynsq
import nsq
import json
def metrics_write(message):
json_data = json.loads(message)
# iterate over the metrics you want to record and write
# into your downstream metrics system
if any_metrics_failed:
# this will indicate to pynsq that it should re-queue
# the message for you
return False
return True
tasks = {"metrics_write": metrics_write}
r = nsq.Reader(tasks, nsqd_tcp_addresses=[''],
topic="api_requests", channel="metrics")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment