-
Notifications
You must be signed in to change notification settings - Fork 0
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
remove receiver, add scraper, few mods #11
base: master
Are you sure you want to change the base?
Conversation
SetSource("scraper"). | ||
SetEventType("cloudevent.flickr.image") | ||
) | ||
event_json = ujson.dumps(event.Properties()) |
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.
That’s why I pointed you to ToRequest API. Here you’re basically lucky because your event data a dict, in other case it wouldn’t work.
Here you need to create an instance of an marshaller, from that you need to call a ToRequest method that will turn your event objection into serialized one (headers and a body).
print(event_json) | ||
|
||
process_url = "http://docker.for.mac.localhost:8080/t/cloudevents/image-processor" | ||
r = requests.post(process_url, data=event_json) |
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.
It’s not enough to send a JSON-like object and call it a CloudEvent. You need to set content type to application/cloudevent+json
import fdk | ||
|
||
from cloudevents.sdk import converters | ||
from cloudevents.sdk import marshaller |
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.
Imported but not used
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.
well I presume I need to use those if I want to send the event the right way (not as json)
|
||
from cloudevents.sdk import converters | ||
from cloudevents.sdk import marshaller | ||
from cloudevents.sdk.converters import structured |
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.
Consider using binary format instead of structured.
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.
why?
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.
simpler, less efforts to parse the event itself.
No description provided.