rpc

package
v0.0.0-...-9b62ba4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REQUEST      = 0
	RESPONSE     = 1
	NOTIFICATION = 2
)

Variables

This section is empty.

Functions

func CoerceInt

func CoerceInt(v reflect.Value) int64

CoerceInt takes a reflected value and returns it as an int64 panics if not an integer type

func CoerceUint

func CoerceUint(v reflect.Value) uint64

CoerceUint takes a reflected value and returns it as an uint64 panics if not an integer type

func HandleRPCRequest

func HandleRPCRequest(req reflect.Value) (int, string, []reflect.Value, error)

This is a low-level function that is not supposed to be called directly by the user. Change this if the MessagePack protocol is updated.

func ReceiveResponse

func ReceiveResponse(reader io.Reader) (int, reflect.Value, error)

This is a low-level function that is not supposed to be called directly by the user. Change this if the MessagePack protocol is updated.

func SendErrorResponseMessage

func SendErrorResponseMessage(writer io.Writer, msgId int, errMsg string) error

This is a low-level function that is not supposed to be called directly by the user. Change this if the MessagePack protocol is updated.

func SendRequestMessage

func SendRequestMessage(writer io.Writer, msgId int, funcName string, arguments []interface{}) error

This is a low-level function that is not supposed to be called directly by the user. Change this if the MessagePack protocol is updated.

func SendResponseMessage

func SendResponseMessage(writer io.Writer, msgId int, value reflect.Value) error

This is a low-level function that is not supposed to be called directly by the user. Change this if the MessagePack protocol is updated.

Types

type FunctionResolver

type FunctionResolver interface {
	Resolve(name string, arguments []reflect.Value) (reflect.Value, error)
}

type Server

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

func NewServer

func NewServer(resolver FunctionResolver, autoCoercing bool, _log *log.Logger) *Server

Creates a new Server instance. raw bytesc are automatically converted into strings if autoCoercing is enabled.

func (*Server) Listen

func (self *Server) Listen(listener net.Listener) *Server

Listenes on the specified transport. A single server can listen on the multiple ports.

func (*Server) Run

func (self *Server) Run() *Server

Goes into the event loop to get ready to serve.

func (*Server) Stop

func (self *Server) Stop() *Server

Lets the server quit the event loop

type Session

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

func NewSession

func NewSession(transport io.ReadWriteCloser, autoCoercing bool) *Session

Creates a new session with the specified connection. Strings are automatically converted into raw bytes if autoCoercing is enabled.

func (*Session) Send

func (self *Session) Send(funcName string, arguments ...interface{}) (reflect.Value, error)

Sends a RPC request to the server.

func (*Session) SendV

func (self *Session) SendV(funcName string, arguments []interface{}) (reflect.Value, error)

Sends a RPC request to the server.

Jump to

Keyboard shortcuts

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