compas_eve.memory
¤
Classes¤
InMemoryTransport
¤
InMemoryTransport(codec: MessageCodec | None = None, *args, **kwargs)
In-Memory transport is ideal for simple single-process apps and testing.
It will only distribute messages within the same process, not across different processes.
Parameters:
-
codec(MessageCodec | None, default:None) –The codec to use for encoding and decoding messages. If not provided, defaults to JsonMessageCodec.
-
API Reference
compas_eve Functions
Functions¤
advertise
¤
advertise(topic: Topic)
Announce this code will publish messages to the specified topic.
This call has no effect on the in-memory transport.
on_ready
¤
on_ready(callback: Callable)
In-memory transport is always ready, it will immediately trigger the callback.
publish
¤
subscribe
¤
Subscribe to a topic.
Every time a new message is received on the topic, the callback will be invoked.
Parameters:
-
topic(Topic) –Instance of the topic to subscribe to.
-
callback(Callable) –Callback to invoke whenever a new message arrives. The callback should receive only one
msgargument, e.g.lambda msg: print(msg).
Returns:
-
str–Returns an identifier of the subscription.
unadvertise
¤
unadvertise(topic: Topic)
Announce that this code will stop publishing messages to the specified topic.
This call has no effect on the in-memory transport.