loop

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package loop implements a generic server loop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loop

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

A Loop is a generic server loop.

func New

func New(options ...Option) *Loop

New constructs a runtime loop configured by the given options.

func (*Loop) Start

func (s *Loop) Start(ctx context.Context)

Start executes the server loop.

This method is non-blocking and will spawn additional goroutines.

type Option

type Option interface {
	// contains filtered or unexported methods
}

An Option is used to provide additional configuration to a server or to request additional information from the server internals.

func WithConnectionCounter

func WithConnectionCounter() (Option, func() uint64)

WithConnectionCounter returns a metric function that indicates how many network connections have been received.

func WithHandler added in v0.1.3

func WithHandler(listener net.Listener, fn func(context.Context, net.Conn) error) Option

WithHandler provides a listeners

func WithLatch added in v0.1.2

func WithLatch(l *latch.Latch) Option

WithLatch will inject a Latch that is held whenever a connection is active. This allows callers to implement a graceful draining strategy.

func WithPreflight added in v0.1.2

func WithPreflight(fn func(context.Context) (context.Context, error)) Option

WithPreflight registers a function that can block connection acceptance and well as replace or update the Context to be used later in the request.

Jump to

Keyboard shortcuts

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