rpc

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package rpc implements MessagePack RPC.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed session closed error.
	ErrClosed = errors.New("msgpack/rpc: session closed")

	// ErrInternal msgpack-rpc internal error.
	ErrInternal = errors.New("msgpack/rpc: internal error")

	// ErrHandlerNotFunction handler type is not a function error.
	ErrHandlerNotFunction = errors.New("msgpack/rpc: handler not a function")

	// ErrInvalidHandlerReturn invalid handler function return type error.
	ErrInvalidHandlerReturn = errors.New("msgpack/rpc: handler return must be (), (error) or (valueType, error)")

	// ErrInvalidArgument invalid argument error.
	ErrInvalidArgument = errors.New("msgpack/rpc: invalid argument")
)

Functions

This section is empty.

Types

type Call

type Call struct {
	Args   interface{}
	Reply  interface{}
	Err    error
	Done   chan *Call
	Method string
}

Call represents a MessagePack RPC call.

type Endpoint

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

Endpoint represents a MessagePack RPC peer.

func NewEndpoint

func NewEndpoint(r io.Reader, w io.Writer, c io.Closer, options ...Option) (*Endpoint, error)

NewEndpoint returns a new endpoint with the specified options.

func (*Endpoint) Call

func (e *Endpoint) Call(method string, reply interface{}, args ...interface{}) error

Call invokes the target method and waits for a response.

func (*Endpoint) Close

func (e *Endpoint) Close() error

Close releases the resources used by endpoint.

func (*Endpoint) Go

func (e *Endpoint) Go(method string, done chan *Call, reply interface{}, args ...interface{}) *Call

Go append method call to queue and returns the new Call.

func (*Endpoint) Notify

func (e *Endpoint) Notify(method string, args ...interface{}) error

Notify invokes the target method with non-blocking.

func (*Endpoint) Register

func (e *Endpoint) Register(method string, fn interface{}, args ...interface{}) error

Register registers handler fn for the specified method name.

When servicing a call, the arguments to fn are the values in args followed by the values passed from the peer.

func (*Endpoint) Serve

func (e *Endpoint) Serve() error

Serve serves incoming requests. Serve blocks until the peer disconnects or there is an error.

type Error

type Error struct {
	Value interface{}
}

Error represents a MessagePack RPC error.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

type Option

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

Option is a configures a Endpoint.

func WithExtensions

func WithExtensions(extensions msgpack.ExtensionMap) Option

WithExtensions configures Endpoint to define application-specific types.

func WithLogf

func WithLogf(f func(fmt string, args ...interface{})) Option

WithLogf sets the log function to Endpoint.

Jump to

Keyboard shortcuts

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