Documentation ¶
Overview ¶
Package brick contains facades and configurations that are useful for a variety of apps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugHandler ¶
func DebugHandler(l *BaseLocator, options ...func(options *debug.RouterConfig)) *chi.Mux
DebugHandler provides developer tools via http.
func MountDevPortal ¶
func MountDevPortal(r chi.Router, l *BaseLocator, options ...func(options *debug.RouterConfig))
MountDevPortal mounts debug handlers to router.
func NewBaseRouter ¶
func NewBaseRouter(l *BaseLocator) chi.Router
NewBaseRouter initializes default http router.
Types ¶
type BaseConfig ¶
type BaseConfig struct { Log zapctxd.Config `split_words:"true"` // Environment is the name of environment where application runs. Environment string `default:"dev"` // ServiceName is the name of the service to use in documentation and tracing. ServiceName string `split_words:"true"` // HTTPListenAddr is the address of HTTP server listener. HTTPListenAddr string `split_words:"true" default:":80"` // ShutdownTimeout limits time for graceful shutdown of an application. ShutdownTimeout time.Duration `split_words:"true" default:"10s"` // Debug controls dev tools. Debug debug.Config `split_words:"true"` }
BaseConfig is a basic application agnostic service configuration that manages common infrastructure.
type BaseLocator ¶
type BaseLocator struct { BaseConfig BaseConfig ctxd.LoggerProvider stats.TrackerProvider *graceful.Switch UseCaseMiddlewares []usecase.Middleware HTTPRequestDecoder *request.DecoderFactory HTTPServerMiddlewares []func(h http.Handler) http.Handler OpenAPI *openapi.Collector }
BaseLocator is a basic application agnostic service locator that manages common infrastructure.
func NewBaseLocator ¶
func NewBaseLocator(cfg BaseConfig) (*BaseLocator, error)
NewBaseLocator initializes basic service locator.
func NoOpLocator ¶
func NoOpLocator() *BaseLocator
NoOpLocator creates a dummy service locator, suitable to docs rendering.
func (*BaseLocator) StartHTTPServer ¶ added in v0.0.2
func (l *BaseLocator) StartHTTPServer(handler http.Handler) (string, error)
StartHTTPServer starts HTTP server with provided handler in a goroutine and returns listening addr or error.
Server will listen at BaseConfig.HTTPListenAddr, if the value is empty free random port will be used.
Server will be gracefully stopped on service locator shutdown.
Directories ¶
Path | Synopsis |
---|---|
Package config provides configuration loader based on env vars.
|
Package config provides configuration loader based on env vars. |
Package database provides database instrumentation.
|
Package database provides database instrumentation. |
Package debug provides debug helpers.
|
Package debug provides debug helpers. |
zpages
Package zpages provides OpenCensus zpages handlers.
|
Package zpages provides OpenCensus zpages handlers. |
Package graceful orchestrates shutdown gracefully.
|
Package graceful orchestrates shutdown gracefully. |
Package jaeger configures OpenCensus Jaeger exporter.
|
Package jaeger configures OpenCensus Jaeger exporter. |
Package log provides logging instrumentation.
|
Package log provides logging instrumentation. |
Package opencensus provides helpers for OpenCensus instrumentation.
|
Package opencensus provides helpers for OpenCensus instrumentation. |
Package runtime provides observability helpers.
|
Package runtime provides observability helpers. |
Package usecase provides usecase instrumentation.
|
Package usecase provides usecase instrumentation. |