rpc

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rpc json-rpc client Created by chenguolin 2019-02-22

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Server   string `json:"server"`   //required
	User     string `json:"usre"`     //optional
	Password string `json:"password"` //optional
}

Client json-rpc client

func NewClient

func NewClient(server string) *Client

NewClient new client

func (*Client) BatchCall

func (c *Client) BatchCall(reqs []*Request) ([]*Response, error)

BatchCall json-rpc call

func (*Client) Call

func (c *Client) Call(req *Request) (*Response, error)

Call json-rpc call

func (*Client) SetAuth

func (c *Client) SetAuth(user, password string)

SetAuth set rpc auth user and password

type Request

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

Request json-rpc request struct

type Response

type Response struct {
	JSONRPC string         `json:"jsonrpc"`
	ID      int            `json:"id"`
	Result  interface{}    `json:"result,omitempty"`
	Error   *responseError `json:"error,omitempty"`
}

Response json-rpc response struct

Jump to

Keyboard shortcuts

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