This directory contains JSON-RPC client written in Go. The main goal is to ease communication with
SPDK over Unix and TCP socket in Go. In addition, this repository provides integration of a client
with rpc.py
- Go client replaces Python client.
Requirements:
go
(v1.21 or above)
There are two ways to build files required for client replacement:
- Manual - go to go/rpc and invoke
make
- During configuration part of SPDK add
--with-golang
flag.
After successful installation you will be able to use Go client from within rpc.py
rpc.py --go-client RPC_COMMAND
If you want to use Go client for every RPC command of rpc.py
without adding --go-client
flag
you can define a new environment
variable
SPDK_JSONRPC_GO_CLIENT=1
Examples how to integrate this client into your Go code can be found here
Client is a main component of RPC client. It is responsible for sending and receiving JSON-RPC 2.0 calls.
Sends RPC call with specified method and parameters.
Input:
method
: Name of the method to be invoked.params
: Set of parameters to be used during invocation of the method.
Output:
response
: Response for rpc call. Contains version of JSON-RPC protocol, id, error or result.error
: Contains error if something goes wrong during creation of a request or sending/receiving rpc call. Otherwisenil
.
Close method closes connection with underlying stream.
Output:
error
: Contains error when closing a stream fails. Otherwisenil
.
Struct represents JSON-RPC 2.0 Request object. For more information please visit jsonrpc.org/specification#request_object
Struct represents JSON-RPC 2.0 Response object. For more information please visit jsonrpc.org/specification#response_object
Struct represents JSON-RPC 2.0 Error object. For more information please visit jsonrpc.org/specification#error_object
This method creates a new JSON-RPC 2.0 client. Both Unix and TCP sockets are supported.
Input:
network
: Type of network. Bothunix
andtcp
are supported.address
: Address to given network.
Output:
client
: New Client struct.error
: Contains error if something goes wrong during creation of a client. Otherwisenil
.