A tiny library that abstract the producer-sink asynchronous communication pattern by using PUSH and PULL socket types from ZeroMQ.
Producer-Sink-ZMQ is not available on PyPI yet, so you need to install it with pip providing a GitHub path as follows:
$ pip install git+https://github.com/d2gex/producer-sink-zmq.git@0.1.3#egg=producer-sink-zmq
''' A producer that sends a sequence of number in descending order starting at 10 '''
producer = producer.Producer(url=tcp://127.0.0.1:5556, identity='Producer Name')
loops = 10
while loops:
producer.run(loops)
loops -= 1
where:
- url: Follows a format protocol://ip:port. TCP, IPC and INPROC protocols are supported
- linger: Time i seconds for the socket to linger around until can close, once the close statement has been issued
''' A sink that receives a sequence of number in descending order starting at 10 '''
sink = producer.Sink(url=tcp://127.0.0.1:5556, identity='Sink Name')
loops = 10
while loops:
data = producer.run()
print(data)
loops -= 1