java跨进程通信_一个基于 Socket + JSON 的轻量级跨进程通信机制

ProcBridge是一种基于TCP套接字的超轻量级IPC(进程间通信)协议,允许简单地在进程间发送和接收JSON数据。它类似于HTTP协议的简化版,但仅传输JSON值。在服务器端定义处理请求并返回结果的函数,在客户端同步发出请求并获取结果。ProcBridge已用Java、Python和Node.js实现,适用于HTTP和RPC过于复杂的情况。
摘要由CSDN通过智能技术生成

logo.png68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f676f6e677a68616e672f70726f636272696467652e73766768747470733a2f2f696d672e736869656c64732e696f2f707970692f707976657273696f6e732f70726f636272696467652e73766768747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6176612d382d627269676874677265656e2e73766768747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f64652e6a732d382d7265642e737667

1. Introduction

ProcBridge is a super-lightweight IPC (Inter-Process Communication) protocol over TCP socket. It enables you to send and recieve JSON between processes easily. ProcBridge is much like a simplified version of HTTP protocol, but only transfer JSON values.

concept.png

On the server side, you define a function which handles requests and returns result. On the client side, you just make request and get results synchronously. Both requests and responses are wildcard JSON values (null, boolean, number, string, object, and array).

ProcBridge has been implemented in Java, Python, and Node.js. If you want to connect two processes and HTTP & RPC are too heavy for your scenario, then ProcBridge will be an ideal choice.

2. Instructions & Example

Please go to sub-repos for more information.

3. Protocol Design

protocol.png

Both request and response are encoded into ProcBridge Packets. Those binary packets are sent over TCP socket directly. Talk is cheap, please read Python implementation to fully understand the protocol design.

4. Collaboration

👀 Note for Early Collaborators (2019-01-10)

The library implementations have been refactored and migrated to sub-repos as described above. From now on, this repo only stores docs. If you worked on master branch before, please switch to legacy branch. Thank you for your understanding and support.

😼

Below is the collaboration guideline:

✨ Extend the protocol

If you want to extend the protocol, for example:

support packet compression

support bidirectional communication

support long connection and event-based communication

define conventions to method name or JSON body

Please open an issue first.

✨ Implement the protocol

You can quickly implement ProcBridge in any other programming languages. Note that it only takes 300 lines of code to fully implement the protocol in Python. Please name your repo like procbridge-xxx where xxx is your programming language. Don't forget to open an issue to let me know it.

✨ Improve existing implementation

Cool. Please open PR in sub-repos.

5. Contacts

👨🏻‍💻 Gong Zhang (gong@me.com)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值