winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.73k stars 185 forks source link

feat: external inflight typescript files #6305

Closed MarkMcCulloh closed 3 weeks ago

MarkMcCulloh commented 1 month ago

Fixes #6045

This PR introduces a new utility function @inflight. This allows you to create an inflight closure from an external file with specific lifts:

// main.w
bring cloud;
let bucket = new cloud.Bucket();
let queue = new cloud.Queue();

bucket.onCreate(@inflight("./bucket_create.ts",
  export: "default",
//        ^ Optional named export from the file, default is the default export
  lifts:[{ obj: queue, alias: "myQueue", ops: ["push"] }],
//       ^ object to lift, can be any preflight expression
//                     ^ Optional alias, by default, this will be the variable name passed to obj
//                                     ^ methods to lift, if not provided then all methods will be granted
));
// bucket_create.ts
import inflight from "./.bucket_create.inflight";

export default inflight(async ({ myQueue }, file) => {
//                               ^ inflight interface to your preflight queue
  await myQueue.push(file);
});

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

github-actions[bot] commented 1 month ago

Thanks for opening this pull request! :tada: 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
monadabot commented 1 month ago

Console preview environment is available at https://wing-console-pr-6305.fly.dev :rocket:

Last Updated (UTC) 2024-05-27 01:19
monadabot commented 1 month ago

Benchmarks

Comparison to Baseline 🟥⬜⬜🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 56ms±0.58 | 58ms±0.66 | +3ms (+4.65%)🟥 | | functions_10.test.w -t sim | 495ms±7.74 | 510ms±8.05 | +15ms (+2.94%)⬜ | | functions_10.test.w -t tf-aws | 2025ms±25.31 | 2079ms±18.42 | +54ms (+2.68%)⬜ | | hello_world.test.w -t sim | 399ms±3.7 | 411ms±5.69 | +12ms (+3.01%)🟥 | | hello_world.test.w -t tf-aws | 1441ms±9.86 | 1445ms±9.28 | +3ms (+0.24%)⬜ | | functions_1.test.w -t sim | 395ms±6.09 | 399ms±3.17 | +3ms (+0.78%)⬜ | | functions_1.test.w -t tf-aws | 817ms±4.91 | 829ms±8.33 | +12ms (+1.5%)⬜ | | jsii_big.test.w -t sim | 2793ms±16.04 | 2801ms±9.01 | +8ms (+0.29%)⬜ | | jsii_big.test.w -t tf-aws | 2996ms±12.38 | 2995ms±13.44 | -1ms (-0.04%)⬜ | | empty.test.w -t sim | 360ms±5.07 | 364ms±4.48 | +4ms (+1.15%)⬜ | | empty.test.w -t tf-aws | 593ms±4.03 | 594ms±3.85 | +1ms (+0.23%)⬜ | | jsii_small.test.w -t sim | 373ms±2.63 | 372ms±5.13 | -1ms (-0.17%)⬜ | | jsii_small.test.w -t tf-aws | 612ms±4.93 | 607ms±5.1 | -5ms (-0.85%)⬜ | ⬜ 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|510ms|488ms|521ms|8ms|11ms| |functions_10.test.w -t tf-aws|2079ms|2035ms|2121ms|18ms|26ms| |hello_world.test.w -t sim|411ms|404ms|426ms|6ms|8ms| |hello_world.test.w -t tf-aws|1445ms|1426ms|1477ms|9ms|13ms| |functions_1.test.w -t sim|399ms|395ms|409ms|3ms|4ms| |functions_1.test.w -t tf-aws|829ms|811ms|849ms|8ms|12ms| |jsii_big.test.w -t sim|2801ms|2783ms|2824ms|9ms|13ms| |jsii_big.test.w -t tf-aws|2995ms|2966ms|3025ms|13ms|19ms| |empty.test.w -t sim|364ms|354ms|374ms|4ms|6ms| |empty.test.w -t tf-aws|594ms|585ms|602ms|4ms|5ms| |jsii_small.test.w -t sim|372ms|363ms|384ms|5ms|7ms| |jsii_small.test.w -t tf-aws|607ms|596ms|618ms|5ms|7ms|
Last Updated (UTC) 2024-05-26 22:47
mergify[bot] commented 3 weeks ago

Thanks for contributing, @MarkMcCulloh! This PR will now be added to the merge queue, or immediately merged if mark/intrinsic-inflight is up-to-date with main and the queue is empty.

monadabot commented 3 weeks ago

Congrats! :rocket: This was released in Wing 0.74.17.