streamrpc

package
v14.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptConnection

func AcceptConnection(ctx context.Context) (net.Conn, error)

AcceptConnection completes the StreamRPC handshake on the server side. It notifies the client that the server has accepted the stream, and returns the connection.

func Call

func Call(ctx context.Context, dial DialFunc, method string, msg proto.Message, callback func(net.Conn) error, opts ...CallOption) (err error)

Call makes a StreamRPC call. The dial function determines the remote address. The method argument is the full name of the StreamRPC method we are calling (e.g. "/foo.BarService/BazStream"). Msg is the request message. If the server accepts the call, callback is called with a connection.

Types

type CallOption

type CallOption func(*callOptions)

CallOption is an abstraction that lets us pass 0 or more options to a call.

func WithClientInterceptor

func WithClientInterceptor(interceptor grpc.UnaryClientInterceptor) CallOption

WithClientInterceptor adds a gRPC unary client interceptor to an outgoing call.

func WithCredentials

func WithCredentials(creds credentials.PerRPCCredentials) CallOption

WithCredentials adds gRPC per-request credentials to an outgoing call.

type DialFunc

type DialFunc func(time.Duration) (net.Conn, error)

DialFunc is an abstraction that allows Call to transparently handle unencrypted connections and TLS connections.

type RequestRejectedError

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

RequestRejectedError is returned by Call if the server explicitly rejected the request (as opposed to e.g. an IO timeout).

func (*RequestRejectedError) Error

func (r *RequestRejectedError) Error() string

type Server

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

Server handles network connections and routes them to StreamRPC handlers.

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer returns a new StreamRPC server. You can pass the result to grpc-go RegisterFooServer functions.

func (*Server) Handle

func (s *Server) Handle(c net.Conn) error

Handle handles an incoming network connection with the StreamRPC protocol. It is intended to be called from a net.Listener.Accept loop (or something equivalent).

func (*Server) RegisterService

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

RegisterService implements grpc.ServiceRegistrar. It makes it possible to pass a *Server to grpc-go foopb.RegisterFooServer functions as the first argument.

type ServerOption

type ServerOption func(*Server)

ServerOption is an abstraction that lets you pass 0 or more server options to NewServer.

func WithServerInterceptor

func WithServerInterceptor(interceptor grpc.UnaryServerInterceptor) ServerOption

WithServerInterceptor adds a unary gRPC server interceptor.

Jump to

Keyboard shortcuts

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