-
Notifications
You must be signed in to change notification settings - Fork 45
Fix local development with Pub/Sub Emulator #234
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
Comments
I'll look at this when I'm back at work in January. |
Okay, now I'm back at work... could you clarify what exactly you'd expect the flow to be for local development? If you're expecting the emulator to push events to the Functions Framework, but the emulator doesn't support creating CloudEvents, then that feels like it's more of either a missing feature of the emulator, or something missing in-between. I wouldn't want the Functions Framework to take a dependency on a different format that the emulator happens to create. If you can explain carefully what you're expecting, I can try to work out some potential options, and will consult with @matthewrobertson about them too. |
Thanks for the reply! I'm trying to establish an end-to-end local environment for running tests and local development that doesn't depend on anything in GCP itself. I have these components:
How I use the emulator The issue is that that function is receiving a message with this format:
Which is different to what GCP sends it. This causes the function framework to fail when using a typed CloudEvent with the following error: It appears that there is some internal marshalling logic that happens in the GCP function framework to change the format to something the function understands. Other functions frameworks seem to have solved this by adding the marshalling logic to the function runtime. I hope I'm on the right track here! |
Right - the I'm assuming that in production, you'll end up subscribing to PubSub events either using Eventarc or using the Rather than add this very-special-casing support to the Functions Framework, I would personally suggest adding a sort of proxy, probably via an We could potentially have the code for that within this repo - I'd just prefer not to have it within the Functions Framework itself. Basically I want to move away from legacy event formats rather than accepting more of them :) I'll discuss it with @matthewrobertson though. (It's definitely feasible to change the adapter to accept the format from PubSub; it's just not something I'd like to do if we can avoid it.) |
Ah that makes sense - I had a hunch the push endpoint behaved a little differently. Your assumption is correct - the function is deployed using I think your suggestion would work - the unknown for me is in accurately re-creating that MessagePublishedData format from what is supplied by PushEndpoint, but that might be straightforward. I'll give it a go. Totally understand not wanting to have this in the functions framework itself - it doesn't feel like it belongs there as its emulatorey test stuff. I guess my issue has been in getting this happy path running locally, so if there was a template or code sample that setup that proxy to forward to a function (could some kind of host extension provide this?) then that would make the happy path pretty great! |
I can try to create some sample code this afternoon, to at least unblock you while we work out a longer-term approach. Glad we're all on the same page now - sometimes that can be half the difficulty! |
Thanks so much, and thanks for the quick responses! |
Right, I've created a brief demo here: #235 It consists of three projects:
Hopefully it's reasonably self-explanatory. Running it consists of having four tabs open:
I'm not sure whether we'll want to include this in the repo anywhere, but hopefully it'll be useful to you as a starting point. |
Ah thanks very much, that's pretty much what I expected. Is connecting a function to the emulator not a more common scenario? I'm a little surprised this hasn't come up before (at least not in my googling) as I'd have thought it would be preferable to testing with a real GCP project. Thanks very much for your help 🙂 |
All I can say is that I don't remember see this before. But I only see feature requests etc for .NET. |
Hi there,
Currently the dotnet functions framework doesn't seem to work with the pubsub emulator, due to I believe the same issue as with other functions framework implementations (GoogleCloudPlatform/functions-framework-nodejs#272).
I've just hit this, as I'm receiving an error that isn't occurring when the function runs against real pub/sub.
The text was updated successfully, but these errors were encountered: