nitrictech / nitric

Nitric is a multi-language framework for cloud applications with infrastructure from code.
https://nitric.io
Apache License 2.0
1.25k stars 52 forks source link

Design: Subscribe to bucket changes #410

Closed tjholm closed 1 year ago

tjholm commented 1 year ago

Design a way to subscribe to changes in buckets as part of application code.

tjholm commented 1 year ago

Documenting previous proposal:

import { bucket } from '@nitric/sdk';

// create a bucket called files
const files = bucket("files");

// using pattern of "<event_type>:<file_pattern>"
// subscribe to write events for all files on the bucket
files.on('write:*', async (ctx) => {
  // do something with the event
});
raksiv commented 1 year ago

qq's

Will we support all access permissions 'read', 'write', 'delete'? What format will the file pattern be?

tjholm commented 1 year ago

@raksiv good questions, for permissions I think we should just impute them from the subscription, so regardless of whether or not a function actually has access to read/write to a bucket, it can still know about things that have happended with it (even if it can't get access to the contents).

Need to do some research on patterns based on how we plan to support this for each platform. Initially I was thinking a basic glob(ish) pattern.

However we may be better off doing a simple prefix match as well.

tjholm commented 1 year ago

Ways we can support this functionality:

AWS:

GCP:

Azure:

tjholm commented 1 year ago

Three things that need to be designed for this:

HomelessDinosaur commented 1 year ago

https://www.notion.so/nitric/Subscribing-to-resource-notifications-da31f63ac01340938b0a60fed6cd457c