A high-performance, peer-to-peer RPC library that makes remote objects feel local. Built on top of Yamux multiplexing and Go's reflection, it enables seamless bi-directional interaction between processes with support for callbacks, distributed garbage collection, and stream pooling.
- Peer-to-Peer Architecture: No strict client/server distinction — both sides can import and export objects, enabling true bi-directional communication.
- Cursor-Based API: Chain property accesses and method calls using
ProxyCursorwith.Get()and.Apply(), then execute synchronously or asynchronously. - Distributed Garbage Collection: Automatically manages remote object lifecycles using Go's
runtime.SetFinalizerand a reference counting protocol. - Bi-Directional Callbacks: Pass functions as arguments — they are automatically registered and invoked remotely.
- Stream Pooling: Reuses Yamux substreams to eliminate handshake overhead for high-frequency calls.
- Context Support: Full
context.Contextintegration for cancellation and timeouts.
go get github.com/stateforward/proxyables.goServer (Exporting an object):
import "github.com/stateforward/proxyables.go"
type API struct{}
func (a *API) Echo(msg string) string {
return "echo " + msg
}
func (a *API) Compute(a1, b int) int {
return a1 + b
}
// conn is any net.Conn or io.ReadWriteCloser
exported, _ := proxyables.Export(conn, &API{}, nil)Client (Importing the object):
import "github.com/stateforward/proxyables.go"
proxy, _, _ := proxyables.ImportFrom(conn, nil)
// Chain instructions and execute
result := <-proxy.Get("Echo").Apply("hello").Await(ctx)
if result.Error != nil {
panic(result.Error)
}
_ = result.Value // "echo hello"
result = <-proxy.Get("Compute").Apply(10, 20).Await(ctx)
if result.Error != nil {
panic(result.Error)
}
_ = result.Value // 30- Proxy Layer:
ProxyCursorbuilds instruction chains for remote execution. - Instruction Protocol: Operations (get, apply, etc.) are serialized into
ProxyInstructionmessages using MessagePack. - Transport: Uses
hashicorp/yamuxto multiplex concurrent operations over a single connection. - Reference Management: An
ObjectRegistrytracks local objects with reference counting and deduplication. - Stream Pool: Maintains idle Yamux streams for reuse, reducing allocation overhead.
MIT