debug

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2018 License: MIT Imports: 13 Imported by: 3

Documentation

Overview

Example
package main

import (
	"github.com/goph/fxt"
	"github.com/goph/fxt/debug"
	"github.com/goph/healthz"
	"go.uber.org/fx"
)

func main() {
	status := healthz.NewStatusChecker(healthz.Healthy)

	app := fx.New(
		fx.NopLogger,
		fxt.Bootstrap,
		fx.Provide(
			func() *debug.Config {
				return debug.NewConfig(":8080")
			},
			debug.NewHealthCollector,
			debug.NewServer,
		),
		fx.Invoke(func(collector healthz.Collector) {
			collector.RegisterChecker(healthz.ReadinessCheck, status)
		}),
	)

	if err := app.Err(); err != nil {
		panic(err)
	}

}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHealthCollector

func NewHealthCollector(handler Handler) healthz.Collector

NewHealthCollector returns a new healthz.Collector.

func NewServer

func NewServer(params ServerParams) (Handler, Err)

NewServer creates a new debug server.

func NewStatusChecker added in v0.6.1

func NewStatusChecker(collector healthz.Collector) *healthz.StatusChecker

NewStatusChecker returns a new healthz.StatusChecker with "Healthy" as the default value. It also registers the checker in the health collector.

Types

type Config

type Config struct {
	Debug   bool
	Network string
	Addr    string
}

Config holds a list of options used during the debug server construction.

func NewConfig

func NewConfig(addr string) *Config

NewConfig returns a new config populated with default values.

type Err added in v0.2.0

type Err <-chan error

Err accepts an error which causes the application to stop.

type Handler

type Handler interface {
	http.Handler

	// Handle registers the handler for the given pattern.
	// If a handler already exists for pattern, Handle panics.
	Handle(pattern string, handler http.Handler)

	// HandleFunc registers the handler function for the given pattern.
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

Handler accepts an http.Handler or http.HandlerFunc and registers it for a pattern.

type ServerParams

type ServerParams struct {
	dig.In

	Config    *Config
	Logger    log.Logger `optional:"true"`
	Lifecycle fxt.Lifecycle
}

ServerParams provides a set of dependencies for a debug server constructor.

Jump to

Keyboard shortcuts

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