Documentation ¶
Index ¶
- func NewHealthCalculator() *healthCalculate
- type App
- func (a *App) AddHealthCheck(h healthcheck.HealthChecker)
- func (a *App) AddMiddleware(m Middleware)
- func (a *App) GetEnvAsIntOrDie(key string) int
- func (a *App) GetEnvOrDie(key string) string
- func (a *App) HealthCheck() ([]byte, error)
- func (a *App) Logger() Logger
- func (a *App) Server(h http.Handler)
- func (a *App) Start(ctx context.Context) error
- func (a *App) WithServer(s Server)
- type DummyLogger
- func (*DummyLogger) Debug(args ...interface{})
- func (*DummyLogger) Debugf(format string, args ...interface{})
- func (*DummyLogger) Error(args ...interface{})
- func (*DummyLogger) Errorf(format string, args ...interface{})
- func (*DummyLogger) Fatal(args ...interface{})
- func (*DummyLogger) Fatalf(format string, args ...interface{})
- func (*DummyLogger) Info(args ...interface{})
- func (*DummyLogger) Infof(format string, args ...interface{})
- func (*DummyLogger) Panic(args ...interface{})
- func (*DummyLogger) Panicf(format string, args ...interface{})
- func (*DummyLogger) Print(args ...interface{})
- func (*DummyLogger) Printf(format string, args ...interface{})
- func (*DummyLogger) Warn(args ...interface{})
- func (*DummyLogger) Warnf(format string, args ...interface{})
- func (*DummyLogger) Warning(args ...interface{})
- func (*DummyLogger) Warningf(format string, args ...interface{})
- type LogWrite
- type LogWriter
- type Logger
- type Middleware
- type OptionApp
- type Server
- type Status
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 (*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 (*App) GetEnvOrDie ¶ added in v0.7.1
func (*App) HealthCheck ¶ added in v0.6.0
HealthCheck returns an error to indicate that the service is not healthy
func (*App) WithServer ¶ added in v0.6.0
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 ¶
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)