rpc_clients

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package rpc_clients provides a common interface for different RPC protocols to enable fair performance comparison over Unix Domain Sockets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkConfig

type BenchmarkConfig struct {
	UDSPath     string        // Unix Domain Socket path
	Timeout     time.Duration // Request timeout
	MaxRetries  int           // Maximum retry attempts
	WarmupCalls int           // Number of warmup calls before measurement
}

BenchmarkConfig holds configuration for benchmark testing

type BenchmarkResult

type BenchmarkResult struct {
	Protocol    string        // Protocol name
	PayloadSize string        // Payload size category
	Latency     time.Duration // Average latency
	Throughput  float64       // Requests per second
	ErrorRate   float64       // Percentage of failed requests
	CPUUsage    float64       // Average CPU usage percentage
	MemoryUsage int64         // Memory usage in bytes
}

BenchmarkResult stores the results of a benchmark run

type JSONRPCClient

type JSONRPCClient struct {
	// contains filtered or unexported fields
}

JSONRPCClient implements JSON-RPC 2.0 protocol over Unix Domain Socket

func NewJSONRPCClient

func NewJSONRPCClient() *JSONRPCClient

NewJSONRPCClient creates a new JSON-RPC client

func (*JSONRPCClient) Call

func (c *JSONRPCClient) Call(ctx context.Context, method string, args interface{}, reply interface{}) error

Call invokes a JSON-RPC method

func (*JSONRPCClient) Close

func (c *JSONRPCClient) Close() error

Close terminates the connection

func (*JSONRPCClient) Connect

func (c *JSONRPCClient) Connect(udsPath string) error

Connect establishes connection to JSON-RPC server via UDS

func (*JSONRPCClient) Name

func (c *JSONRPCClient) Name() string

Name returns the protocol identifier

type JSONRPCError

type JSONRPCError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

JSONRPCError represents a JSON-RPC 2.0 error

type JSONRPCRequest

type JSONRPCRequest struct {
	JSONRPC string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
	ID      uint64      `json:"id"`
}

JSONRPCRequest represents a JSON-RPC 2.0 request

type JSONRPCResponse

type JSONRPCResponse struct {
	JSONRPC string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *JSONRPCError   `json:"error,omitempty"`
	ID      uint64          `json:"id"`
}

JSONRPCResponse represents a JSON-RPC 2.0 response

type MsgpackRPCClient

type MsgpackRPCClient struct {
	// contains filtered or unexported fields
}

MsgpackRPCClient implements MessagePack-RPC protocol over Unix Domain Socket

func NewMsgpackRPCClient

func NewMsgpackRPCClient() *MsgpackRPCClient

NewMsgpackRPCClient creates a new MessagePack-RPC client

func (*MsgpackRPCClient) Call

func (c *MsgpackRPCClient) Call(ctx context.Context, method string, args interface{}, reply interface{}) error

Call invokes a MessagePack-RPC method

func (*MsgpackRPCClient) Close

func (c *MsgpackRPCClient) Close() error

Close terminates the connection

func (*MsgpackRPCClient) Connect

func (c *MsgpackRPCClient) Connect(udsPath string) error

Connect establishes connection to MessagePack-RPC server via UDS

func (*MsgpackRPCClient) Name

func (c *MsgpackRPCClient) Name() string

Name returns the protocol identifier

type MsgpackRequest

type MsgpackRequest struct {
	Type   uint8       // 0 for request
	MsgID  uint32      // Message ID
	Method string      // Method name
	Params interface{} // Parameters
}

MsgpackRequest represents a MessagePack-RPC request Format: [type, msgid, method, params]

type MsgpackResponse

type MsgpackResponse struct {
	Type   uint8       // 1 for response
	MsgID  uint32      // Message ID
	Error  interface{} // Error if any
	Result interface{} // Result value
}

MsgpackResponse represents a MessagePack-RPC response Format: [type, msgid, error, result]

type PyprocClient

type PyprocClient struct {
	// contains filtered or unexported fields
}

PyprocClient wraps the existing pyproc Pool to implement RPCClient interface

func NewPyprocClient

func NewPyprocClient(pythonExec, workerScript string) *PyprocClient

NewPyprocClient creates a new pyproc client instance

func (*PyprocClient) Call

func (c *PyprocClient) Call(ctx context.Context, method string, args interface{}, reply interface{}) error

Call invokes a method on the pyproc worker

func (*PyprocClient) Close

func (c *PyprocClient) Close() error

Close shuts down the pyproc worker

func (*PyprocClient) Connect

func (c *PyprocClient) Connect(udsPath string) error

Connect establishes connection to the pyproc worker

func (*PyprocClient) Name

func (c *PyprocClient) Name() string

Name returns the protocol identifier

type RPCClient

type RPCClient interface {
	// Connect establishes a connection to the RPC server via Unix Domain Socket
	Connect(udsPath string) error

	// Call invokes a remote method with given arguments and stores the reply
	Call(ctx context.Context, method string, args interface{}, reply interface{}) error

	// Close terminates the connection and cleans up resources
	Close() error

	// Name returns the protocol name for identification in benchmarks
	Name() string
}

RPCClient defines the common interface for all RPC protocol implementations. Each implementation must provide connection management and call functionality.

type TestPayload

type TestPayload struct {
	Size   string      // "small", "medium", "large"
	Method string      // RPC method to call
	Data   interface{} // Actual payload data
}

TestPayload represents different payload sizes for benchmarking

func LargePayload

func LargePayload() TestPayload

Large payload (~1MB) - Data transfer scenario

func MediumPayload

func MediumPayload() TestPayload

Medium payload (~2KB) - Typical API request

func SmallPayload

func SmallPayload() TestPayload

Small payload (~64 bytes) - Simple operation

type XMLRPCClient

type XMLRPCClient struct {
	// contains filtered or unexported fields
}

XMLRPCClient implements XML-RPC protocol over Unix Domain Socket

func NewXMLRPCClient

func NewXMLRPCClient() *XMLRPCClient

NewXMLRPCClient creates a new XML-RPC client

func (*XMLRPCClient) Call

func (c *XMLRPCClient) Call(ctx context.Context, method string, args interface{}, reply interface{}) error

Call invokes an XML-RPC method

func (*XMLRPCClient) Close

func (c *XMLRPCClient) Close() error

Close terminates the connection

func (*XMLRPCClient) Connect

func (c *XMLRPCClient) Connect(udsPath string) error

Connect establishes connection to XML-RPC server via UDS

func (*XMLRPCClient) Name

func (c *XMLRPCClient) Name() string

Name returns the protocol identifier

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL