Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Server-Side Events in commands #1364

Open
javiertoledo opened this issue Mar 2, 2023 · 1 comment
Open

Add support for Server-Side Events in commands #1364

javiertoledo opened this issue Mar 2, 2023 · 1 comment
Labels
dev-experience Developer Experience difficulty: medium feature-request New feature or request provider:multicloud Affects multiple cloud providers size: XL A task that due to its size could be considered a project itself. spike

Comments

@javiertoledo
Copy link
Member

Feature Request

Description

It would be nice to have a way to use Server-Side Events (SSE) in commands. SSE is a technology that allows a client to receive partial real-time updates from a server using an HTTP connection that is kept alive during the process. This feature can be useful for client applications that need to implement partial updates as some long-during action is performed.

For example, imagine a command that triggers a complex workflow that involves multiple steps and takes some time to complete. The client application could use SSE to receive notifications about the progress of each step and update the UI accordingly.

Possible Solution

One possible solution is to add a new method to the Register class that allows sending events to the client. For example:

@Command({
  authorize: 'all'
})
export class MyCommand {
  public constructor(
    readonly field1: string,
    readonly field2: string
  ) {}

  public async handle(register: Register): Promise<void> {
    // Do some initial work
    register.sendEvent('Step 1 completed')
    // Do some more work
    register.sendEvent('Step 2 completed')
    // Finalize work
    register.sendEvent('Done')
  }
}

The sendEvent method would deliver the events to the client via SSE.

Additional information

There is an open question about how to implement SSE over GraphQL, since Booster Framework uses GraphQL mutations to access commands. There are two possible options:

  • Option 1: Use a separate endpoint and a protocol that implements the GraphQL over SSE technique described here.
  • Option 2: Implement the possibility to run commands over a WebSocket,making it possible for the client to subscribe to partial updates.

It would be a good idea to perform a small research on these options and decide which one is more suitable or if there are other options.

@javiertoledo javiertoledo added feature-request New feature or request size: XL A task that due to its size could be considered a project itself. spike provider:multicloud Affects multiple cloud providers dev-experience Developer Experience difficulty: medium labels Mar 2, 2023
@Virajjai
Copy link

Hi @javiertoledo can i work on this and could you please explain a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-experience Developer Experience difficulty: medium feature-request New feature or request provider:multicloud Affects multiple cloud providers size: XL A task that due to its size could be considered a project itself. spike
Projects
Development

No branches or pull requests

2 participants