Documentation
¶
Overview ¶
Package main demonstrates channel-based message passing between workflows.
This example shows: - Subscribe/Receive for receiving messages - Publish for broadcasting messages - SendTo for direct messaging to specific workflow instances - ModeBroadcast vs ModeCompeting delivery modes
Usage:
go run ./examples/channel/
Then in separate terminals:
Start a consumer (broadcast mode): curl -X POST http://localhost:8084/start-consumer \ -H "Content-Type: application/json" \ -d '{"consumer_id": "consumer-1", "mode": "broadcast"}'
Start another consumer: curl -X POST http://localhost:8084/start-consumer \ -H "Content-Type: application/json" \ -d '{"consumer_id": "consumer-2", "mode": "broadcast"}'
Send a message to all consumers: curl -X POST http://localhost:8084/publish \ -H "Content-Type: application/json" \ -d '{"channel": "notifications", "message": "Hello everyone!"}'
Send a direct message to a specific consumer: curl -X POST http://localhost:8084/send-to \ -H "Content-Type: application/json" \ -d '{"instance_id": "<workflow-instance-id>", "channel": "notifications", "message": "Private message"}'