예제 #1
0
def connect_to_db():
    global kafka
    print "Connecting to cassandra"
    try:
        connect_cassandra()
    except Exception as e:
        print e

    print "Connecting to kafka"
    kafka = connect_kafka()
    print "done with connecting"
예제 #2
0
def connect_to_db():
    global kafka
    print "Connecting to cassandra"
    try:
        connect_cassandra()
    except Exception as e:
        print e

    print "Connecting to kafka"
    kafka = connect_kafka()
    print "done with connecting"
예제 #3
0
def stream_ws(ws):
    global kafka
    # get the stream_id we're going to follow
    msg = ws.receive()
    topic = "live_updates.{}".format(msg)

    from uuid import uuid4

    kafka = connect_kafka()
    consumer = SimpleConsumer(kafka, None, topic, auto_commit=False)

    while True:
        print "Fetching"
        try:
            msg = consumer.get_messages(timeout=.25)[0].message.value
            ws.send(msg)
            print "sent {}".format(msg)
        except Exception as e:
            print e
            print "nothing waiting"
예제 #4
0
def stream_ws(ws):
    global kafka
    # get the stream_id we're going to follow
    msg = ws.receive()
    topic = "live_updates.{}".format(msg)

    from uuid import uuid4

    kafka = connect_kafka()
    consumer = SimpleConsumer(kafka, None, topic, auto_commit=False)

    while True:
        print "Fetching"
        try:
            msg = consumer.get_messages(timeout=.25)[0].message.value
            ws.send(msg)
            print "sent {}".format(msg)
        except Exception as e:
            print e
            print "nothing waiting"