jsonclient

package
v0.0.0-...-83caf68 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: BSD-3-Clause Imports: 10 Imported by: 50

Documentation

Overview

Package jsonclient 实现JSON rpc客户端请求功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(res interface{}) (interface{}, error)

Callback a callback function

type CallbackExt

type CallbackExt func(res ...interface{}) (interface{}, error)

CallbackExt an extension callback function

type JSONClient

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

JSONClient a object of jsonclient

func New

func New(prefix, url string, tlsVerify bool) (*JSONClient, error)

New produce a jsonclient by perfix and url

func NewJSONClient

func NewJSONClient(url string) (*JSONClient, error)

NewJSONClient produce a json object

func (*JSONClient) Call

func (client *JSONClient) Call(method string, params, resp interface{}) error

Call jsonclinet call method

type RPCCtx

type RPCCtx struct {
	Addr   string
	Method string
	Params interface{}
	Res    interface{}
	// contains filtered or unexported fields
}

RPCCtx rpc ctx interface TODO: SetPostRunCb()

func NewRPCCtx

func NewRPCCtx(laddr, method string, params, res interface{}) *RPCCtx

NewRPCCtx produce a object of rpcctx

func (*RPCCtx) Run

func (c *RPCCtx) Run()

Run rpcctx to runresult

func (*RPCCtx) RunExt

func (c *RPCCtx) RunExt(arg ...interface{})

RunExt extension to run

func (*RPCCtx) RunResult

func (c *RPCCtx) RunResult() (interface{}, error)

RunResult format rpc result

func (*RPCCtx) RunResultExt

func (c *RPCCtx) RunResultExt(arg ...interface{}) (interface{}, error)

RunResultExt format rpc result with ext cb func

func (*RPCCtx) RunWithoutMarshal

func (c *RPCCtx) RunWithoutMarshal()

RunWithoutMarshal return source result of string

func (*RPCCtx) SetResultCb

func (c *RPCCtx) SetResultCb(cb Callback)

SetResultCb rpcctx callback

func (*RPCCtx) SetResultCbExt

func (c *RPCCtx) SetResultCbExt(cb CallbackExt)

SetResultCbExt extension rpcctx callback

Jump to

Keyboard shortcuts

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