winglang / wing

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

Add ability to filter events before they reach inflight function for Buckets #7169

Open boyney123 opened 2 months ago

boyney123 commented 2 months ago

Use Case

I'm uploading files to my bucket, I want the ability to filter events before my inflight function is triggered.

bucket.onCreate(inflight (key: str) => {
     // inflight function is triggered for all files in the bucket 
});

Proposed Solution

bucket.onCreate(inflight (key: str) => {
     // inflight function is only triggered on matches
}, { prefix: 'uploads/', suffix: '.png' });

When setting a Lambda destination for S3 events, you can filter by the prefix or suffix. Our abstraction could use the same functionality, although I'm not sure how Azure or Google would handle this!?

Random other note, but maybe filters with code would be useful here too? Ability to filter events before the inflight is triggered? Although when it compiles into the cloud I'm not actually sure how this would work....

Implementation Notes

No response

Component

No response

Community Notes