rpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 17 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrIllegalHeaderWrite indicates that setting header is illegal because of
	// the stream's state.
	ErrIllegalHeaderWrite = errors.New("transport: the stream is done or WriteHeader was already called")
)

Functions

func Codec added in v0.1.5

func Codec() grpc.Codec

Codec returns a proxying grpc.Codec with the default protobuf codec as parent.

See CodecWithParent.

func CodecWithParent added in v0.1.5

func CodecWithParent(fallback grpc.Codec) grpc.Codec

CodecWithParent returns a proxying grpc.Codec with a user provided codec as parent.

This codec is *crucial* to the functioning of the proxy. It allows the proxy server to be oblivious to the schema of the forwarded messages. It basically treats a gRPC message frame as raw bytes. However, if the server handler, or the client caller are not proxy-internal functions it will fall back to trying to decode the message using a fallback codec.

func SetupConnOptions added in v0.1.1

func SetupConnOptions(opts []nats.Option) []nats.Option

SetupConnOptions default conn opts.

Types

type Client

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

func NewClient

func NewClient(nc NatsConn, svcid string, nid string) *Client

func (*Client) Close added in v0.1.3

func (p *Client) Close() error

Close gracefully stops a Client

func (*Client) CloseStream added in v0.1.9

func (p *Client) CloseStream(nid string) bool

func (*Client) Invoke

func (c *Client) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error

Invoke performs a unary RPC and returns after the request is received into reply.

func (*Client) NewStream

func (c *Client) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)

NewStream begins a streaming RPC.

type Frame added in v0.1.5

type Frame struct {
	Payload []byte
}

type NatsConn

type NatsConn interface {
	Publish(subj string, data []byte) error
	PublishRequest(subj, reply string, data []byte) error
	Request(subj string, data []byte, timeout time.Duration) (*nats.Msg, error)
	ChanSubscribe(subj string, ch chan *nats.Msg) (*nats.Subscription, error)
	SubscribeSync(subj string) (*nats.Subscription, error)
	QueueSubscribe(subj, queue string, cb nats.MsgHandler) (*nats.Subscription, error)
	LastError() error
	Flush() error
}

NatsConn nats connection.

type RawCodec added in v0.1.5

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

func (*RawCodec) Marshal added in v0.1.5

func (c *RawCodec) Marshal(v interface{}) ([]byte, error)

func (*RawCodec) String added in v0.1.5

func (c *RawCodec) String() string

func (*RawCodec) Unmarshal added in v0.1.5

func (c *RawCodec) Unmarshal(data []byte, v interface{}) error

type Server

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

Server is the interface to gRPC over NATS

func NewServer

func NewServer(nc NatsConn, nid string) *Server

NewServer creates a new Proxy

func (*Server) CloseStream added in v0.1.9

func (s *Server) CloseStream(nid string) error

func (*Server) GetServiceInfo added in v0.1.4

func (s *Server) GetServiceInfo() map[string]grpc.ServiceInfo

func (*Server) RegisterService

func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss interface{})

RegisterService is used to register gRPC services

func (*Server) Stop

func (s *Server) Stop()

Stop gracefully stops a Proxy

Directories

Path Synopsis
Package reflection implements server reflection service.
Package reflection implements server reflection service.

Jump to

Keyboard shortcuts

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