run

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 3 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCServe

func GRPCServe(server GRPCServer, lis net.Listener) (execute func() error, interrupt func(error))

GRPCServe returns an actor, i.e. an execute and interrupt func, that terminates when the underlying gRPC server fails.

func GracefulRestart

func GracefulRestart(ctx context.Context, upg Upgrader) (execute func() error, interrupt func(error))

GracefulRestart returns an actor, i.e. an execute and interrupt func, that terminates when graceful restart is initiated and the child process signals to be ready, or the parent context is canceled.

func HTTPServe added in v0.5.0

func HTTPServe(
	server HTTPServer,
	lis net.Listener,
	shutdownTimeout time.Duration,
) (execute func() error, interrupt func(error))

HTTPServe returns an actor, i.e. an execute and interrupt func, that terminates when the underlying HTTP server fails.

It accepts a timeout parameter for the graceful shutdown. 0 means no timeout.

Types

type GRPCServer

type GRPCServer interface {
	Serve(lis net.Listener) error
	GracefulStop()
}

GRPCServer is a gRPC server.

type HTTPServer added in v0.5.0

type HTTPServer interface {
	Serve(lis net.Listener) error
	Shutdown(ctx context.Context) error
}

HTTPServer is an HTTP server.

type ServeLogger added in v0.5.0

type ServeLogger interface {
	// Info logs an Info event.
	Info(msg string, fields ...map[string]interface{})
}

ServeLogger logs server start/shutdown events.

type Upgrader

type Upgrader interface {
	Ready() error
	Exit() <-chan struct{}
	Stop()
}

Upgrader handles zero downtime upgrades and passing files between processes.

Upgrader is based on https://github.com/cloudflare/tableflip.

type Wrapper added in v0.5.0

type Wrapper func(execute func() error, interrupt func(error)) (func() error, func(error))

Wrapper is an actor that wraps another actor. It is useful for creating middleware.

func LogServe added in v0.5.0

func LogServe(logger ServeLogger) Wrapper

LogServe returns an actor, i.e. an execute and interrupt func, that logs a message when a server is being started/shut down.

Jump to

Keyboard shortcuts

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