nitrictech/nitric

Design: Subscribe to bucket changes

tjholm opened this issue · 6 comments

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

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
});

qq's

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

@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.

Three things that need to be designed for this:

  • SDK interfaces (core developer experience).
  • Runtime interfaces (how we register workers and route events at runtime).
  • Deployment interfaces (how we express these in the nitric cloud spec, for providers to deploy).