Skip to content

Support pubsub push #518

Open
Open
@majelbstoat

Description

I'd like to run an event handling service on a serverless platform, like Cloud Run or Cloud Functions. This requires the service respond to http requests (example).

The current cloudevents sdk doesn't appear to support receiving messages in this way. As a result, my service would get spun down due to no incoming traffic. I can work around this by specifying a minimum number of instances, but it also wouldn't scale up in cases of event spikes.

I'd like to request some sort of framework for receiving messages from pubsub as a blocking http server, instead of streaming pulls.

It would be cool if the same StartReceiver method could be used, and controlled only by an option to pubsub.New().

Perhaps something like:

host := "https://myservice.cloudfunctions.net/events"
t := pubsub.New(ctx, pubsub.WithPushConfig(pubsub.PushConfig{
  Endpoint: host,
}))
c, err := cloudevents.NewClient(t, ce.WithTimeNow())
err := c.StartReceiver(ctx, func(ctx context.Context, event event.Event) error {
  // Same as before.
})

Then, in the presence of a push config, StartReceiver would instead start an http server to accept and process the messages, doing sufficient transformation to allow re-use of the same user-defined receive method.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions