Commit 3142d569 authored by Boris Glimcher's avatar Boris Glimcher Committed by Tomasz Zawadzki
Browse files

go/rpc: add interface for Client



this is mostly going to be used with mockery

Change-Id: I2d7205c10ab9d628f5874114c860a69ede478c7c
Signed-off-by: default avatarBoris Glimcher <Boris.Glimcher@emc.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20251


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarMaciej Miś <maciej.mis@intel.com>
Community-CI: Mellanox Build Bot
parent 75bf61ff
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -23,12 +23,20 @@ const (
	TCP = "tcp"
)

// Client interface mostly for mockery auto-generation
type IClient interface {
	Call(method string, params any) (*Response, error)
}

// Client represents JSON-RPC 2.0 client.
type Client struct {
	codec     *jsonCodec
	requestId atomic.Uint64
}

// build time check that struct implements interface
var _ IClient = (*Client)(nil)

// Call method sends a JSON-RPC 2.0 request to a specified address (provided during client creation).
func (c *Client) Call(method string, params any) (*Response, error) {
	id := c.requestId.Add(1)