Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCancelled = errors.New("cancelled")
)
Functions ¶
This section is empty.
Types ¶
type ConnectionHandler ¶
ConnectionHandler is the signature of the handler function Returning an error in the handler exits the ListerAndServe function with that error
type ConnectionIntf ¶ added in v1.1.27
type ConnectionIntf interface { OnConnect(ctx context.Context, connection ConnectionParams) bool OnDisconnect(ctx context.Context, connection ConnectionParams) HandleConnection(ctx context.Context, connection ConnectionParams) error }
type ConnectionParams ¶ added in v1.1.27
type ConnectionParams struct { Conn net.Conn ServerConfig *ServerConfig }
type Server ¶ added in v1.1.27
Server represents a tcp server
func NewServer ¶ added in v1.1.27
func NewServer(config ServerConfig) *Server
type ServerConfig ¶ added in v1.1.27
type ServerConfig struct { ListenAddress string // "0.0.0.0" ListenPort int // 8080 TlsConfig *tls.Config Logger *logrus.Entry UserData interface{} // any datas, passed to each connection, must be thread safe Connection ConnectionIntf }
ServerConfig holds the server configuration parameters for a Server
type TCPServer ¶
type TCPServer struct {
// contains filtered or unexported fields
}
TCPServer holds the data for our TCP Server
func (*TCPServer) GetNbAccepted ¶
GetNbAccepted returns the number of connections accepted
func (*TCPServer) GetNbGoroutines ¶
GetNbGoroutines returns the number of goroutines currently handling connections
func (*TCPServer) ListerAndServe ¶
func (tcpServer *TCPServer) ListerAndServe(ctx context.Context, address string, handler ConnectionHandler, tlsConfig *tls.Config, userData interface{}) error
ListerAndServe accepts incoming tcp connexions and calls the handler in a new goroutine
Click to show internal directories.
Click to hide internal directories.