container

package
v0.0.0-...-1ac7f0e Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var C = func(i interface{}) *Container {
	if c, ok := i.(*Container); ok {
		return c
	}
	r, ok := i.(*http.Request)
	if !ok {
		panic("could not get the container with dic.C()")
	}
	c, ok := r.Context().Value(dingo.ContainerKey("dingo")).(*Container)
	if !ok {
		panic("could not get the container from the given *http.Request in dic.C()")
	}
	return c
}

C retrieves a Container from an interface. The function panics if the Container can not be retrieved.

The interface can be :

  • a *Container
  • an *http.Request containing a *Container in its context.Context for the dingo.ContainerKey("dingo") key.

The function can be changed to match the needs of your application.

Functions

func Biller

func Biller(i interface{}) billing.Biller

Biller retrieves the "biller" object from the app scope.

---------------------------------------------

name: "biller"
type: billing.Biller
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*slog.Logger) ["logger"]
	- "2": Service(*data.Client) ["data"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetBiller method. If the container can not be retrieved, it panics.

func Captcha

func Captcha(i interface{}) auth.Captcha

Captcha retrieves the "captcha" object from the app scope.

---------------------------------------------

name: "captcha"
type: auth.Captcha
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetCaptcha method. If the container can not be retrieved, it panics.

func Config

func Config(i interface{}) *config.Config

Config retrieves the "config" object from the main scope.

---------------------------------------------

name: "config"
type: *config.Config
scope: "main"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetConfig method. If the container can not be retrieved, it panics.

func Data

func Data(i interface{}) *data.Client

Data retrieves the "data" object from the main scope.

---------------------------------------------

name: "data"
type: *data.Client
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: true

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetData method. If the container can not be retrieved, it panics.

func I18n

func I18n(i interface{}) *in.Bundle

I18n retrieves the "i18n" object from the app scope.

---------------------------------------------

name: "i18n"
type: *in.Bundle
scope: "app"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetI18n method. If the container can not be retrieved, it panics.

func IpStrategy

func IpStrategy(i interface{}) realclientipgo.Strategy

IpStrategy retrieves the "ipStrategy" object from the main scope.

---------------------------------------------

name: "ipStrategy"
type: realclientipgo.Strategy
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetIpStrategy method. If the container can not be retrieved, it panics.

func Limiter

func Limiter(i interface{}) *v1.Limiter

Limiter retrieves the "limiter" object from the app scope.

---------------------------------------------

name: "limiter"
type: *v1.Limiter
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*v.Client) ["redis"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetLimiter method. If the container can not be retrieved, it panics.

func Logger

func Logger(i interface{}) *slog.Logger

Logger retrieves the "logger" object from the main scope.

---------------------------------------------

name: "logger"
type: *slog.Logger
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetLogger method. If the container can not be retrieved, it panics.

func Messenger

func Messenger(i interface{}) messaging.Messenger

Messenger retrieves the "messenger" object from the app scope.

---------------------------------------------

name: "messenger"
type: messaging.Messenger
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*ses.SES) ["ses"]
	- "2": Service(*in.Bundle) ["i18n"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetMessenger method. If the container can not be retrieved, it panics.

func NewBuilder

func NewBuilder(scopes ...string) (*builder, error)

NewBuilder creates a builder that can be used to create a Container. You probably should use NewContainer to create the container directly. But using NewBuilder allows you to redefine some di services. This can be used for testing. But this behavior is not safe, so be sure to know what you are doing.

func Redis

func Redis(i interface{}) *v.Client

Redis retrieves the "redis" object from the app scope.

---------------------------------------------

name: "redis"
type: *v.Client
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetRedis method. If the container can not be retrieved, it panics.

func Resolver

func Resolver(i interface{}) *resolvers.Resolver

Resolver retrieves the "resolver" object from the app scope.

---------------------------------------------

name: "resolver"
type: *resolvers.Resolver
scope: "app"
build: func
params:
	- "0": Service(billing.Biller) ["biller"]
	- "1": Service(auth.Captcha) ["captcha"]
	- "2": Service(*config.Config) ["config"]
	- "3": Service(*data.Client) ["data"]
	- "4": Service(*v1.Limiter) ["limiter"]
	- "5": Service(messaging.Messenger) ["messenger"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetResolver method. If the container can not be retrieved, it panics.

func Scheduler

func Scheduler(i interface{}) *tasks.Scheduler

Scheduler retrieves the "scheduler" object from the app scope.

---------------------------------------------

name: "scheduler"
type: *tasks.Scheduler
scope: "app"
build: func
params: nil
unshared: false
close: true

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetScheduler method. If the container can not be retrieved, it panics.

func Ses

func Ses(i interface{}) *ses.SES

Ses retrieves the "ses" object from the app scope.

---------------------------------------------

name: "ses"
type: *ses.SES
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

It tries to find the container with the C method and the given interface. If the container can be retrieved, it calls the GetSes method. If the container can not be retrieved, it panics.

Types

type Container

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

Container represents a generated dependency injection container. It is a wrapper around a di.Container.

A Container has a scope and may have a parent in a more generic scope and children in a more specific scope. Objects can be retrieved from the Container. If the requested object does not already exist in the Container, it is built thanks to the object definition. The following attempts to get this object will return the same object.

func NewContainer

func NewContainer(scopes ...string) (*Container, error)

NewContainer creates a new Container. If no scope is provided, di.App, di.Request and di.SubRequest are used. The returned Container has the most generic scope (di.App). The SubContainer() method should be called to get a Container in a more specific scope.

func (*Container) Clean

func (c *Container) Clean() error

Clean deletes the sub-container created by UnscopedSafeGet, UnscopedGet or UnscopedFill.

func (*Container) Delete

func (c *Container) Delete() error

Delete works like DeleteWithSubContainers if the Container does not have any child. But if the Container has sub-containers, it will not be deleted right away. The deletion only occurs when all the sub-containers have been deleted manually. So you have to call Delete or DeleteWithSubContainers on all the sub-containers.

func (*Container) DeleteWithSubContainers

func (c *Container) DeleteWithSubContainers() error

DeleteWithSubContainers takes all the objects saved in this Container and calls the Close function of their Definition on them. It will also call DeleteWithSubContainers on each child and remove its reference in the parent Container. After deletion, the Container can no longer be used. The sub-containers are deleted even if they are still used in other goroutines. It can cause errors. You may want to use the Delete method instead.

func (*Container) Fill

func (c *Container) Fill(name string, dst interface{}) error

Fill is similar to SafeGet but it does not return the object. Instead it fills the provided object with the value returned by SafeGet. The provided object must be a pointer to the value returned by SafeGet.

func (*Container) Get

func (c *Container) Get(name string) interface{}

Get is similar to SafeGet but it does not return the error. Instead it panics.

func (*Container) GetBiller

func (c *Container) GetBiller() billing.Biller

GetBiller retrieves the "biller" object from the app scope.

---------------------------------------------

name: "biller"
type: billing.Biller
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*slog.Logger) ["logger"]
	- "2": Service(*data.Client) ["data"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetCaptcha

func (c *Container) GetCaptcha() auth.Captcha

GetCaptcha retrieves the "captcha" object from the app scope.

---------------------------------------------

name: "captcha"
type: auth.Captcha
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetConfig

func (c *Container) GetConfig() *config.Config

GetConfig retrieves the "config" object from the main scope.

---------------------------------------------

name: "config"
type: *config.Config
scope: "main"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetData

func (c *Container) GetData() *data.Client

GetData retrieves the "data" object from the main scope.

---------------------------------------------

name: "data"
type: *data.Client
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: true

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetI18n

func (c *Container) GetI18n() *in.Bundle

GetI18n retrieves the "i18n" object from the app scope.

---------------------------------------------

name: "i18n"
type: *in.Bundle
scope: "app"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetIpStrategy

func (c *Container) GetIpStrategy() realclientipgo.Strategy

GetIpStrategy retrieves the "ipStrategy" object from the main scope.

---------------------------------------------

name: "ipStrategy"
type: realclientipgo.Strategy
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetLimiter

func (c *Container) GetLimiter() *v1.Limiter

GetLimiter retrieves the "limiter" object from the app scope.

---------------------------------------------

name: "limiter"
type: *v1.Limiter
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*v.Client) ["redis"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetLogger

func (c *Container) GetLogger() *slog.Logger

GetLogger retrieves the "logger" object from the main scope.

---------------------------------------------

name: "logger"
type: *slog.Logger
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetMessenger

func (c *Container) GetMessenger() messaging.Messenger

GetMessenger retrieves the "messenger" object from the app scope.

---------------------------------------------

name: "messenger"
type: messaging.Messenger
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*ses.SES) ["ses"]
	- "2": Service(*in.Bundle) ["i18n"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetRedis

func (c *Container) GetRedis() *v.Client

GetRedis retrieves the "redis" object from the app scope.

---------------------------------------------

name: "redis"
type: *v.Client
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetResolver

func (c *Container) GetResolver() *resolvers.Resolver

GetResolver retrieves the "resolver" object from the app scope.

---------------------------------------------

name: "resolver"
type: *resolvers.Resolver
scope: "app"
build: func
params:
	- "0": Service(billing.Biller) ["biller"]
	- "1": Service(auth.Captcha) ["captcha"]
	- "2": Service(*config.Config) ["config"]
	- "3": Service(*data.Client) ["data"]
	- "4": Service(*v1.Limiter) ["limiter"]
	- "5": Service(messaging.Messenger) ["messenger"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetScheduler

func (c *Container) GetScheduler() *tasks.Scheduler

GetScheduler retrieves the "scheduler" object from the app scope.

---------------------------------------------

name: "scheduler"
type: *tasks.Scheduler
scope: "app"
build: func
params: nil
unshared: false
close: true

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) GetSes

func (c *Container) GetSes() *ses.SES

GetSes retrieves the "ses" object from the app scope.

---------------------------------------------

name: "ses"
type: *ses.SES
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it panics.

func (*Container) IsClosed

func (c *Container) IsClosed() bool

IsClosed returns true if the Container has been deleted.

func (*Container) Parent

func (c *Container) Parent() *Container

Parent returns the parent Container.

func (*Container) ParentScopes

func (c *Container) ParentScopes() []string

ParentScopes returns the list of scopes wider than the Container scope.

func (*Container) SafeGet

func (c *Container) SafeGet(name string) (interface{}, error)

SafeGet retrieves an object from the Container. The object has to belong to this scope or a more generic one. If the object does not already exist, it is created and saved in the Container. If the object can not be created, it returns an error.

func (*Container) SafeGetBiller

func (c *Container) SafeGetBiller() (billing.Biller, error)

SafeGetBiller retrieves the "biller" object from the app scope.

---------------------------------------------

name: "biller"
type: billing.Biller
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*slog.Logger) ["logger"]
	- "2": Service(*data.Client) ["data"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetCaptcha

func (c *Container) SafeGetCaptcha() (auth.Captcha, error)

SafeGetCaptcha retrieves the "captcha" object from the app scope.

---------------------------------------------

name: "captcha"
type: auth.Captcha
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetConfig

func (c *Container) SafeGetConfig() (*config.Config, error)

SafeGetConfig retrieves the "config" object from the main scope.

---------------------------------------------

name: "config"
type: *config.Config
scope: "main"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetData

func (c *Container) SafeGetData() (*data.Client, error)

SafeGetData retrieves the "data" object from the main scope.

---------------------------------------------

name: "data"
type: *data.Client
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: true

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetI18n

func (c *Container) SafeGetI18n() (*in.Bundle, error)

SafeGetI18n retrieves the "i18n" object from the app scope.

---------------------------------------------

name: "i18n"
type: *in.Bundle
scope: "app"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetIpStrategy

func (c *Container) SafeGetIpStrategy() (realclientipgo.Strategy, error)

SafeGetIpStrategy retrieves the "ipStrategy" object from the main scope.

---------------------------------------------

name: "ipStrategy"
type: realclientipgo.Strategy
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetLimiter

func (c *Container) SafeGetLimiter() (*v1.Limiter, error)

SafeGetLimiter retrieves the "limiter" object from the app scope.

---------------------------------------------

name: "limiter"
type: *v1.Limiter
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*v.Client) ["redis"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetLogger

func (c *Container) SafeGetLogger() (*slog.Logger, error)

SafeGetLogger retrieves the "logger" object from the main scope.

---------------------------------------------

name: "logger"
type: *slog.Logger
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetMessenger

func (c *Container) SafeGetMessenger() (messaging.Messenger, error)

SafeGetMessenger retrieves the "messenger" object from the app scope.

---------------------------------------------

name: "messenger"
type: messaging.Messenger
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*ses.SES) ["ses"]
	- "2": Service(*in.Bundle) ["i18n"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetRedis

func (c *Container) SafeGetRedis() (*v.Client, error)

SafeGetRedis retrieves the "redis" object from the app scope.

---------------------------------------------

name: "redis"
type: *v.Client
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetResolver

func (c *Container) SafeGetResolver() (*resolvers.Resolver, error)

SafeGetResolver retrieves the "resolver" object from the app scope.

---------------------------------------------

name: "resolver"
type: *resolvers.Resolver
scope: "app"
build: func
params:
	- "0": Service(billing.Biller) ["biller"]
	- "1": Service(auth.Captcha) ["captcha"]
	- "2": Service(*config.Config) ["config"]
	- "3": Service(*data.Client) ["data"]
	- "4": Service(*v1.Limiter) ["limiter"]
	- "5": Service(messaging.Messenger) ["messenger"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetScheduler

func (c *Container) SafeGetScheduler() (*tasks.Scheduler, error)

SafeGetScheduler retrieves the "scheduler" object from the app scope.

---------------------------------------------

name: "scheduler"
type: *tasks.Scheduler
scope: "app"
build: func
params: nil
unshared: false
close: true

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) SafeGetSes

func (c *Container) SafeGetSes() (*ses.SES, error)

SafeGetSes retrieves the "ses" object from the app scope.

---------------------------------------------

name: "ses"
type: *ses.SES
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

If the object can not be retrieved, it returns an error.

func (*Container) Scope

func (c *Container) Scope() string

Scope returns the Container scope.

func (*Container) Scopes

func (c *Container) Scopes() []string

Scopes returns the list of available scopes.

func (*Container) SubContainer

func (c *Container) SubContainer() (*Container, error)

SubContainer creates a new Container in the next sub-scope that will have this Container as parent.

func (*Container) SubScopes

func (c *Container) SubScopes() []string

SubScopes returns the list of scopes that are more specific than the Container scope.

func (*Container) UnscopedFill

func (c *Container) UnscopedFill(name string, dst interface{}) error

UnscopedFill is similar to UnscopedSafeGet but copies the object in dst instead of returning it.

func (*Container) UnscopedGet

func (c *Container) UnscopedGet(name string) interface{}

UnscopedGet is similar to UnscopedSafeGet but it does not return the error. Instead it panics.

func (*Container) UnscopedGetBiller

func (c *Container) UnscopedGetBiller() billing.Biller

UnscopedGetBiller retrieves the "biller" object from the app scope.

---------------------------------------------

name: "biller"
type: billing.Biller
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*slog.Logger) ["logger"]
	- "2": Service(*data.Client) ["data"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetCaptcha

func (c *Container) UnscopedGetCaptcha() auth.Captcha

UnscopedGetCaptcha retrieves the "captcha" object from the app scope.

---------------------------------------------

name: "captcha"
type: auth.Captcha
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetConfig

func (c *Container) UnscopedGetConfig() *config.Config

UnscopedGetConfig retrieves the "config" object from the main scope.

---------------------------------------------

name: "config"
type: *config.Config
scope: "main"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetData

func (c *Container) UnscopedGetData() *data.Client

UnscopedGetData retrieves the "data" object from the main scope.

---------------------------------------------

name: "data"
type: *data.Client
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: true

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetI18n

func (c *Container) UnscopedGetI18n() *in.Bundle

UnscopedGetI18n retrieves the "i18n" object from the app scope.

---------------------------------------------

name: "i18n"
type: *in.Bundle
scope: "app"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetIpStrategy

func (c *Container) UnscopedGetIpStrategy() realclientipgo.Strategy

UnscopedGetIpStrategy retrieves the "ipStrategy" object from the main scope.

---------------------------------------------

name: "ipStrategy"
type: realclientipgo.Strategy
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetLimiter

func (c *Container) UnscopedGetLimiter() *v1.Limiter

UnscopedGetLimiter retrieves the "limiter" object from the app scope.

---------------------------------------------

name: "limiter"
type: *v1.Limiter
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*v.Client) ["redis"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetLogger

func (c *Container) UnscopedGetLogger() *slog.Logger

UnscopedGetLogger retrieves the "logger" object from the main scope.

---------------------------------------------

name: "logger"
type: *slog.Logger
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetMessenger

func (c *Container) UnscopedGetMessenger() messaging.Messenger

UnscopedGetMessenger retrieves the "messenger" object from the app scope.

---------------------------------------------

name: "messenger"
type: messaging.Messenger
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*ses.SES) ["ses"]
	- "2": Service(*in.Bundle) ["i18n"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetRedis

func (c *Container) UnscopedGetRedis() *v.Client

UnscopedGetRedis retrieves the "redis" object from the app scope.

---------------------------------------------

name: "redis"
type: *v.Client
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetResolver

func (c *Container) UnscopedGetResolver() *resolvers.Resolver

UnscopedGetResolver retrieves the "resolver" object from the app scope.

---------------------------------------------

name: "resolver"
type: *resolvers.Resolver
scope: "app"
build: func
params:
	- "0": Service(billing.Biller) ["biller"]
	- "1": Service(auth.Captcha) ["captcha"]
	- "2": Service(*config.Config) ["config"]
	- "3": Service(*data.Client) ["data"]
	- "4": Service(*v1.Limiter) ["limiter"]
	- "5": Service(messaging.Messenger) ["messenger"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetScheduler

func (c *Container) UnscopedGetScheduler() *tasks.Scheduler

UnscopedGetScheduler retrieves the "scheduler" object from the app scope.

---------------------------------------------

name: "scheduler"
type: *tasks.Scheduler
scope: "app"
build: func
params: nil
unshared: false
close: true

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedGetSes

func (c *Container) UnscopedGetSes() *ses.SES

UnscopedGetSes retrieves the "ses" object from the app scope.

---------------------------------------------

name: "ses"
type: *ses.SES
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it panics.

func (*Container) UnscopedSafeGet

func (c *Container) UnscopedSafeGet(name string) (interface{}, error)

UnscopedSafeGet retrieves an object from the Container, like SafeGet. The difference is that the object can be retrieved even if it belongs to a more specific scope. To do so, UnscopedSafeGet creates a sub-container. When the created object is no longer needed, it is important to use the Clean method to delete this sub-container.

func (*Container) UnscopedSafeGetBiller

func (c *Container) UnscopedSafeGetBiller() (billing.Biller, error)

UnscopedSafeGetBiller retrieves the "biller" object from the app scope.

---------------------------------------------

name: "biller"
type: billing.Biller
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*slog.Logger) ["logger"]
	- "2": Service(*data.Client) ["data"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetCaptcha

func (c *Container) UnscopedSafeGetCaptcha() (auth.Captcha, error)

UnscopedSafeGetCaptcha retrieves the "captcha" object from the app scope.

---------------------------------------------

name: "captcha"
type: auth.Captcha
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetConfig

func (c *Container) UnscopedSafeGetConfig() (*config.Config, error)

UnscopedSafeGetConfig retrieves the "config" object from the main scope.

---------------------------------------------

name: "config"
type: *config.Config
scope: "main"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetData

func (c *Container) UnscopedSafeGetData() (*data.Client, error)

UnscopedSafeGetData retrieves the "data" object from the main scope.

---------------------------------------------

name: "data"
type: *data.Client
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: true

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetI18n

func (c *Container) UnscopedSafeGetI18n() (*in.Bundle, error)

UnscopedSafeGetI18n retrieves the "i18n" object from the app scope.

---------------------------------------------

name: "i18n"
type: *in.Bundle
scope: "app"
build: func
params: nil
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetIpStrategy

func (c *Container) UnscopedSafeGetIpStrategy() (realclientipgo.Strategy, error)

UnscopedSafeGetIpStrategy retrieves the "ipStrategy" object from the main scope.

---------------------------------------------

name: "ipStrategy"
type: realclientipgo.Strategy
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetLimiter

func (c *Container) UnscopedSafeGetLimiter() (*v1.Limiter, error)

UnscopedSafeGetLimiter retrieves the "limiter" object from the app scope.

---------------------------------------------

name: "limiter"
type: *v1.Limiter
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*v.Client) ["redis"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetLogger

func (c *Container) UnscopedSafeGetLogger() (*slog.Logger, error)

UnscopedSafeGetLogger retrieves the "logger" object from the main scope.

---------------------------------------------

name: "logger"
type: *slog.Logger
scope: "main"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if main is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetMessenger

func (c *Container) UnscopedSafeGetMessenger() (messaging.Messenger, error)

UnscopedSafeGetMessenger retrieves the "messenger" object from the app scope.

---------------------------------------------

name: "messenger"
type: messaging.Messenger
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
	- "1": Service(*ses.SES) ["ses"]
	- "2": Service(*in.Bundle) ["i18n"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetRedis

func (c *Container) UnscopedSafeGetRedis() (*v.Client, error)

UnscopedSafeGetRedis retrieves the "redis" object from the app scope.

---------------------------------------------

name: "redis"
type: *v.Client
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetResolver

func (c *Container) UnscopedSafeGetResolver() (*resolvers.Resolver, error)

UnscopedSafeGetResolver retrieves the "resolver" object from the app scope.

---------------------------------------------

name: "resolver"
type: *resolvers.Resolver
scope: "app"
build: func
params:
	- "0": Service(billing.Biller) ["biller"]
	- "1": Service(auth.Captcha) ["captcha"]
	- "2": Service(*config.Config) ["config"]
	- "3": Service(*data.Client) ["data"]
	- "4": Service(*v1.Limiter) ["limiter"]
	- "5": Service(messaging.Messenger) ["messenger"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetScheduler

func (c *Container) UnscopedSafeGetScheduler() (*tasks.Scheduler, error)

UnscopedSafeGetScheduler retrieves the "scheduler" object from the app scope.

---------------------------------------------

name: "scheduler"
type: *tasks.Scheduler
scope: "app"
build: func
params: nil
unshared: false
close: true

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

func (*Container) UnscopedSafeGetSes

func (c *Container) UnscopedSafeGetSes() (*ses.SES, error)

UnscopedSafeGetSes retrieves the "ses" object from the app scope.

---------------------------------------------

name: "ses"
type: *ses.SES
scope: "app"
build: func
params:
	- "0": Service(*config.Config) ["config"]
unshared: false
close: false

---------------------------------------------

This method can be called even if app is a sub-scope of the container. If the object can not be retrieved, it returns an error.

Jump to

Keyboard shortcuts

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