Skip to content

Conversation

@carimura
Copy link
Member

@carimura carimura commented Dec 8, 2018

No description provided.

SetSource("scraper").
SetEventType("cloudevent.flickr.image")
)
event_json = ujson.dumps(event.Properties())
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imported but not used

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants