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

remove receiver, add scraper, few mods #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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

functions/scraper/Dockerfile Show resolved Hide resolved
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