Giter Club home page Giter Club logo

procbridge's Introduction

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.

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, Node.js, Swift, and C#. 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

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 ([email protected])

procbridge's People

Contributors

cnico avatar dreo avatar gongzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

procbridge's Issues

Swift Support

Hi,

I created a Swift backend for a temporary project that needed IPC between Swift and Kotlin. My temporary project is over, but this bridge is worth keeping. I'm using the new Network Framework which is nice but it requires macOS 10.14 or later. That requirement is configured inside Package.swift.

I don't have as much experience in Swift as I have in other languages, but the implementation is acceptably clean and it could be a good starting point for your "official" backend:

https://github.com/royalstream/procbridge-swift

If you like it, perhaps you can create an empty repository on your side and I can submit this implementation as a Pull Request. I could also transfer the repository but that's something I've never done before, so I'm not sure how that works.

Best,

SB

help pls

I would like to ask, how do I make it so that (let's say a chat) others have messages visible, etc. or how does it work? because I don't see any connections except 127.0.0.1:port (either I'm so stupid or xs)

[python]

Traceback (most recent call last):
  File "c:\Users\name\Documents\python\procbridgetest\main.py", line 32, in <module>
    from procbridge import ProcBridgeServer
ImportError: cannot import name 'ProcBridgeServer'

Python 3.6.4
procbridge 1.0.3

solution was to add below to procbridge/__init__.py:

from procbridge.procbridge import ProcBridgeServer, ProcBridge

Communication has a big latency

Waiting for a server's response seems to normally take around ~5000ms.

How to reproduce:

I have tested this with the following scenario:

Client side (Kotlin(JVM)):

import co.gongzh.procbridge.Client

val procClient = Client(
    "0.0.0.0",
    8000
)

    val start = System.currentTimeMillis()
    procClient.request("ping", null)
    println("Latency : ${System.currentTimeMillis() - start}ms")

Server side (Python):

import procbridge as pb


def handler(method, args):
    if method == "initialtest1":
        return "Initial test 1 triggered"
    if method == "initialtest2":
        return "Initial test 2 triggered"
    if method == "echo":
        return args
    if method == "ping":
        return "pong"


if __name__ == '__main__':
    port = 8000 
    s = pb.Server('0.0.0.0', port, handler)
    s.start(daemon=False)
    print("Procbridge server is on {}...".format(port))

Run it several time or put it in a loop.
You should get a similar result:

Latency : 5020ms
Latency : 1ms
Latency : 5001ms
Latency : 5009ms
Latency : 5003ms
Latency : 5004ms
Latency : 5004ms
Latency : 5003ms
Latency : 5004ms
Latency : 3ms
Latency : 2ms
Latency : 5008ms
Latency : 1ms
Latency : 5ms
Latency : 5008ms
Latency : 1ms
Latency : 1ms
Latency : 2ms
Latency : 5010ms
Latency : 5004ms
Latency : 5003ms
Latency : 5004ms
Latency : 5006ms
Latency : 5002ms

Unix Domain socket support

Hi. By any change is unix domain socket support in the plans? Sometime we just need IPC between process running in the same machine

Can you make a document for this project?

It took me three hours to understand how this thing works. No explanatory notes are hard to understand how this works and how to use it

And ChatGPT helps me a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.