server

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: AGPL-3.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 DeadlineListener

type DeadlineListener interface {
	net.Listener

	SetDeadline(deadline time.Time) error
}

DeadlineListener is a listener that allows to set a deadline

type Handler

type Handler interface {
	// Handle is called whenever a new connection is accepted.
	Handle(ctx context.Context, conn net.Conn)

	// Quit is being called when the server received a quit signal.
	Quit() error
}

Handler is a interface that needs to be implemented in order to react on the requests that Server is getting.

type Server

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

Server is a generic server implementation that listens on a certain port and starts a new go routine for each new accepted connection. Whatever the goroutine does is defined by the user-defined handler.

func NewServer

func NewServer(ctx context.Context, lst net.Listener, handler Handler) (*Server, error)

NewServer creates a new server from the listener in `lst` and will call `handler` when receiving requests. It uses `ctx` for handling timeouts.

func (*Server) Close

func (sv *Server) Close() error

Close cleans up internal resources

func (*Server) Quit

func (sv *Server) Quit()

Quit stops the blocking of Serve()

func (*Server) Serve

func (sv *Server) Serve() error

Serve blocks to serve requests to the client. It can be stopped by calling Quit.

Jump to

Keyboard shortcuts

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