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 MountDevPortal ¶
func MountDevPortal(r chi.Router, l *BaseLocator)
MountDevPortal mounts debug handlers to router.
func NewBaseRouter ¶
func NewBaseRouter(l *BaseLocator) chi.Router
NewBaseRouter initializes default http router.
func RunTests ¶ added in v0.0.4
func RunTests(t *testing.T, envPrefix string, cfg WithBaseConfig, init func(tc *TestContext) (*BaseLocator, http.Handler))
RunTests runs feature tests.
func Start ¶ added in v0.0.4
func Start(envPrefix string, cfg WithBaseConfig, init func(docsMode bool) (*BaseLocator, http.Handler))
Start loads config and runs application with provided service locator and 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.
func (*BaseConfig) Base ¶ added in v0.0.4
func (c *BaseConfig) Base() BaseConfig
Base exposes base config.
type BaseLocator ¶
type BaseLocator struct { BaseConfig BaseConfig ctxd.LoggerProvider stats.TrackerProvider *graceful.Switch DebugRouter *debug.Mux UseCaseMiddlewares []usecase.Middleware HTTPRequestDecoder *request.DecoderFactory HTTPServerMiddlewares []func(h http.Handler) http.Handler OpenAPI *openapi.Collector Storage *sqluct.Storage }
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) SetupDebugRouter ¶ added in v0.0.4
func (l *BaseLocator) SetupDebugRouter()
SetupDebugRouter initializes a router with debug tools.
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.
type TestContext ¶ added in v0.0.4
type TestContext struct { Vars *shared.Vars Local *httpdog.Local External *httpdog.External Database *dbdog.Manager ScenarioInitializer func(s *godog.ScenarioContext) }
TestContext is a test context for feature tests.
type WithBaseConfig ¶ added in v0.0.4
type WithBaseConfig interface {
Base() BaseConfig
}
WithBaseConfig is an embedded config accessor.
Source Files ¶
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. |