VarSync is a lightweight, real-time variable sharing system that allows Python and JavaScript (Node.js) processes on the same machine to share variables through a Go core backend.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Python │ │ Node.js │ │ Go │
│ Wrapper │ │ Wrapper │ │ Core │
│ │ │ │ │ │
│ set_var() │ │ setVar() │ │ In-Memory │
│ get_var() │ │ getVar() │ │ Key-Value │
│ delete_var()│ │ deleteVar() │ │ Store │
│ list_vars() │ │ listVars() │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
└───────────────────┼───────────────────┘
│
TCP/Unix Socket
JSON Protocol
- Real-time variable sharing between Python and Node.js processes
- Lightweight Go core with in-memory key-value store
- Concurrent access with proper locking mechanisms
- Cross-platform support (Linux, macOS, Windows)
- Simple JSON protocol for communication
- Automatic connection management and error handling
- Support for primitive data types (strings, numbers, booleans)
- JSON serialization for complex objects
cd core
go build -o varsync
./varsyncThe core will start listening on localhost:8080 by default.
from varbridge import VarSync
# Connect to the core
vs = VarSync()
# Set variables
vs.set_var("user_count", 42)
vs.set_var("status", "active")
vs.set_var("data", {"name": "John", "age": 30})
# Get variables
count = vs.get_var("user_count") # 42
status = vs.get_var("status") # "active"
data = vs.get_var("data") # {"name": "John", "age": 30}
# List all keys
keys = vs.list_vars() # ["user_count", "status", "data"]
# Delete a variable
vs.delete_var("status")const VarSync = require('varbridge-js');
// Connect to the core
const vs = new VarSync();
// Set variables
vs.setVar("user_count", 42);
vs.setVar("status", "active");
vs.setVar("data", {name: "John", age: 30});
// Get variables
const count = vs.getVar("user_count"); // 42
const status = vs.getVar("status"); // "active"
const data = vs.getVar("data"); // {name: "John", age: 30}
// List all keys
const keys = vs.listVars(); // ["user_count", "status", "data"]
// Delete a variable
vs.deleteVar("status");cd core
go build -o varsynccd varbridge-py
pip install -e .cd varbridge-js
npm installSee the examples/ directory for complete working examples:
examples/python_node_example.py- Python exampleexamples/node_python_example.js- Node.js exampleexamples/cross_language_demo.py- Cross-language demonstration
The communication protocol uses JSON messages over TCP:
{
"cmd": "SET|GET|DELETE|LIST_KEYS",
"key": "variable_name",
"value": "variable_value"
}{
"status": "success|error",
"data": "response_data",
"error": "error_message"
}VarSync/
├── core/ # Go core implementation
├── varbridge-py/ # Python wrapper
├── varbridge-js/ # Node.js wrapper
├── examples/ # Usage examples
└── README.md
- Go Core:
cd core && go build -o varsync - Python:
cd varbridge-py && pip install -e . - Node.js:
cd varbridge-js && npm install
MIT License - see LICENSE file for details.