rpc

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version   = "2.0"
	DefaultID = 1
	TimeOut   = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host    string `toml:"host"`
	TimeOut uint32 `toml:"timeout"`
}

配置

type IRpc

type IRpc interface {
	// 调用
	Call(ctx context.Context, args *ReqArgs, result interface{}) error
}

标准

func New

func New(opts ...Option) IRpc

func NewRpc

func NewRpc(sRpc Rpc, opts ...Option) IRpc

type Method

type Method string

模块名称

type ModuleName

type ModuleName string

模块名称

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithHost

func WithHost(host string) Option

func WithServiceName

func WithServiceName(serviceName ServiceName) Option

func WithTimeOut

func WithTimeOut(timeOut uint32) Option

type Parameter

type Parameter struct {
	// 配置
	Config
	// contains filtered or unexported fields
}

参数

type ReqArgs

type ReqArgs struct {
	JsonRpc string      `json:"jsonrpc"`
	Method  Method      `json:"method"`
	Params  interface{} `json:"params"`
	ID      uint8       `json:"id"`
}

请求参数

type Resp

type Resp struct {
	JsonRpc string      `json:"jsonrpc"`
	Result  interface{} `json:"result"`
	ID      uint8       `json:"id"`
	Error   interface{} `json:"error"`
}

返回值

type Rpc

type Rpc interface {
	GetConfig(name ModuleName) *Config
	ModuleName() ModuleName
	ServiceName() ServiceName
}

服务标准

type ServiceName

type ServiceName string

服务名称

Jump to

Keyboard shortcuts

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