Abstract#

Abstract base classes for handling ZeroMQ socket operations.

class brainmaze_zmq.abstract.ABExitHandler#

Abstract base class for handling an exit signal via a ZeroMQ PULL socket.

kill_exit_handler()#

Close the exit socket and clean up resources.

on_recv_exit(msg)#

Handle receiving an exit signal.

Parameters:

msg (list) – The message received via the PULL socket.

setup_exit_handler(port: int)#

Set up a PULL socket to listen for an exit signal.

Parameters:

port (int) – The port to bind the PULL socket to.

abstractmethod stop()#

Abstract method to be implemented by subclasses to handle stopping operations.

class brainmaze_zmq.abstract.ABPublisherHandler#

Abstract base class for publishing messages via a ZeroMQ PUB socket.

kill_publisher_handler()#

Close the publisher socket and clean up resources.

publish(topic: str, msg: tuple)#

Publish a message with a topic.

Parameters:
  • topic (str) – The topic for the message.

  • msg (tuple) – The message to publish.

setup_publisher_handler(port: int)#

Set up a PUB socket to publish messages.

Parameters:

port (int) – The port to bind the PUB socket to.

class brainmaze_zmq.abstract.ABReplyHandler#

Abstract base class for handling a REPLY mechanism via a ZeroMQ REP socket.

kill_reply_handler()#

Close the reply socket and clean up resources.

abstractmethod reply(msg)#

Abstract method to handle incoming messages and provide a reply.

Parameters:

msg (list) – The message received via the REP socket.

setup_reply_handler(port: int)#

Set up a REP socket to handle incoming requests.

Parameters:

port (int) – The port to bind the REP socket to.

class brainmaze_zmq.abstract.ABRequestHandler#

Abstract base class for handling requests via a ZeroMQ REQ socket.

kill_request_handler()#

Close the request socket and clean up resources.

request_reply(msg)#

Send a request and wait for a reply.

Parameters:

msg (str) – The request message to send.

Returns:

The reply received from the server.

Return type:

Any

setup_request_handler(port: int)#

Set up a REQ socket to send requests.

Parameters:

port (int) – The port to connect the REQ socket to.

class brainmaze_zmq.abstract.ABSubscriberHandler#

Abstract base class for subscribing to messages via a ZeroMQ SUB socket.

kill_subscriber_handler()#

Close the subscriber socket and clean up resources.

abstractmethod on_recv_data(msg)#

Abstract method to handle incoming data.

Parameters:

msg (list) – The message received via the SUB socket.

setup_subscriber_handler(port: int, topic: str)#

Set up a SUB socket to subscribe to messages on a topic.

Parameters:
  • port (int) – The port to connect the SUB socket to.

  • topic (str) – The topic to subscribe to.