Skip to content

Fix local development with Pub/Sub emulator #272

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

Merged
merged 3 commits into from
Apr 20, 2021

Conversation

matthewrobertson
Copy link
Member

@matthewrobertson matthewrobertson commented Apr 7, 2021

Currently, deploying a function with --trigger-topic creates a Pub/Sub subscription that delivers events to an internal endpoint that marshals request payloads before forwarding them to a user's function. Unfortunately, this breaks local development with the Pub/Sub emulator as the Functions Frameworks are dependent on this request marshalling logic.

In order to better support local development and testing with the Pub/Sub emulator, this commit introduces the event marshalling logic to the Functions Framework via express middleware that is enable when the PUBSUB_EMULATOR_HOST is set.

fixes #41, fixes #96

@google-cla google-cla bot added the cla: yes label Apr 7, 2021
@matthewrobertson matthewrobertson force-pushed the fix-pubsub-emulator branch 3 times, most recently from 73a896c to 008a9d0 Compare April 7, 2021 22:00
@matthewrobertson matthewrobertson requested a review from grant April 16, 2021 21:52
@matthewrobertson matthewrobertson marked this pull request as ready for review April 16, 2021 21:53
Copy link
Contributor

@grant grant left a comment

Choose a reason for hiding this comment

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

Thanks!

Do you mind adding a little more detailed description in the PR for how you tested this locally?

For example, I don't see the use of PUBSUB_EMULATOR_HOST in the PR here. Some light instructions for how a user can test this manually would help. Even better would be to update the docs we have on this content with the new setup.

@matthewrobertson matthewrobertson requested a review from grant April 19, 2021 21:00
Copy link
Contributor

@grant grant left a comment

Choose a reason for hiding this comment

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

Main concern is the middleware for all raw Pub/Sub requests. o.w. lgtm

@matthewrobertson matthewrobertson merged commit 4d8eb24 into master Apr 20, 2021
matthewrobertson added a commit to GoogleCloudPlatform/functions-framework-java that referenced this pull request Jun 28, 2021
Currently, the functions frameworks are dependent on some private
dataplane event marshalling logic in order to correctly pass PubSub
events to background functions. This commit implements the same
marshalling logic in the FF in order to enable local development using
the PubSub emulator.

We have already made this change in other languages:
GoogleCloudPlatform/functions-framework-nodejs#272
GoogleCloudPlatform/functions-framework-ruby#100
GoogleCloudPlatform/functions-framework-python#121
GoogleCloudPlatform/functions-framework-go#70
matthewrobertson added a commit to GoogleCloudPlatform/functions-framework-java that referenced this pull request Jun 28, 2021
Currently, the functions frameworks are dependent on some private
dataplane event marshalling logic in order to correctly pass PubSub
events to background functions. This commit implements the same
marshalling logic in the FF in order to enable local development using
the PubSub emulator.

We have already made this change in other languages:
GoogleCloudPlatform/functions-framework-nodejs#272
GoogleCloudPlatform/functions-framework-ruby#100
GoogleCloudPlatform/functions-framework-python#121
GoogleCloudPlatform/functions-framework-go#70
matthewrobertson added a commit to GoogleCloudPlatform/functions-framework-java that referenced this pull request Jun 30, 2021
Currently, the functions frameworks are dependent on some private
dataplane event marshalling logic in order to correctly pass PubSub
events to background functions. This commit implements the same
marshalling logic in the FF in order to enable local development using
the PubSub emulator.

We have already made this change in other languages:
GoogleCloudPlatform/functions-framework-nodejs#272
GoogleCloudPlatform/functions-framework-ruby#100
GoogleCloudPlatform/functions-framework-python#121
GoogleCloudPlatform/functions-framework-go#70
matthewrobertson added a commit to GoogleCloudPlatform/functions-framework-java that referenced this pull request Jul 2, 2021
Currently, the functions frameworks are dependent on some private
dataplane event marshalling logic in order to correctly pass PubSub
events to background functions. This commit implements the same
marshalling logic in the FF in order to enable local development using
the PubSub emulator.

We have already made this change in other languages:
GoogleCloudPlatform/functions-framework-nodejs#272
GoogleCloudPlatform/functions-framework-ruby#100
GoogleCloudPlatform/functions-framework-python#121
GoogleCloudPlatform/functions-framework-go#70
matthewrobertson added a commit to GoogleCloudPlatform/functions-framework-java that referenced this pull request Jul 7, 2021
* unblock local development with the pubsub emulator

Currently, the functions frameworks are dependent on some private
dataplane event marshalling logic in order to correctly pass PubSub
events to background functions. This commit implements the same
marshalling logic in the FF in order to enable local development using
the PubSub emulator.

We have already made this change in other languages:
GoogleCloudPlatform/functions-framework-nodejs#272
GoogleCloudPlatform/functions-framework-ruby#100
GoogleCloudPlatform/functions-framework-python#121
GoogleCloudPlatform/functions-framework-go#70

* fix code style issues
@grant grant deleted the fix-pubsub-emulator branch October 15, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants