tcp

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionHandler

type ConnectionHandler interface {
	HandleConnection(conn net.Conn)
}

ConnectionHandler handles a single TCP connection.

type Manager

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

Manager starts and stops TCP servers.

func NewManager

func NewManager(servers []ServerConfig, m *metrics.Collector) *Manager

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start begins listening on all configured TCP servers.

func (*Manager) Wait

func (m *Manager) Wait()

Wait blocks until all accept loops exit and stops starters.

type ServerConfig

type ServerConfig struct {
	Name    string
	Address string
	Handler ConnectionHandler // For generic TCP accept loop.
	Starter Starter           // For self-managed servers (SMTP, etc.).
}

ServerConfig describes a TCP server a module needs. Provide either Handler (for generic TCP) or Starter (for self-managed servers).

type Starter

type Starter interface {
	Start(ctx context.Context) error
	Stop() error
}

Starter is an alternative to ConnectionHandler for servers that manage their own listener (e.g., go-smtp).

Jump to

Keyboard shortcuts

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