injectz

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootstrap

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

Bootstrap builds a list of initializers.

func NewBootstrap

func NewBootstrap() *Bootstrap

NewBootstrap initializes a new *Bootstrap.

func (*Bootstrap) Add

func (i *Bootstrap) Add(initializers ...Initializer) *Bootstrap

Add one or more initializers.

func (*Bootstrap) AddGroup

func (i *Bootstrap) AddGroup(initializers []Initializer) *Bootstrap

AddGroup adds one or more initializers.

func (*Bootstrap) MustInitialize

func (i *Bootstrap) MustInitialize() (Injector, Releaser)

MustInitialize the current initializers.

type Initializer

type Initializer func(ctx context.Context) (Injector, Releaser)

Initializer initializes a value, returning a corresponding Injector and Releaser.

type Injector

type Injector func(ctx context.Context) context.Context

Injector injects values into a Context.

func NewInjectors

func NewInjectors(injectors ...Injector) Injector

NewInjectors combines multiple injectors into one.

func NewNoopInjector

func NewNoopInjector() Injector

NewNoopInjector returns an injector that does nothing.

func NewSingletonInjector

func NewSingletonInjector(contextKey, value interface{}) Injector

NewSingletonInjector always injects the given value using the given context key.

type Releaser

type Releaser func()

Releaser releases an initialized resource.

func NewCloseReleaser

func NewCloseReleaser(closer io.Closer) Releaser

NewCloseReleaser returns a releaser that calls closer.Close, ignoring any returned error.

func NewNoopReleaser

func NewNoopReleaser() Releaser

NewNoopReleaser returns a releaser that does nothing.

func NewReleasers

func NewReleasers(releasers ...Releaser) Releaser

NewReleasers combines multiple releasers into one (invoking them in reverse order).

Directories

Path Synopsis
internal
tinjectz
Package tinjectz is a generated GoMock package.
Package tinjectz is a generated GoMock package.

Jump to

Keyboard shortcuts

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