The Rembus 1.0.0 version retains much of the original API while taking a significant step forward in the spirit of providing a simple yet powerful way to build distributed applications.
What Makes Rembus Unique?
Rembus is a infrastructure-free middleware for distributed applications, with a broker
process that routes between nodes and can be used as a general-purpose library for building customs distributed applications.
For example if you don’t need a broker but simply two remote components to communicate with each other you can use Rembus to setup a direct connection between them.
See the docs for some more details.
A Client-Server Architecture
Suppose you have to transfer a Julia DataFrame to a remote process that needs to consume it as a Pandas DataFrame.
This is how Rembus can help you to solve this case:
The julia server
using Rembus
using DataFrames
function get_julia_dataframe()
return DataFrame(:name=>["name_$i" for i in 1:10], :x=>1:10, :y=>rand(10))
end
rb = component("julia_server", ws=8000)
expose(rb, get_julia_dataframe)
wait(rb)
The python client
After installing the python rembus
package:
pip install rembus
Invoke the RPC service implemented in julia and get the pandas dataframe as
response:
import rembus
rb = rembus.node()
df = rb.rpc("get_julia_dataframe")
A Rembus glimpse: Distributed REPLs
Rembus is designed for long-running distributed applications, but let’s start with a simple example: a distributed REPL system for exchanging data and computations.
This approach enables rapid prototyping of distributed applications.
Step 1: Start a Broker
A broker component routes messages between distributed applications.
It listens on port 8000
for WebSocket clients.
# REPL_1
using Rembus
broker = component(ws=8000)
Step 2: Create a Subscriber
A component subscribes to a topic and reacts to incoming messages.
# REPL_2
using Rembus
sub = component("mysubscriber")
function mytopic(msg)
println("Received message: $msg")
end
subscribe(sub, mytopic)
reactive(sub) # Commands the broker to stream messages to this subscriber
Step 3: Publish Messages
A publisher component sends messages to the topic.
# REPL_3
using Rembus
pub = component("mypublisher")
publish(pub, "mytopic", "Hello World")
At this point, we’ve implemented a basic Pub/Sub system with:
A broker (message router)
A subscriber (listens for messages)
A publisher (sends messages)
Step 4: Expose a Remote Function
Now, let’s make things interesting:
We’ll extend the broker to expose a new function mysum
, making it accessible from other REPLs.
# REPL_1
mysum(x, y) = x + y + 0.1
expose(broker, mysum)
Step 5: Call the Remote Function
From any REPL, we can now invoke the exposed function remotely:
# REPL_2
result = rpc(sub, "mysum", 1, 2)
# REPL_3
result = rpc(pub, "mysum", 3, 4)
Just like that, we’ve built a distributed system that supports both Pub/Sub and Remote Procedure Calls (RPC)!
What’s Next?
I’d love your input on how Rembus can evolve.
Try it out, report issues, and suggest improvements!
Star the project
if you find it useful!