openformation / strawman

A Deno-based service virtualization solution

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement a Websocket interface that allows to control strawman remotely

grebaldi opened this issue · comments

It should be possible to remote control a strawman-server instance.

To achieve this, a websocket interface is to be implemented in the scope of this issue.

This interface should allow for calling application services of strawman-core and to exchange log messages coming from the strawman-server instance.

It should follow the JSON-RPC Protocol (version 2.0).

It should live in modules/strawman-server-rc and be invoked as in both the capture and the replay command of strawman-server-cli.

Regarding log message exchange:

Currently, log messages are simply being written via console.log or similar methods. In the scope of this issue, logging should be moved to a dedicated event bus.

To achieve the exchange, strawman-server-rc should treat all its clients as JSON-RPC-servers themselves to allow for duplex communication.

Further resources:


Edit 2022-01-27 13:53:

It turns out, this feature is quite difficult to unravel from the current state of affairs. After some investigation and one failed attempt to approach this problem, I identified the following TODOs:

  • Introduce a Mode concept to the domain layer of strawman-core
    • This will provide a strategy-like approach to the distinction between the replay and capture functionalities
  • Merge the captureRequest and replayRequest application services into a single handleHttpRequest service
    • This service will use the Mode concept to decide whether to capture or to replay the request
  • Implement an event-bus-driven logger.
    • This should probably go into a separate module
    • It should also cover the existing logError function
  • Implement the rc server
  • Merge the capture and replay commands of strawman-cli-server into a single start command
    • This command will start both the http and the rc server