python - ZeroMQ pattern for Worker processes? -




i'm learning 0mq , having difficulty understanding pattern use use case.

i want create server multiple clients connect. server going hand out work items, each work item have go specific client. example, if server picking cards deck, want hearts go 1 worker, diamonds second worker, etc. (the work items events sessions, , need every event single session go same worker.)

what pattern use this, , have code shows (in python):

context = zqm.context() socket = context.socket(which type?) socket.bind("tcp://*:5555")  #wait 4 clients connect (how?)  while true:     card = getnextcard()     if card.suit == hearts:         send card worker #1 (how?)     if card.suit == diamonds:         send card workder #2     etc... 

basically, how track clients have connected server, , send work items 1 of n clients connected?

welcome world of distributed-computing:

clients may introduce themselves, once starting connected server, assume server have

sub_to_ask4connect = context.socket( zmq.sub ) sub_to_ask4connect.bind(                "tcp://a.b.c.d:p" ) sub_to_ask4connect.setsockopt(       zmq.linger, 0 ) sub_to_ask4connect.setsockopt(       zmq.subscribe, "" ) #------------------------------------------------------ ready .recv() * 

next, establish client-accept-into-workerpoolpolicy():

so handle right newcomer, has introduced via above setup sub_to_ask4connect socket-interface.

clients ought know protocol of -
a) .connect() proper address
b) .send() proper self-introduction
c) ready .connect() / .bind() additional socket interfaces, per server's instructions so
d) have .bind()-ready ( or .connect()-to known server-side reverse-pub, if security requirements permit ) interface receive further details , handshaking signalisation, during workerpool-assignment/coordination/release policies, work-package specific , server-side controlled.

simply said, not expect single archetype match requirements such distributed control of ad-hoc work-package routing having dynamic ad-hoc client-association/release in-place.

such distributed-pool(s) system control-plane more important , cardinal such dynamic eco-system, simpler work-package logistics plane ( simpler handshaking takes place ).

anyway, enjoy new universe -- distributed entities appear / disappear , ( may ) cooperate in new way, not common monolythic architectures , architects.

feel free browse other zeromq questions , answers find more inspirative insights.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -