-
Notifications
You must be signed in to change notification settings - Fork 223
Adding raw event subscription alongside CloudEvent subscription #1617
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
base: master
Are you sure you want to change the base?
Adding raw event subscription alongside CloudEvent subscription #1617
Conversation
Signed-off-by: Artur Ciocanu <artur.ciocanu@gmail.com>
|
@dapr/approvers-java-sdk and @dapr/maintainers-java-sdk could you please take a look and approve. This has been requested by @alicejgibbons. One thing I want to mention, I am not really fond of the new name An alternative would be to rename the old method to |
Another possibility is naming the new one |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1617 +/- ##
============================================
+ Coverage 76.91% 78.92% +2.00%
- Complexity 1592 2074 +482
============================================
Files 145 227 +82
Lines 4843 6258 +1415
Branches 562 684 +122
============================================
+ Hits 3725 4939 +1214
- Misses 821 970 +149
- Partials 297 349 +52 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @Override | ||
| public <T> Flux<T> subscribeToEventsData(String pubsubName, String topic, TypeRef<T> type) { | ||
| return subscribeToEvents(pubsubName, topic, type) | ||
| .map(CloudEvent::getData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artur-ciocanu does this line not force the type to deserialize into a CloudEvent?
|
Regardinging renaming, can we have multiple overloads to subscribeToEvents? |
@alicejgibbons unfortunately we can not have the same overloads that depends just on generic type. @alicejgibbons as I was thinking more and more. Instead of coming up with different APIs, customers can leverage Flux via a simple It is an additional step, but it is not too bad. Please let me know your thoughts. |
| // Publish messages | ||
| for (int i = 0; i < NUM_MESSAGES; i++) { | ||
| String message = String.format("Raw message #%d for run %s", i, runId); | ||
| client.publishEvent(PUBSUB_NAME, TOPIC_NAME, message).block(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still publishing a cloudEvent by default since you are not adding the raw payload header. Thus needs to be changed to something like the following:
PublishEventRequest publishEventRequest = new PublishEventRequest(pubsubName, topicName, eventType);
publishEventRequest.setContentType(APPLICATION_EVENT_TYPES_JSON);
headers.put("rawPayload", "true");
publishEventRequest.setMetadata(headers);
client.publishEvent(publishEventRequest).block();
Description
Adding raw event subscription alongside CloudEvent subscription
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #1616
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: