server

package
v0.82.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// RawListener is the bound TCP listener of the Server.
	RawListener *net.TCPListener
	// CMux wraps RawListener to provide connection protocol multiplexing over
	// a single bound socket. gRPC and HTTP Listeners are provided by default.
	// Additional Listeners may be added directly via CMux.Match() -- though
	// it is then the user's responsibility to Serve the resulting Listeners.
	CMux cmux.CMux
	// GRPCListener is a CMux Listener for gRPC connections.
	GRPCListener net.Listener
	// HTTPListener is a CMux Listener for HTTP connections.
	HTTPListener net.Listener
	// HTTPMux is the http.ServeMux which is served by Serve().
	HTTPMux *http.ServeMux
	// GRPCServer is the gRPC server mux which is served by Serve().
	GRPCServer *grpc.Server
	// GRPCLoopback is a dialed connection to this GRPCServer.
	GRPCLoopback *grpc.ClientConn
}

Server bundles gRPC & HTTP servers, multiplexed over a single bound TCP socket (using CMux). Additional protocols may be added to the Server by interacting directly with its provided CMux.

func MustLoopback

func MustLoopback() *Server

MustLoopback builds and returns a new Server instance bound to a random port on the loopback interface. It panics on error.

func New

func New(iface string, port uint16) (*Server, error)

New builds and returns a Server of the given TCP network interface |iface| and |port|. |port| may be zero, in which case a random free port is assigned.

func (*Server) Endpoint

func (s *Server) Endpoint() pb.Endpoint

Endpoint of the Server.

func (*Server) QueueTasks

func (s *Server) QueueTasks(tg *task.Group)

QueueTasks serving the CMux, HTTP, and gRPC component servers onto the task.Group. If additional Listeners are derived from the Server.CMux, attempts to Accept will block until the CMux itself begins serving.

Jump to

Keyboard shortcuts

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