Skip to content

Emit bedrock events on actions #27

@aljones15

Description

@aljones15

Proposal:

After an action happens bedrock-edv-storage will emit an event with data for each event that just occurred. Because the invoker is important events should fire from the HTTP API layer after the event has happened. Currently all we need is an event that fires after a stream has begun.

POST /edvs/:edvId/documents/:docId/chunks/:chunkIndex

const eventData {
  docId,
  edvId,
  invoker,
  controller
}
await bedrodk.emit('bedrock-edv-storage.chunk-post-insert', eventData);

GET /edvs/:edvId/documents/:docId/chunks/:chunkIndex

// only emit on the first chunk to prevent excessive events
if (chunkIndex === 0) {
  const eventData {
    docId,
    edvId,
    invoker,
    controller
  };
  await bedrodk.emit('bedrock-edv-storage.chunk-stream-started', eventData);
}

POST /edvs
Emits:

const eventData = {
  actor,
  controller,
  edvId: id
}
await bedrock.emit('bedrock-edv-storage.edv-post-insert', eventData);

Further events can be added to other endpoints. The chunk one for streams is really the hard one as we can't reliably determine if a stream has finished with out some work.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions