netutil

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FatalIfUnexpected

func FatalIfUnexpected(err error)

FatalIfUnexpected calls Log.Fatal(err) unless err is nil, or an error that comes from the net package indicating that the listener was closed or from the Stopper indicating quiescence.

func IsClosedConnection

func IsClosedConnection(err error) bool

IsClosedConnection returns true if err is a non-temporary net.Error or is cmux.ErrListenerClosed, grpc.ErrServerStopped, io.EOF, or net.ErrClosed.

func ListenAndServeGRPC

func ListenAndServeGRPC(
	stopper *stop.Stopper, server *grpc.Server, addr net.Addr,
) (net.Listener, error)

ListenAndServeGRPC creates a listener and serves the specified grpc Server on it, closing the listener when signaled by the stopper.

func TestingOverrideSRVLookupFn

func TestingOverrideSRVLookupFn(
	fn func(service, proto, name string) (cname string, addrs []*net.SRV, err error),
) func()

TestingOverrideSRVLookupFn enables a test to temporarily override the SRV lookup function.

Types

type InitialHeartbeatFailedError

type InitialHeartbeatFailedError struct {
	WrappedErr error
}

InitialHeartbeatFailedError indicates that while attempting a GRPC connection to a node, we aren't successful and have never seen a heartbeat over that connection before.

func NewInitialHeartBeatFailedError

func NewInitialHeartBeatFailedError(cause error) *InitialHeartbeatFailedError

NewInitialHeartBeatFailedError creates a new InitialHeartbeatFailedError.

func (*InitialHeartbeatFailedError) Cause

Cause implements causer.

func (*InitialHeartbeatFailedError) Error

Error implements error.

func (*InitialHeartbeatFailedError) Format

func (e *InitialHeartbeatFailedError) Format(s fmt.State, verb rune)

Format implements fmt.Formatter.

func (*InitialHeartbeatFailedError) FormatError

func (e *InitialHeartbeatFailedError) FormatError(p errors.Printer) error

FormatError implements errors.FormatError.

type Server

type Server struct {
	*http.Server
}

Server is a thin wrapper around http.Server. See MakeServer for more detail.

func MakeServer

func MakeServer(stopper *stop.Stopper, tlsConfig *tls.Config, handler http.Handler) Server

MakeServer constructs a Server that tracks active connections, closing them when signaled by stopper.

It can serve two different purposes simultaneously:

- to serve as actual HTTP server, using the .Serve(net.Listener) method. - to serve as plain TCP server, using the .ServeWith(...) method.

The latter is used e.g. to accept SQL client connections.

When the HTTP facility is not used, the Go HTTP server object is still used internally to maintain/register the connections via the ConnState() method, for convenience.

func (*Server) ServeWith

func (s *Server) ServeWith(
	ctx context.Context,
	stopper *stop.Stopper,
	l net.Listener,
	serveConn func(context.Context, net.Conn),
) error

ServeWith accepts connections on ln and serves them using serveConn.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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