gracehttpserverrunner

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 3 Imported by: 0

README

Go Report Card PkgGoDev GitHub License GitHub tag (latest by date)

Grace HTTP Server Runner

A GRPC Server Runner for use with grace.

Usage

package main

import (
	"context"
	"github.com/tomwright/grace"
	"github.com/tomwright/gracehttpserverrunner"
	"net/http"
	"time"
)

func main() {
	g := grace.Init(context.Background())

	// Create and configure your HTTP server.
	server := &http.Server{
		Addr:    ":8080",
		Handler: http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {}),
	}

	// Create and configure the HTTP server runner.
	runner := &gracehttpserverrunner.HTTPServerRunner{
		Server:  server,
		ShutdownTimeout: time.Second * 5,
	}

	// Run the runner.
	g.Run(runner)

	g.Wait()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServerRunner

type HTTPServerRunner struct {
	// Server is the HTTP server to serve.
	Server *http.Server
	// ShutdownTimeout is the maximum time to allow for a graceful shutdown.
	ShutdownTimeout time.Duration
	// contains filtered or unexported fields
}

HTTPServerRunner runs a HTTP server.

func (*HTTPServerRunner) Run

func (r *HTTPServerRunner) Run(ctx context.Context) error

Run starts a http server.

Jump to

Keyboard shortcuts

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