rpc

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 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 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, id string) *Client

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.

func (*Client) Stop

func (p *Client) Stop()

Stop gracefully stops a Client

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 Server

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

Server is the interface to gRPC over NATS

func NewServer

func NewServer(nc NatsConn, id string) *Server

NewServer creates a new Proxy

func (*Server) RegisterService

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

RegisterService is used to register gRPC services

func (*Server) Stop

func (p *Server) Stop()

Stop gracefully stops a Proxy

Jump to

Keyboard shortcuts

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