rad  5.1.0
Public Member Functions | Properties | List of all members
rad.services.pubsub.Subscriber Class Reference

Subscriber is a protobuf-aware subscriber and uses ZmqSubscriber for the lower level protocol. More...

Public Member Functions

def __init__ (self, *handler, list topic_types, zmq.asyncio.Context zmq_ctx, unknown_handler=None, asyncio.AbstractEventLoop loop=None)
 
def start (self)
 Start reading from socket. More...
 
def stop (self)
 Stop reading from socket. More...
 
def connect (self, str endpoint)
 Connect to endpoint. More...
 
def disconnect (self, str endpoint)
 Disconnect from endpoint. More...
 
def subscribe (self, topic_name)
 Subscribe on the topic topic_name. More...
 
def unsubscribe (self, topic_name)
 Unsubscribe to topic identified by topic_name. More...
 

Properties

 is_closed = property
 Returns true if subscriber is not running, false otherwise. More...
 

Detailed Description

Subscriber is a protobuf-aware subscriber and uses ZmqSubscriber for the lower level protocol.

Constructor & Destructor Documentation

◆ __init__()

def rad.services.pubsub.Subscriber.__init__ (   self,
handler,
list  topic_types,
zmq.asyncio.Context  zmq_ctx,
  unknown_handler = None,
asyncio.AbstractEventLoop  loop = None 
)
Params
handler Callable that will be called with the received topics. Should take two arguments, topic-name and the parsed topic type. Example my_handler(topic_name, topic_type) topic_types list of protobuf message types that form the known set of topic types that can be decoded. [<pb_msg>, <pb_msg>, ...] zmq_ctx ZMQ context. unknown_handler Handler of unknown topics (optional). loop Event loop or None to use the default.

Member Function Documentation

◆ connect()

def rad.services.pubsub.Subscriber.connect (   self,
str  endpoint 
)

Connect to endpoint.

◆ disconnect()

def rad.services.pubsub.Subscriber.disconnect (   self,
str  endpoint 
)

Disconnect from endpoint.

◆ start()

def rad.services.pubsub.Subscriber.start (   self)

Start reading from socket.

   @todo: Return future instead?
Returns
Coroutine. The ZMQ socket reader coro that needs to be awaited on.

◆ stop()

def rad.services.pubsub.Subscriber.stop (   self)

Stop reading from socket.

   @todo: Return future instead?
Returns
Coroutine. The ZMQ socket reader coro that needs to be awaited on.

◆ subscribe()

def rad.services.pubsub.Subscriber.subscribe (   self,
  topic_name 
)

Subscribe on the topic topic_name.

Note
ZMQ topic filtering is done simply on the start of the string, subscribing to 'foo' will match the published topic 'foobar'.
Params
topic_name Topic name (str or bytes).

◆ unsubscribe()

def rad.services.pubsub.Subscriber.unsubscribe (   self,
  topic_name 
)

Unsubscribe to topic identified by topic_name.

Property Documentation

◆ is_closed

rad.services.pubsub.Subscriber.is_closed = property
static

Returns true if subscriber is not running, false otherwise.


The documentation for this class was generated from the following file: