Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code example of how to create a CloudEvent in code and use in pub/sub requests #1633

Closed
msfussell opened this issue Jul 10, 2021 · 7 comments
Labels
area/runtime/pubsub content/missing-information More information requested or needed good first issue Good for newcomers

Comments

@msfussell
Copy link
Member

In this topic
https://docs.dapr.io/developing-applications/building-blocks/pubsub/howto-publish-subscribe/#sending-a-custom-cloudevent it describes how you can send your own cloudevent but does not show any code example. This will become more common when Dapr event filtering feature dapr/dapr#2582 is introduced.

This doc issue is to provide a code example of how to create a CloudEvent in code and use in pub/sub requests.

@msfussell msfussell added content/missing-information More information requested or needed good first issue Good for newcomers labels Jul 10, 2021
@willtsai
Copy link
Contributor

@msfussell -- if we add examples for publishing a custom CloudEvent via Bash and Powershell, would that satisfy this requirement? i.e. something like:

Bash:
curl -X POST http://localhost:3500/v1.0/publish/pubsub/deathStarStatus -H "Content-Type: application/cloudevents+json" -d '{"specversion" : "1.0", "type" : "com.dapr.cloudevent.sent", "source" : "testcloudeventspubsub", "subject" : "Cloud Events Test", "id" : "someCloudEventId", "time" : "2021-08-02T09:00:00Z", "datacontenttype" : "application/cloudevents+json", "data" : {"status": "completed"}}'

Powershell:
Invoke-RestMethod -Method Post -ContentType 'application/cloudevents+json' -Body '{"specversion" : "1.0", "type" : "com.dapr.cloudevent.sent", "source" : "testcloudeventspubsub", "subject" : "Cloud Events Test", "id" : "someCloudEventId", "time" : "2021-08-02T09:00:00Z", "datacontenttype" : "application/cloudevents+json", "data" : {"status": "completed"}}' -Uri 'http://localhost:3500/v1.0/publish/pubsub/deathStarStatus'

@willtsai
Copy link
Contributor

Here's the $ curl (Bash) example that illustrates the Dapr app successfully receiving and processing the custom CloudEvent:

image

@yaron2
Copy link
Member

yaron2 commented Aug 23, 2021

Here's the $ curl (Bash) example that illustrates the Dapr app successfully receiving and processing the custom CloudEvent:

image

Not speaking for @msfussell, but I think that'll do the job.

@willtsai
Copy link
Contributor

willtsai commented Sep 1, 2021

@msfussell -- do the above suggestions look good to you? If so, I can work on the changes and submit a PR for this. Thanks!

@msfussell
Copy link
Member Author

Yes. This would be sufficient to add. Also ensure that there is a link to the quickstarts.

@willtsai
Copy link
Contributor

Thanks @msfussell @yaron2 - here's the PR. Note that the link to quickstarts is already included in the Next steps section in that page.

#1892

@greenie-msft
Copy link
Collaborator

Docs PR merged: #1892

Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime/pubsub content/missing-information More information requested or needed good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants