Skip to content

Advanced HTTP events #545

@xpepermint

Description

@xpepermint

The documentation describes HTTP related events pretty well. I try to understand advanced use cases which are not covered by the docs.

I'd like to standardize all incoming requests of my SAAS service by forcing cloud events everywhere. This would include API calls performed by users over the HTTP protocol (e.g. REST, RPC). The spec in this repo is pretty forward. Based on HTTP Protocol Binding nothing prevents such use case. If I'm correct, then a user would send event metadata as HTTP headers and use application/json content type for GET/POST requests and application/octet-stream for binary stuff like file uploads. The only restriction I see is the size limit for intermediaries and consumers which is expected to be up to 64 KB - this blocks file upload implementation. By ignoring this limit the HTTP event received from a user would look like this:

const httpEvent = {
    "specversion" : "1.0",
    "type" : "com.myservice.api.files.upload",
    "source" : "https://myservice.com/api/files",
    "subject" : "upload",
    "id" : "A234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "datacontenttype" : "application/octet-stream",
    "data" : HTTPRequestObject // stream instance (`req`)
};

I wonder why Google's implementation of HTTP cloud function doesn't provide the event object. It seems like Knative also follows Google's pattern. AWS, however, agrees that a user sends an event object where they attach custom properties.

// Google
exports.helloHttp = (req, res) => {};
exports.helloEvent = (event, context) => {};
// AWS
exports.helloHttp = async (event) => {};

If we ignore how cloud functions work today, cloud events could also start HTTP event streaming (SSE) and there's a bunch of other use cases. At the moment it seems to me that cloud events are only meant for small background triggers and not as an overall event standard. Am I correct? I remember a talk almost a year ago where a guy said that an event carries only data for a consumer to create another request to access actual data. Maybe this is still true.

I would appreciate comments on what I wrote above and some more words about the conceptional-level overview of how the cloud events should be used. It would be great for this spec to be more opinionated to eliminate confusion. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions