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

feat(sdk)!: change cloud.Function event type from str to Json #6219

Merged
merged 45 commits into from
Jul 17, 2024

Conversation

garysassano
Copy link
Collaborator

@garysassano garysassano commented Apr 12, 2024

Closes #6216

BREAKING CHANGE: The input and return types for cloud.Function handlers has been changed from str? to Json? to align with the event formats used by major cloud providers like AWS, GCP, and Azure.

This is a breaking change for any existing code that assumes the input event is a str.

To migrate:

  • Update cloud.Function handlers to expect a Json? value as input instead of a str?
  • Remove any JSON parsing logic since the input will already be parsed into a Json value. To convert a x: Json? to str, you can write x?.asStr()!.
  • Update any tests or invocations of cloud.Function to pass in Json values instead of str

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

@garysassano garysassano requested a review from a team as a code owner April 12, 2024 06:30
Copy link

github-actions bot commented Apr 12, 2024

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistence, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

@eladb
Copy link
Contributor

eladb commented Apr 12, 2024

Please add a detailed description and a BREAKING CHANGE section to the PR description

@garysassano garysassano changed the title fix(sdk)!: attempt change input event for cloud.Function from string to Json fix(sdk)!: change cloud.Function event input type from string to Json Apr 13, 2024
@garysassano garysassano changed the title fix(sdk)!: change cloud.Function event input type from string to Json fix(sdk)!: change cloud.Function event type from string to Json Apr 13, 2024
@garysassano
Copy link
Collaborator Author

The function invocation on AWS works now.

❯ aws lambda invoke --function-name Function-c852aba6 --payload $(echo '{ "foo": 123 }' | base64)  out.json
{
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
}

Copy link

github-actions bot commented May 4, 2024

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days.
If you need help with the PR, do not hesitate to reach out in the winglang community discord at winglang.discord.com.
Feel free to re-open this PR when it is still relevant and ready to be worked on again.
Thanks!

@github-actions github-actions bot added the Stale label May 4, 2024
@garysassano garysassano removed the Stale label May 4, 2024
Copy link

github-actions bot commented Jun 5, 2024

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days.
If you need help with the PR, do not hesitate to reach out in the winglang community Discord.
Feel free to re-open this PR when it is still relevant and ready to be worked on again.
Thanks!

@github-actions github-actions bot added the Stale label Jun 5, 2024
@garysassano garysassano removed the Stale label Jun 5, 2024
@tsuf239
Copy link
Collaborator

tsuf239 commented Jun 5, 2024

Hi Gary, do you need any help with this one?
Can you please resolve the conflicts?

@garysassano
Copy link
Collaborator Author

I resolved the conflicts, but I don't have much knowledge on how the simulator resources work. Some of them require type adjusting.

@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Jul 15, 2024
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Jul 15, 2024
@monadabot
Copy link
Contributor

Benchmarks

Comparison to Baseline ⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜🟥⬜
Benchmark Before After Change
version 58ms±0.36 58ms±0.83 0ms (-0.03%)⬜
functions_10.test.w -t sim 523ms±16.7 506ms±20.36 -17ms (-3.21%)⬜
functions_10.test.w -t tf-aws 2232ms±22.94 2208ms±20.39 -24ms (-1.09%)⬜
jsii_small.test.w -t sim 382ms±2.49 389ms±2.83 +6ms (+1.62%)⬜
jsii_small.test.w -t tf-aws 634ms±6.2 645ms±5.93 +11ms (+1.74%)⬜
jsii_big.test.w -t sim 2989ms±11.83 3024ms±13.1 +34ms (+1.15%)⬜
jsii_big.test.w -t tf-aws 3166ms±13.62 3210ms±27.9 +44ms (+1.39%)⬜
hello_world.test.w -t sim 405ms±3.68 414ms±4.31 +9ms (+2.11%)⬜
hello_world.test.w -t tf-aws 1493ms±5.84 1503ms±8.82 +10ms (+0.64%)⬜
empty.test.w -t sim 366ms±2.53 373ms±3.84 +7ms (+1.78%)⬜
empty.test.w -t tf-aws 620ms±2.7 625ms±5.73 +5ms (+0.79%)⬜
functions_1.test.w -t sim 404ms±4.74 419ms±9.4 +15ms (+3.73%)🟥
functions_1.test.w -t tf-aws 857ms±5.36 868ms±6.95 +11ms (+1.3%)⬜

⬜ Within 1.5 standard deviations
🟩 Faster, Above 1.5 standard deviations
🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 58ms 57ms 60ms 1ms 1ms
functions_10.test.w -t sim 506ms 471ms 548ms 20ms 28ms
functions_10.test.w -t tf-aws 2208ms 2165ms 2254ms 20ms 29ms
jsii_small.test.w -t sim 389ms 384ms 395ms 3ms 4ms
jsii_small.test.w -t tf-aws 645ms 629ms 657ms 6ms 8ms
jsii_big.test.w -t sim 3024ms 2993ms 3057ms 13ms 18ms
jsii_big.test.w -t tf-aws 3210ms 3156ms 3298ms 28ms 39ms
hello_world.test.w -t sim 414ms 405ms 425ms 4ms 6ms
hello_world.test.w -t tf-aws 1503ms 1478ms 1519ms 9ms 12ms
empty.test.w -t sim 373ms 363ms 379ms 4ms 5ms
empty.test.w -t tf-aws 625ms 614ms 638ms 6ms 8ms
functions_1.test.w -t sim 419ms 403ms 449ms 9ms 13ms
functions_1.test.w -t tf-aws 868ms 858ms 888ms 7ms 10ms
Last Updated (UTC) 2024-07-15 20:17

@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Jul 15, 2024
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Jul 15, 2024
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Jul 15, 2024
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Jul 15, 2024
Copy link
Contributor

mergify bot commented Jul 17, 2024

Thanks for contributing, @garysassano! This PR will now be added to the merge queue, or immediately merged if gary/funtion-json-handler is up-to-date with main and the queue is empty.

@mergify mergify bot merged commit 98de4ad into main Jul 17, 2024
25 checks passed
@mergify mergify bot deleted the gary/funtion-json-handler branch July 17, 2024 15:26
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.79.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Lambda input event is JSON and not string
7 participants