Unify JSON-RPC servers and make JSON-RPC optional #23

Open
opened 2021-11-13 13:07:00 +00:00 by glyph · 1 comment
Owner

Detailing some thoughts here from a conversation with @notplants :

Having multiple JSON-RPC microservices is great for modularity and interoperability but not so great for simplicity and minimising resource use.

One option is to group all JSON-RPC servers into one and allow selecting feature sets through configuration variables. For example, configuring the server to only expose RPCs for networking and stats while disabling the OLED features. This would mean we have a single binary running as a single process running on a single port; much easier in terms of devops, versioning, updating and system deployment.

An additional change would be to make the JSON-RPC server completely optional by separating the business logic of each microservice and placing it in a common library. Crate organisation might then look like this:

# contains core logic, such as wpasupplicant commands for networking
peach-lib
# wraps functionality from peach-lib and exposes it via RPC
peach-jsonrpc-server
# provides client methods for making RPC calls against the server
peach-jsonrpc-client

This would allow a single binary to bundle the entirety of the functionality currently exposed through the PeachCloud web interface (not including configuration, static assests etc.). One of the major advantages of this approach is optimising for minimal resource use.

A follow-on refactor would be to bundle peach-menu, peach-buttons and peach-oled into a single binary for the physical menu system.

Detailing some thoughts here from a conversation with @notplants : Having multiple JSON-RPC microservices is great for modularity and interoperability but not so great for simplicity and minimising resource use. One option is to group all JSON-RPC servers into one and allow selecting feature sets through configuration variables. For example, configuring the server to only expose RPCs for networking and stats while disabling the OLED features. This would mean we have a single binary running as a single process running on a single port; much easier in terms of devops, versioning, updating and system deployment. An additional change would be to make the JSON-RPC server completely optional by separating the business logic of each microservice and placing it in a common library. Crate organisation might then look like this: ```bash # contains core logic, such as wpasupplicant commands for networking peach-lib # wraps functionality from peach-lib and exposes it via RPC peach-jsonrpc-server # provides client methods for making RPC calls against the server peach-jsonrpc-client ``` This would allow a single binary to bundle the entirety of the functionality currently exposed through the PeachCloud web interface (not including configuration, static assests etc.). One of the major advantages of this approach is optimising for minimal resource use. A follow-on refactor would be to bundle `peach-menu`, `peach-buttons` and `peach-oled` into a single binary for the physical menu system.
glyph added the
refactor
label 2021-11-13 13:09:43 +00:00
Author
Owner

I may have just created peach-jsonrpc-client (Saturday-evening desire to program).

It only has four dependencies and provides RPC client functions for peach-network, peach-oled and peach-stats. I've replaced snafu with a custom error implementation and serde with miniserde.

log = "0.4"
jsonrpc-client-core = "0.5"
jsonrpc-client-http = "0.5"
miniserde = "0.1.15"

The RPC client code for calling the dyndns-server still needs to be extracted from peach-lib.

Just figured I'd mention this here so we know it's in the bag if / when we wish to do this refactor.

I may have just created `peach-jsonrpc-client` (Saturday-evening desire to program). It only has four dependencies and provides RPC client functions for `peach-network`, `peach-oled` and `peach-stats`. I've replaced `snafu` with a custom error implementation and `serde` with `miniserde`. ```yaml log = "0.4" jsonrpc-client-core = "0.5" jsonrpc-client-http = "0.5" miniserde = "0.1.15" ``` The RPC client code for calling the dyndns-server still needs to be extracted from `peach-lib`. Just figured I'd mention this here so we know it's in the bag if / when we wish to do this refactor.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: PeachCloud/peach-workspace#23
No description provided.