Documentation
¶
Index ¶
- Constants
- Variables
- func GetDBManager(ctx context.Context) (database.Manager, error)
- func GetFromContext(ctx context.Context, key string) (any, error)
- func GetLogger(ctx context.Context) (logger.Logger, error)
- func GetMemoise(ctx context.Context) (memoise.Memoise, error)
- func GetResponderChain(ctx context.Context) (*responder.Chain, error)
- func GetTimedCache(ctx context.Context) (timedcache.TimedCache, error)
- func MustGetDBManager(ctx context.Context) database.Manager
- func MustGetLogger(ctx context.Context) logger.Logger
- func MustGetMemoise(ctx context.Context) memoise.Memoise
- func MustGetResponderChain(ctx context.Context) *responder.Chain
- func MustGetTimedCache(ctx context.Context) timedcache.TimedCache
- func PutToContext(ctx context.Context, key string, value any) (context.Context, error)
- func SetDBManager(ctx context.Context, inst database.Manager) (context.Context, error)
- func SetLogger(ctx context.Context, inst logger.Logger) (context.Context, error)
- func SetMemoise(ctx context.Context, inst memoise.Memoise) (context.Context, error)
- func SetResponderChain(ctx context.Context, inst *responder.Chain) (context.Context, error)
- func SetTimedCache(ctx context.Context, inst timedcache.TimedCache) (context.Context, error)
Constants ¶
const (
ContextKeyDBManager = "_DI_DB_MGR"
)
const (
ContextKeyLogger = "_DI_LOGGER"
)
const (
ContextKeyMemoise = "_DI_MEMO"
)
const (
ContextKeyResponderChain = "_DI_RESPONDER"
)
const (
ContextKeyTimedCache = "_DI_TIMEDCACHE"
)
Variables ¶
var (
ErrKeyNotFound = errors.Base("value map key not found")
)
var (
ErrValueNotDBManager = errors.Base("value is not database.Manager")
)
var (
ErrValueNotLogger = errors.Base("value is not logger.Logger")
)
var (
ErrValueNotMemoise = errors.Base("value is not memoise.Memoise")
)
var (
ErrValueNotResponderChain = errors.Base("value is not responder.Chain")
)
var (
ErrValueNotTimedCache = errors.Base("value is not timedcache.TimedCache")
)
Functions ¶
func GetDBManager ¶
Get the database manager from the given context.
Will return `ErrValueNoDBManager` if the value in the context is not of type `database.Manager`.
func GetFromContext ¶
Get a value from a context.
Will signal `contextext.ErrInvalidContext` if the context is not valid. Will signal `contextext.ErrValueMapNotFound` if there is no value map. Will signal `ErrKeyNotFound` if the value map does not contain the key.
func GetLogger ¶
Get the logger from the given context.
Will return `ErrValueNotLogger` if the value in the context is not of type `logger.Logger`.
func GetMemoise ¶
Get the memoiser from the given context.
Will return `ErrValueNoMemoise` if the value in the context is not of type `memoise.Memoise`.
func GetResponderChain ¶
Get the responder chain from the given context.
Will return `ErrValueNotResponderChain` if the value in the context is not of type `responder.Chain`.
Please be aware that this responder chain should be treated as immutable, as we can't really propagate changes down the context hierarchy.
func GetTimedCache ¶
func GetTimedCache(ctx context.Context) (timedcache.TimedCache, error)
Get the timed cache value from the given context.
WIll return `ErrValueNotTimedCache` if the value in the context is not of type `timedcache.TimedCache`.
func MustGetDBManager ¶
Attempt to get the database manager from the given context. Panics if the operation fails.
func MustGetLogger ¶
Attempt to get the logger from the given context. Panics if the operation fails.
func MustGetMemoise ¶
Attempt to get the memoiser from the given context. Panics if the operation fails.
func MustGetResponderChain ¶
Attempt to get the responder chain from the given context. Panics if the operation fails.
func MustGetTimedCache ¶
func MustGetTimedCache(ctx context.Context) timedcache.TimedCache
Attempt to get the timed cache value from the given context. Panics if the operation fails.
func PutToContext ¶
Place a value in a context.
If there is no value map in the context then one will be created.
Returns a new context with the value map.
func SetDBManager ¶
Set the database manager value to the context map.
func SetMemoise ¶
Set the memoiser value to the context map.
func SetResponderChain ¶
Set the responder chain value in the context map.
func SetTimedCache ¶
func SetTimedCache(ctx context.Context, inst timedcache.TimedCache) (context.Context, error)
Set the timed cache value in the context map.
Types ¶
This section is empty.