Packages
snakepit
0.3.1
0.13.0
0.12.0
0.11.1
0.11.0
0.10.1
0.10.0
0.9.1
0.9.0
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.11
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
High-performance pooler and session manager for external language integrations. Supports Python, Node.js, Ruby, and more with gRPC streaming, session management, and production-ready process cleanup.
Current section
Files
Jump to
Current section
Files
lib/snakepit/adapters/generic_python_msgpack.ex
defmodule Snakepit.Adapters.GenericPythonMsgpack do
@moduledoc """
Generic Python adapter for Snakepit using MessagePack protocol.
This adapter uses the v2 bridge with MessagePack support for improved performance:
- 1.3-2.3x faster for regular data
- 55x faster for binary data
- 18-36% smaller message sizes
## Configuration
config :snakepit,
adapter_module: Snakepit.Adapters.GenericPythonMsgpack
## Supported Commands
Same as GenericPython adapter:
- `ping` - Health check and basic info
- `echo` - Echo arguments back (useful for testing)
- `compute` - Simple math operations (add, subtract, multiply, divide)
- `info` - Bridge and system information
"""
@behaviour Snakepit.Adapter
@impl true
def executable_path do
System.find_executable("python3") || System.find_executable("python")
end
@impl true
def script_path do
# Use the v2 bridge that supports MessagePack
case :code.priv_dir(:snakepit) do
{:error, :bad_name} ->
# Development mode - use relative path from current working directory
Path.join([File.cwd!(), "priv", "python", "generic_bridge_v2.py"])
priv_dir ->
Path.join(priv_dir, "python/generic_bridge_v2.py")
end
end
@impl true
def script_args do
["--mode", "pool-worker"]
end
@impl true
def supported_commands do
["ping", "echo", "compute", "info", "store", "retrieve"]
end
@impl true
def validate_command(command, _args) do
if command in supported_commands() do
:ok
else
{:error, "Unsupported command: #{command}"}
end
end
end