freja

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Freja - "Fry - uh"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHealthCalculator

func NewHealthCalculator() *healthCalculate

Types

type App

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

func New added in v0.6.0

func New(options ...OptionApp) *App

func NewApp

func NewApp(healthCalculator healthCalculator, logger Logger, options ...OptionApp) *App

func (*App) AddHealthCheck added in v0.6.0

func (a *App) AddHealthCheck(h healthcheck.HealthChecker)

func (*App) AddMiddleware added in v0.6.0

func (a *App) AddMiddleware(m Middleware)

AddMiddleware adds another middleware, and if it does implement the interface HealthChecker it'll add as a HealCheck as well

func (*App) GetEnvAsIntOrDie added in v0.7.1

func (a *App) GetEnvAsIntOrDie(key string) int

func (*App) GetEnvOrDie added in v0.7.1

func (a *App) GetEnvOrDie(key string) string

func (*App) HealthCheck added in v0.6.0

func (a *App) HealthCheck() ([]byte, error)

HealthCheck returns an error to indicate that the service is not healthy

func (*App) Logger added in v0.6.0

func (a *App) Logger() Logger

func (*App) Server added in v0.6.0

func (a *App) Server(h http.Handler)

func (*App) Start added in v0.6.0

func (a *App) Start(ctx context.Context) error

func (*App) WithServer added in v0.6.0

func (a *App) WithServer(s Server)

type DummyLogger

type DummyLogger struct{}

func (*DummyLogger) Debug

func (*DummyLogger) Debug(args ...interface{})

func (*DummyLogger) Debugf

func (*DummyLogger) Debugf(format string, args ...interface{})

func (*DummyLogger) Error

func (*DummyLogger) Error(args ...interface{})

func (*DummyLogger) Errorf

func (*DummyLogger) Errorf(format string, args ...interface{})

func (*DummyLogger) Fatal

func (*DummyLogger) Fatal(args ...interface{})

func (*DummyLogger) Fatalf

func (*DummyLogger) Fatalf(format string, args ...interface{})

func (*DummyLogger) Info

func (*DummyLogger) Info(args ...interface{})

func (*DummyLogger) Infof

func (*DummyLogger) Infof(format string, args ...interface{})

func (*DummyLogger) Panic

func (*DummyLogger) Panic(args ...interface{})

func (*DummyLogger) Panicf

func (*DummyLogger) Panicf(format string, args ...interface{})

func (*DummyLogger) Print

func (*DummyLogger) Print(args ...interface{})

func (*DummyLogger) Printf

func (*DummyLogger) Printf(format string, args ...interface{})

func (*DummyLogger) Warn

func (*DummyLogger) Warn(args ...interface{})

func (*DummyLogger) Warnf

func (*DummyLogger) Warnf(format string, args ...interface{})

func (*DummyLogger) Warning

func (*DummyLogger) Warning(args ...interface{})

func (*DummyLogger) Warningf

func (*DummyLogger) Warningf(format string, args ...interface{})

type LogWrite

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

func NewLogWrite

func NewLogWrite(log Logger, level string) *LogWrite

func (*LogWrite) Write

func (l *LogWrite) Write(p []byte) (int, error)

type LogWriter

type LogWriter interface {
	io.Writer
}

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	// This will do an exit(1)
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Print(args ...interface{})
	Warn(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	// This will do an exit(1)
	Fatal(args ...interface{})
	Panic(args ...interface{})
}

type Middleware

type Middleware interface {
	Init() error
	Run(ctx context.Context) error
	Stop(ctx context.Context) error
}

Middleware is the manager for any task that is meant to run in the background besides the http server It'll initiate it, run it in a different goroutine and if the service is shutdown it'll stop it gracefully. It can be also used as a mean to ensure the correct clean up of resources before shutdown, such as closing DB connections, etc. --- Init() --- This method is for any initial instructions the task may need, please bear in mind this is mean to run fast and it does run in the main thread, if an error is thrown, it'll prevent the service from starting --- Run(ctx) --- This method runs in a different go routine, and that process can run for as long as its needed. If the service gets a shutdown signal it'll cancel the context first before running the Stop(ctx) method. Its worth mention that if the execution of this method fails it won't re-start the service, it'll log it, if you wish to restart it, consider using the HealthChecker interface. --- Stop(ctx) ---- This method is executed as the last step of the graceful shutdown and is meant to clean up resources before shut down One last thing to note, if any Middleware implements the HealthChecker interface, it'll be added automatically to the health check pool when added to the App

type OptionApp

type OptionApp func(*App)

func OptionCustomServer

func OptionCustomServer(server Server) OptionApp

func OptionGracefulShutdownTimeout

func OptionGracefulShutdownTimeout(gracefulShutdownTimeout time.Duration) OptionApp

type Server

type Server interface {
	ListenAndServe() error
	Shutdown(context.Context) error
}

type Status

type Status struct {
	Name   string `json:"name"`
	Status string `json:"status"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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