rpc

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseTypeNone = iota
	ResponseTypeUndefined
	ResponseTypeError
	ResponseTypeStream
	ResponseTypeValue
)

ResponseTypes ...

Variables

View Source
var ErrClose = errors.New("response closed")

ErrClose returned when the the server closes a streaming response

View Source
var ErrInvalidType = errors.New("invaild type")

ErrInvalidType returned when the request or response type doesn't match the expected value

View Source
var ErrMessageTooLarge = errors.New("received message too large")

ErrMessageTooLarge emitted when received message exceeds configured limit

View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented ...

Functions

func ErrorCode added in v0.3.0

func ErrorCode(err error) int32

func WrapError added in v0.3.0

func WrapError[T ~int32](err error, code T) error

Types

type Call

type Call interface {
	ID() uint64
}

Call ...

type CallBase

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

CallBase ...

func NewCallBase

func NewCallBase(ctx context.Context) CallBase

NewCallBase ...

func (*CallBase) Cancel

func (c *CallBase) Cancel()

Cancel ...

func (*CallBase) Context

func (c *CallBase) Context() context.Context

Context ...

type CallIn

type CallIn struct {
	CallBase
	ParentCallAccessor
	// contains filtered or unexported fields
}

CallIn ...

func NewCallIn

func NewCallIn(ctx context.Context, req *pb.Call, parentCallAcessor ParentCallAccessor, send SendFunc) *CallIn

NewCallIn ...

func (*CallIn) Argument

func (c *CallIn) Argument(arg proto.Message) error

Argument ...

func (*CallIn) ID

func (c *CallIn) ID() uint64

ID ...

func (*CallIn) Method

func (c *CallIn) Method() string

Method ...

func (*CallIn) ResponseType

func (c *CallIn) ResponseType() ResponseType

ResponseType ...

type CallOut

type CallOut struct {
	CallBase
	// contains filtered or unexported fields
}

CallOut ...

func NewCallOut

func NewCallOut(ctx context.Context, method string, arg proto.Message) (*CallOut, error)

NewCallOut ...

func NewCallOutWithParent

func NewCallOutWithParent(ctx context.Context, method string, arg proto.Message, parent Call) (*CallOut, error)

NewCallOutWithParent ...

func (*CallOut) AssignResponse

func (c *CallOut) AssignResponse(res *CallIn)

AssignResponse ...

func (*CallOut) ID

func (c *CallOut) ID() uint64

ID ...

func (*CallOut) Method

func (c *CallOut) Method() string

Method ...

func (*CallOut) ReadResponse

func (c *CallOut) ReadResponse(out proto.Message) error

ReadResponse ...

func (*CallOut) ReadResponseStream

func (c *CallOut) ReadResponseStream(res interface{}) error

ReadResponseStream ...

func (*CallOut) SendRequest

func (c *CallOut) SendRequest(fn SendFunc) error

SendRequest ...

type Caller

type Caller interface {
	CallUnary(ctx context.Context, method string, req proto.Message, res proto.Message) error
	CallStreaming(ctx context.Context, method string, req proto.Message, res interface{}) error
}

Caller ...

type Client

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

Client ...

func NewClient

func NewClient(logger *zap.Logger, dialer Dialer) (*Client, error)

NewClient ...

func (*Client) CallStreaming

func (c *Client) CallStreaming(ctx context.Context, method string, req proto.Message, res interface{}) error

CallStreaming ...

func (*Client) CallUnary

func (c *Client) CallUnary(ctx context.Context, method string, req, res proto.Message) error

CallUnary ...

func (*Client) Close

func (c *Client) Close()

Close ...

type Dialer

type Dialer interface {
	Dial(context.Context, Dispatcher) (Transport, error)
}

Dialer ...

type Dispatcher

type Dispatcher interface {
	Dispatch(*CallIn, func())
}

Dispatcher ...

type ErrorCoder added in v0.3.0

type ErrorCoder interface {
	error
	ErrorCode() int32
}

type HTTPServer

type HTTPServer struct {
	*ServiceDispatcher
}

HTTPServer ...

func NewHTTPServer

func NewHTTPServer(logger *zap.Logger) *HTTPServer

NewHTTPServer ...

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ParentCallAccessor

type ParentCallAccessor interface {
	ParentCallIn() *CallIn
	ParentCallOut() *CallOut
}

ParentCallAccessor ...

type RWDialer

type RWDialer struct {
	Logger          *zap.Logger
	ReadWriter      io.ReadWriter
	MaxMessageBytes int
}

RWDialer ...

func (*RWDialer) Dial

func (d *RWDialer) Dial(ctx context.Context, dispatcher Dispatcher) (Transport, error)

Dial ...

type RWFDialer

type RWFDialer struct {
	Logger           *zap.Logger
	ReadWriteFlusher ReadWriteFlusher
}

RWFDialer ...

func (*RWFDialer) Dial

func (d *RWFDialer) Dial(ctx context.Context, dispatcher Dispatcher) (Transport, error)

Dial ...

type RWTransport

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

RWTransport ...

func (*RWTransport) Call

func (t *RWTransport) Call(call *CallOut, fn ResponseFunc) error

Call ...

func (*RWTransport) Listen

func (t *RWTransport) Listen() error

Listen reads incoming calls

type ReadWriteFlusher

type ReadWriteFlusher interface {
	io.ReadWriter
	Flush() error
}

ReadWriteFlusher ...

type ResponseFunc

type ResponseFunc func() error

ResponseFunc ...

type ResponseType

type ResponseType int

ResponseType ...

func (ResponseType) String

func (t ResponseType) String() string

type SendFunc

type SendFunc func(context.Context, *pb.Call) error

SendFunc ...

type Server

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

Server ...

func NewServer

func NewServer(logger *zap.Logger, dialer Dialer) *Server

NewServer ...

func (*Server) Listen

func (s *Server) Listen(ctx context.Context) error

Listen ...

type ServiceDispatcher

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

ServiceDispatcher ...

func NewServiceDispatcher

func NewServiceDispatcher(logger *zap.Logger) *ServiceDispatcher

NewServiceDispatcher ...

func (*ServiceDispatcher) Dispatch

func (h *ServiceDispatcher) Dispatch(call *CallIn, done func())

Dispatch ...

func (*ServiceDispatcher) RegisterMethod

func (h *ServiceDispatcher) RegisterMethod(name string, method interface{})

RegisterMethod ...

type ServiceRegistry

type ServiceRegistry interface {
	RegisterMethod(name string, method interface{})
}

ServiceRegistry ...

type Transport

type Transport interface {
	Call(*CallOut, ResponseFunc) error
	Listen() error
}

Transport ...

Jump to

Keyboard shortcuts

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