Documentation
¶
Index ¶
- func Bootstrap(baseCtx context.Context, initializers ...Initializer) (Injector, Releaser, error)
- func InjectorMiddlewareFactory(injector Injector) func(http.Handler) http.Handler
- func MustInitialize(ctx context.Context, initializer Initializer) (Injector, Releaser)
- func MustInject(ctx context.Context, injector Injector) context.Context
- func SafeRelease(releaser Releaser)
- type Initializer
- type Injector
- type Releaser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bootstrap ¶
Bootstrap calls all initializers and returns a compound Injector and Releaser. In case of error, the Releasers obtained until then are returned to allow for a clean exit.
func InjectorMiddlewareFactory ¶
InjectorMiddlewareFactory returns a simple HTTP middleware which populates Context using the injector. Note: this simple implementation panics if Inject returns error.
func MustInitialize ¶
func MustInitialize(ctx context.Context, initializer Initializer) (Injector, Releaser)
MustInitialize calls the Initializer, panicking on error.
func MustInject ¶
MustInject calls the Injector, panicking on error.
func SafeRelease ¶
func SafeRelease(releaser Releaser)
SafeRelease calls Release on the Releaser if not nil. Note: this is mainly needed because a Releaser can be returned by Bootstrap also in case of error.
Types ¶
type Initializer ¶
Initializer initializes a value, returning a corresponding Injector and Releaser.
type Injector ¶
Injector injects values into a Context.
func CompoundInjectorFactory ¶
CompoundInjectorFactory combines multiple injectors into one.
func SingletonInjectorFactory ¶
func SingletonInjectorFactory(contextKey, value interface{}) Injector
SingletonInjectorFactory always injects the given (contextKey, value) pair.
type Releaser ¶
type Releaser func()
Releaser releases an initialized resource.
func CloseReleaserFactory ¶
CloseReleaserFactory is a releaser that calls Close.
func CompoundReleaserFactory ¶
CompoundReleaserFactory combines multiple releasers into one (invoking them in reverse order).
Directories
¶
Path | Synopsis |
---|---|
injectmocks
Package injectmocks is a generated GoMock package.
|
Package injectmocks is a generated GoMock package. |