Documentation ¶
Index ¶
- Constants
- Variables
- func InstanceOf(value interface{}, filters ...string) error
- func MapOf(value interface{}, filters ...string) error
- func Register(constructor interface{}, opts ...RegisterOption) error
- func Run()
- func SetLogger(logger Logger)
- func SliceOf(value interface{}, filters ...string) error
- func Trigger(callback func()) error
- func TypeOf(value interface{}) string
- func TypeOfPtr(value interface{}) string
- func Unregister(packetName string, tags ...string)
- type Container
- func (c *Container) Context() ContainerContext
- func (c *Container) InstanceOf(value interface{}, filters []string) error
- func (c *Container) Log() Logger
- func (c *Container) MapOf(value interface{}, filters []string) error
- func (c *Container) Register(constructor interface{}, opts []RegisterOption) error
- func (c *Container) Run()
- func (c *Container) SetLogger(logger Logger)
- func (c *Container) SliceOf(value interface{}, filters []string) error
- func (c *Container) Trigger(callback func()) error
- func (c *Container) Unregister(packetName string, tags []string)
- type ContainerContext
- type ContainerState
- type Context
- type Logger
- type PreLoader
- type RegisterOption
- type Runner
- type ServiceState
- type ShutDowner
Constants ¶
View Source
const ( Singleton provideScope = iota Prototype )
View Source
const ( Normal provideType = 0 Preloadable provideType = 1 Shutdownable provideType = 2 Runnable provideType = 4 Service = Preloadable | Runnable | Shutdownable )
View Source
const (
DefaultTag = "default"
)
Variables ¶
View Source
var ( PacketNotFound = errors.New("packet not found") VariableIsNotPtr = errors.New("retrieve variable must be pointer") VariableIsNotSlice = errors.New("retrieve variable must be slice") VariableIsNotMap = errors.New("retrieve variable must be map") ValueIsNotPtrOrInterface = errors.New("value must be pointer or interface") InvalidConstructor = errors.New("invalid godi constructor") InvalidDependencies = errors.New("invalid dependencies") ContainerIsNotRunning = errors.New("Container not running") ContainerInRunning = errors.New("Container running") ProviderNotFound = errors.New("provider not found") )
Functions ¶
func InstanceOf ¶
func Register ¶
func Register(constructor interface{}, opts ...RegisterOption) error
func Unregister ¶
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func GetApplicationContainer ¶
func GetApplicationContainer() *Container
func (*Container) Context ¶
func (c *Container) Context() ContainerContext
func (*Container) InstanceOf ¶
func (*Container) Register ¶
func (c *Container) Register(constructor interface{}, opts []RegisterOption) error
func (*Container) Unregister ¶
unregister all if tags = nil
type ContainerContext ¶
type ContainerContext interface { context.Context Log() Logger State() ContainerState Retrievable() bool ShutDown() }
func GetContext ¶
func GetContext() ContainerContext
type ContainerState ¶
type ContainerState uint
const ( Initializing ContainerState = iota ContainerRunning ContainerShutdown )
func (ContainerState) Name ¶
func (c ContainerState) Name() string
type Context ¶
type Context interface { context.Context Container() ContainerContext State() ServiceState Log() Logger }
type Logger ¶
type Logger interface { Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Panic(args ...interface{}) Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) Panicf(template string, args ...interface{}) }
type RegisterOption ¶
type RegisterOption func(option *registerOption)
func Filter ¶
func Filter(dependency string, tags ...string) RegisterOption
func Scope ¶
func Scope(scope provideScope) RegisterOption
func Tag ¶
func Tag(tag string) RegisterOption
func Type ¶
func Type(types ...provideType) RegisterOption
type ServiceState ¶
type ServiceState uint
const ( ServiceInitialize ServiceState = 0 ServicePreloading ServiceState = 1 ServiceRunning ServiceState = 2 ServiceShutDown ServiceState = 4 )
type ShutDowner ¶
type ShutDowner interface {
ShutDown(ctx Context)
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.