Skip to content

refactor: update node ws channel code#3241

Merged
bytemain merged 66 commits intomainfrom
feat/rpc2
Jan 16, 2024
Merged

refactor: update node ws channel code#3241
bytemain merged 66 commits intomainfrom
feat/rpc2

Conversation

@bytemain
Copy link
Copy Markdown
Member

@bytemain bytemain commented Dec 13, 2023

Types

  • 🪚 Refactors

Background or solution

针对 CommonHandler 的改造,能使其在后期兼容 Electron 端

介绍一下这次的改动:
第一个大改动就是统一所有的通信到 WSChannel,WSChannel 发送的数据包都是 fury 序列化后的,移除了目前所有的写死的依赖 jsonrpc 的 MessageConnection 的地方,都换成了 WSChannel

然后就是一些新增的代码,抽象出不同的通道(WS, net.Socket)的通信代码。

第二个就是优化了一下 RPCCenter 的架构,主要是代码重构,没有改太多逻辑,增加了一层 Proxy 抽象(方便加入 SumiRPC)。

第三个就是前后端通信都改成 WSChannel,无论 electron web,也优化了下 ws-channel 的通信消息

第四个就是 ext host 通信和 temrinal 通信改成 ws channel

@opensumi opensumi Bot added the ⚙️ refactor Refactor code label Dec 13, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 14, 2023

Codecov Report

Attention: 240 lines in your changes are missing coverage. Please review.

Comparison is base (32419c9) 57.62% compared to head (77d3d21) 57.70%.

Files Patch % Lines
...ckages/connection/src/common/connection/buffers.ts 73.50% 31 Missing ⚠️
.../connection/src/common/connection/drivers/utils.ts 10.34% 25 Missing and 1 partial ⚠️
packages/extension/src/node/extension.service.ts 12.50% 18 Missing and 3 partials ⚠️
...kages/connection/src/browser/ws-channel-handler.ts 68.75% 15 Missing ⚠️
...src/common/connection/drivers/node-message-port.ts 12.50% 14 Missing ⚠️
packages/core-node/src/connection.ts 22.22% 14 Missing ⚠️
...connection/src/common/connection/drivers/socket.ts 62.50% 12 Missing ⚠️
packages/core-browser/src/bootstrap/connection.ts 69.23% 12 Missing ⚠️
packages/connection/src/common/ws-channel.ts 84.50% 11 Missing ⚠️
...ages/connection/src/node/common-channel-handler.ts 77.55% 11 Missing ⚠️
... and 17 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3241      +/-   ##
==========================================
+ Coverage   57.62%   57.70%   +0.07%     
==========================================
  Files        1340     1357      +17     
  Lines       84557    84943     +386     
  Branches    17590    17639      +49     
==========================================
+ Hits        48728    49018     +290     
- Misses      32560    32654      +94     
- Partials     3269     3271       +2     
Flag Coverage Δ
jsdom 52.58% <52.93%> (+0.04%) ⬆️
node 17.08% <65.08%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread packages/connection/src/common/utils.ts Outdated
Comment thread packages/connection/src/common/ws-channel.ts Outdated
@bytemain bytemain changed the title WIP: refactor: update node ws channel code refactor: update node ws channel code Jan 11, 2024
@bytemain
Copy link
Copy Markdown
Member Author

我介绍一下这次的改动:
第一个大改动就是统一所有的通信到 WSChannel,WSChannel 发送的数据包都是 fury 序列化后的,移除了目前所有的写死的依赖 jsonrpc 的 MessageConnection 的地方,都换成了 WSChannel

然后就是一些新增的代码,抽象出不同的通道(WS, net.Socket)的通信代码。

第二个就是优化了一下 RPCCenter 的架构,主要是代码重构,没有改太多逻辑,增加了一层 Proxy 抽象(方便加入 SumiRPC)。

第三个就是前后端通信都改成 WSChannel,无论 electron web,也优化了下 ws-channel 的通信消息

第四个就是 ext host 通信和 temrinal 通信改成 ws channel

Comment thread packages/connection/src/common/proxy/legacy.ts
Copy link
Copy Markdown
Member

@erha19 erha19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bytemain bytemain merged commit c899849 into main Jan 16, 2024
@bytemain bytemain deleted the feat/rpc2 branch January 16, 2024 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️ refactor Refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants