rpc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Base      connType = "Base"
	HTTP      connType = "Http"
	JSON_HTTP connType = "Json-Http"
)

Variables

This section is empty.

Functions

func NewServer

func NewServer(ctx context.Context, rpcOpts ...RpcServerOptions) (err error)

Types

type BaseRpc

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

func (*BaseRpc) Call

func (r *BaseRpc) Call(serviceMethod string, args any, reply any) (err error)

func (*BaseRpc) Go

func (r *BaseRpc) Go(serviceMethod string, args any, reply any, done interface{}) interface{}

type Message added in v0.0.5

type Message struct {
	Id     int    `json:"id"`
	Method string `json:"method"`
	Params []any  `json:"params"`
}

type Reply added in v0.0.5

type Reply struct {
	Id     int    `json:"id"`
	Result any    `json:"result"`
	Error  string `json:"error"`
}

type RpcClientOptions

type RpcClientOptions func(r *BaseRpc)

func WithClientAddress

func WithClientAddress(address string) RpcClientOptions

func WithClientNetwork

func WithClientNetwork(network string) RpcClientOptions

func WithClientType added in v0.0.5

func WithClientType(t connType) RpcClientOptions

type RpcServerOptions

type RpcServerOptions func(r *BaseRpc)

func WithServerAddress

func WithServerAddress(address string) RpcServerOptions

func WithServerNetwork

func WithServerNetwork(network string) RpcServerOptions

func WithServerType added in v0.0.5

func WithServerType(t connType) RpcServerOptions

type Session

type Session interface {
	Call(serviceMethod string, args any, reply any) error
	Go(serviceMethod string, args any, reply any, done interface{}) interface{}
}

func NewClient

func NewClient(ctx context.Context, rpcOpts ...RpcClientOptions) (session Session, err error)

Jump to

Keyboard shortcuts

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