Beispiel #1
0
def publish(addr, who, url):
    writer = MalamuteClient()
    print_and_flush("connect")
    writer.connect(addr, 100, who)
    print_and_flush("set_producer")
    writer.set_producer(PRODUCER)

    while True:
        now = datetime.datetime.now()
        writer.send(url, [b'success', str(now).encode(UTF8)])
        time.sleep(10)
Beispiel #2
0
def publish(addr, who, url):
    writer = MalamuteClient()
    print_and_flush("connect")
    writer.connect(addr, 100, who)
    print_and_flush("set_producer")
    writer.set_producer(PRODUCER)

    while True:
        now = datetime.datetime.now()
        writer.send(url, [b'success', str(now).encode(UTF8)])
        time.sleep(10)
Beispiel #3
0
def commit(addr, who, filename, repository):
    os.chdir(repository)
    reader = MalamuteClient()
    print_and_flush("connect")
    reader.connect(addr, 100, who)
    print_and_flush("set_consumer")
    reader.set_consumer(PRODUCER, b'')

    while True:
        _, who, url, messages = reader.recv()
        url = url.decode(UTF8)
        messages = [msg.decode(UTF8) for msg in messages]
        write_and_commit(filename, url, messages)
Beispiel #4
0
def commit(addr, who, filename, repository):
    os.chdir(repository)
    reader = MalamuteClient()
    print_and_flush("connect")
    reader.connect(addr, 100, who)
    print_and_flush("set_consumer")
    reader.set_consumer(PRODUCER, b'')

    while True:
        _, who, url, messages = reader.recv()
        url = url.decode(UTF8)
        messages = [msg.decode(UTF8) for msg in messages]
        write_and_commit(filename, url, messages)
Beispiel #5
0
def test(addr):
    service = MalamuteClient()
    service.connect(addr, 100, b'service')
    service.set_worker(b'service', b'derps')

    writer = MalamuteClient()
    print("writer.connect")
    writer.connect(addr, 100, b'writer')
    print("writer.set_producer")
    writer.set_producer(b'writer')

    reader = MalamuteClient()
    print("reader.connect")
    reader.connect(addr, 100, b'reader')
    print("reader.set_consumer")
    reader.set_consumer(b'writer', b'foo')
    reader.set_consumer(b'writer', b'bar')

    print("writer.send")
    writer.send(b'foo', [b'whoaaa', b'whaaaaaa'])
    writer.send(b'bar', [b'whoaaa', b'whaaaaaa'])
    print(reader.recv())
    print(reader.recv())

    reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
    reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
    reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
    print(service.recv())
    print(service.recv())
    print(service.recv())

    service.sendto(b'reader', b'response', None, 100, [b'ok'])
    print(reader.recv())
Beispiel #6
0
def test(addr):
	service = MalamuteClient()
	service.connect(addr, 100, b'service')
	service.set_worker(b'service', b'derps')

	writer = MalamuteClient()
	print("writer.connect")
	writer.connect(addr, 100, b'writer')
	print("writer.set_producer")
	writer.set_producer(b'writer')

	reader = MalamuteClient()
	print("reader.connect")
	reader.connect(addr, 100, b'reader')
	print("reader.set_consumer")
	reader.set_consumer(b'writer', b'foo')
	reader.set_consumer(b'writer', b'bar')

	print("writer.send")
	writer.send(b'foo', [b'whoaaa', b'whaaaaaa'])
	writer.send(b'bar', [b'whoaaa', b'whaaaaaa'])
	print(reader.recv())
	print(reader.recv())

	reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
	reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
	reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
	print(service.recv())
	print(service.recv())
	print(service.recv())

	service.sendto(b'reader', b'response', None, 100, [b'ok'])
	print(reader.recv())