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

[SPEC] Emulator Core Rewrite #1969

Closed
tonyanziano opened this issue Nov 5, 2019 · 2 comments
Closed

[SPEC] Emulator Core Rewrite #1969

tonyanziano opened this issue Nov 5, 2019 · 2 comments
Assignees

Comments

@tonyanziano
Copy link
Contributor

tonyanziano commented Nov 5, 2019

The Problem

The emulator/core package is responsible for the REST server that emulates both the DirectLine service and the back end of the "channel."

This package also contains a per-session storage layer (in memory) that keeps track of everything the "channel" cares about: Current users, bot state, conversations, activities within conversations, etc. However, the only way to see into this storage layer and manipulate it is from the main process of the application. This means that reading or writing to this layer from the renderer process requires the use of IPC.

The Solution

We can leverage the fact that there is no network latency between the renderer and main processes of the Emulator to allow us to perform CRUD operations on the channel storage layer, as well as many other main process functions. This can be done by exposing an API that can be hit directly from the renderer process using fetch.

This will allow us to declaratively start new conversations, get activities for a conversation, and even do things like check for application updates.

I believe that the source for the code package can also be trimmed down and moved into the app/main package, because it is slightly confusing in its current state.

Pros:

  • Exposes the "channel" storage layer to the renderer process directly through an API instead of having to go through Electron's IPC
  • Has the potential to also map other main process functionality to the API (checking for application updates, reading / writing from disk, interacting with ngrok, etc)
  • If functionality is mapped to a REST server, then we can use Restify's 'after' route handler to generate an audit log of what the application was doing to help debug crashes & errors

Cons:

  • Affected code is pivotal for the core scenarios of the Emulator
  • Significant code churn on the main side
  • Lack of pre-existing e2e testing for core functionality to compare against when complete
@tonyanziano tonyanziano self-assigned this Nov 5, 2019
@tonyanziano
Copy link
Contributor Author

tonyanziano commented Nov 7, 2019

Iterative Plan (To minimize size of PRs)

1st Pull Request

  • Initial infrastructure
    • Move /emulator/core to app/main/server
    • Change folder structure of what used to be /emulator/core
  • Same functionality as before. No no features / additions

2nd Pull Request

  • Additional Emulator endpoints for specific functionality (triggering a new conversation, checking for updates, etc.)
  • Updating renderer process to use the new endpoints instead of IPC where applicable

3rd Pull Request (After Web Socket work)

  • TBD... (Logging improvements?)

@cwhitten
Copy link
Member

addressed in #1989

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants