serverdial

package
v0.0.0-...-bbc83da Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionStatus

type ConnectionStatus int
const (
	UnknownStatus ConnectionStatus = iota
	Connected
	Disconnected
	Connecting
)

NOTE: Keep enum in sync with sideeye.ConnectionStatus.

type Listener

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

Listener implements net.Listener and dials connections to a remote address. Listener is a surprising guy -- it doesn't actually "listen" for any sort of incoming connections. Instead, it dials a single connection to a remote address. When that connection is established, it sends a handshake packet (informing the remote server that it should use it as a gRPC client conn) and then it returns the connection from the Accept(). When the connection drops, it dials a new one (so, there's ever at most one connection active).

func NewListener

func NewListener(
	addr string,
	errLogger func(error),
) (*Listener, error)

NewListener creates a Listener that dials the given address. Note that the address should be a valid URL with either http or https scheme and no path or query.

A goroutine is started which dials the target asynchronously. When a connection drops, a new one is dialed.

errLogger can be nil.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept implements net.Listener.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr implements net.Listener.

func (*Listener) Close

func (l *Listener) Close() error

Close implements net.Listener.

func (*Listener) ConnectionStatus

func (l *Listener) ConnectionStatus() ConnectionStatus

ConnectionStatus returns the connection's current state.

Jump to

Keyboard shortcuts

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