cli
cli copied to clipboard
[Proposal] dapr subscribe command
Describe the proposal
This proposal is to add a dapr subscribe
command, a counterpart for the existing dapr publish
command. This will be useful in development scenarios which allows users to subscribe to a pubsub/topic/route, and print the data on STDOUT.
Example usage:
# Subscribe to sample topic in target pubsub via subscriber app without cloud event
dapr subscribe --subscribe-app-id myapp --pubsub target --topic sample --metadata '{"rawPayload":"true"}'
# Subscribe to sample topic in target pubsub via subscriber app with custom routes
dapr subscribe --subscribe-app-id myapp --pubsub target --topic sample --routes '{"rules": [{"match": "event.type == \'widget\'", "path": "/widgets"}], "default": "/products"}'
Proposed flags:
Short | Long | Type | Usage |
---|---|---|---|
-m | --metadata | string | The JSON serialized publish metadata (optional) |
-a | --subscribe-app-id | string | The ID of the subscriber app |
-p | --pubsub | string | The name of the pub/sub component |
-t | --topic | string | The topic to be published to |
-r | --routes | string | The JSON serialized routing configuration (optional) |
-u | --unix-domain-socket | string | Path to a unix domain socket dir. If specified, Dapr API servers will use Unix Domain Sockets (optional) |
-o | --output | string | Different levels of output - data (default), time, metadata, all (optional) |
--response | string | Response from the app - success (default), retry, drop (optional) |
Future scope can also include a --filter
option to selectively show data.
Release Note
RELEASE NOTE: ADD Support for dapr subscribe
@shubham1172 I think this is a proposal that will help users in quickly developing and testing pubsub API in Dapr.
With that I think we need to maintain consistency with other commands and have the --subscribe-app-id
parameter shorthand as -a
.
The one concern that I have with the --routes
parameter is that it does not make much sense for a console output application.
Unless say each event matching a particular match expression with a specific route is prefixed by that route in the output say
<datetime?> <rote.path> <event data> <metadata?>
?: optional route.path : either default path or specific path
WDYT?
Unless say each event matching a particular match expression with a specific route is prefixed by that route in the output say
@mukundansundar yes, that we can do. The main motivation for using a routes is the ability to filter events.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This feature would be useful in the development of Dapr pub-sub Pluggable Components, as the developer would not be forced to write an entire test harness or find and adapt an existing sample just to quickly test sending and, in particular, receiving events.