server

package
v0.0.0-...-53df4c2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package server ...

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoListeners is returned when Server.Serve() is called before
	// Server.Listen()
	ErrNoListeners = errors.New("server: no listeners defined")

	// ErrMissingListener is returned by Server.Serve() when the number of
	// listeners created by Server.Listen() doesn't match the number of
	// listeners set in Config.Listeners.
	ErrMissingListener = errors.New("server: missing listener")

	// ErrAlreadyServing is returned by Server.Serve() when there are already
	// servers listening.  Before calling Server.Serve() again, Server.Close()
	// should be called to ensure all servers and listeners are closed.
	ErrAlreadyServing = errors.New("server: already serving")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Listeners is a slice of listeners to bind to.
	Listeners []listener.Listener
}

Config represents the configuration for a Server.

type Opt

type Opt func(*Server) error

Opt is a configuration option to initialize a server.

func WithConfig

func WithConfig(c *Config) Opt

WithConfig overwrites the config for the server.

func WithListener

func WithListener(l listener.Listener) Opt

WithListener adds another listener to the server.

type Server

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

Server .

func FromLexer

func FromLexer(b lexer.Block) (*Server, error)

FromLexer .

func New

func New(ops ...Opt) (*Server, error)

New .

func (*Server) Close

func (s *Server) Close(ctx context.Context) error

Close .

func (*Server) Listen

func (s *Server) Listen(ctx context.Context) []error

Listen .

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve .

Directories

Path Synopsis
Package listener ...
Package listener ...

Jump to

Keyboard shortcuts

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