ioc

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNamedPrototype

func AddNamedPrototype[T any](f *Factory, name string, fn Provider[T])

AddNamedPrototype add named prototype provider to Factory

func AddNamedSingleton

func AddNamedSingleton[T any](f *Factory, name string, val T)

AddNamedSingleton add named singleton provider to Factory

func AddPrototype

func AddPrototype[T any](f *Factory, fn Provider[T])

AddPrototype add prototype provider to Factory

func AddSingleton

func AddSingleton[T any](f *Factory, val T)

AddSingleton add singleton provider to Factory

func Get

func Get[T any](f *Factory) result.Result[T]

Get retrieve typed service from Factory

func GetNamed

func GetNamed[T any](f *Factory, name string) result.Result[T]

GetNamed retrieve named typed service from Factory

func MustGet

func MustGet[T any](f *Factory) T

MustGet retrieve typed service from Factory, or panic if error

func MustGetNamed

func MustGetNamed[T any](f *Factory, name string) T

MustGetNamed retrieve named typed service from Factory, or panic if error

Types

type Factory

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

Factory is a container for providers

func Configure

func Configure(configure func(*Factory)) *Factory

Configure create a new Factory, and run specific configure function

type Provider

type Provider[T any] func(*Factory) (T, error)

Provider is a function that create a value of type T

Jump to

Keyboard shortcuts

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