cockroach: Index | Files

package netutil

import ""


Package Files

addr.go net.go

func FatalIfUnexpected Uses

func FatalIfUnexpected(err error)

FatalIfUnexpected calls Log.Fatal(err) unless err is nil, cmux.ErrListenerClosed, or the net package's errClosed.

func IsClosedConnection Uses

func IsClosedConnection(err error) bool

IsClosedConnection returns true if err is cmux.ErrListenerClosed, grpc.ErrServerStopped, io.EOF, or the net package's errClosed.

func ListenAndServeGRPC Uses

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 SplitHostPort Uses

func SplitHostPort(v string, defaultPort string) (addr string, port string, err error)

SplitHostPort is like net.SplitHostPort however it supports addresses without a port number. In that case, the provided port number is used.

type InitialHeartbeatFailedError Uses

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 Uses

func NewInitialHeartBeatFailedError(cause error) *InitialHeartbeatFailedError

NewInitialHeartBeatFailedError creates a new InitialHeartbeatFailedError.

func (*InitialHeartbeatFailedError) Cause Uses

func (e *InitialHeartbeatFailedError) Cause() error

Cause implements causer.

func (*InitialHeartbeatFailedError) Error Uses

func (e *InitialHeartbeatFailedError) Error() string

Error implements error.

func (*InitialHeartbeatFailedError) Format Uses

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

Format implements fmt.Formatter.

func (*InitialHeartbeatFailedError) FormatError Uses

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

FormatError implements errors.FormatError.

type Server Uses

type Server struct {

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

func MakeServer Uses

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 Uses

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

ServeWith accepts connections on ln and serves them using serveConn.

Package netutil imports 16 packages (graph) and is imported by 151 packages. Updated 2021-01-26. Refresh now. Tools for package owners.