Python - topic.publish()
Publishes a topic.
from nitric.resources import topicfrom nitric.application import Nitricupdates = topic('updates').allow('publish')await updates.publish({'something': 'amazing happened'})Nitric.run()
Parameters
- Name
event
- Type
- Event
- Description
The event to publish to the topic.
- Name
id
- Type
- string
- Description
Unique ID to apply to the event.
- Name
payload
- Type
- dict
- Description
Payload to send with the event.
- Name
payloadType
- Type
- string
- Description
A hint to the type of payload supplied.
Examples
Publish a topic
from nitric.resources import topicfrom nitric.application import Nitricupdates = topic('updates').allow('publish')await updates.publish({'something': 'amazing happened'})Nitric.run()
Notes
- A service may subscribe to OR publish to a topic but not both. This is in place to stop services calling themselves infinitely.
Last updated on Oct 11, 2024