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

Add protobuf example & README documentation #169

Open
grayside opened this issue May 8, 2023 · 0 comments
Open

Add protobuf example & README documentation #169

grayside opened this issue May 8, 2023 · 0 comments
Labels
api: eventarc Issues related to the googleapis/google-cloudevents-go API. documentation Improvements or additions to documentation priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@grayside
Copy link
Contributor

grayside commented May 8, 2023

Problem

We now support receiving events in binary protobuf format, and expect Firestore events to be primarily used in protobuf. Current examples only show JSON parsing.

Proposal

Add examples of how to parse protobuf event payloads with the library in two forms:

Rough Example (Untested)

import (
    "log"
    cloudevent "github.com/cloudevents/sdk-go/v2"
    _ "github.com/cloudevents/sdk-go/binding/format/protobuf/v2"
    "github.com/googleapis/google-cloudevents-go/cloud/firestoredata"
)

func handler(w http.ResponseWriter, r *http.Request) {
    event := cloudevent.NewEventFromHTTPRequest(r)
    var target firestoredata.DocumentEventData
    if err := event.DataAs(&target); err != nil {
        log.Fatal("event.DataAs: %v", err)
    }
    fmt.Println(target.Value.Name)
}
@grayside grayside added documentation Improvements or additions to documentation type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 8, 2023
@product-auto-label product-auto-label bot added the api: eventarc Issues related to the googleapis/google-cloudevents-go API. label May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: eventarc Issues related to the googleapis/google-cloudevents-go API. documentation Improvements or additions to documentation priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant