mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 07:36:37 +08:00
refactor(core): align architecture with cordis spatiotemporal composability
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/core/extpoints"
|
||||
)
|
||||
|
||||
@@ -214,6 +215,24 @@ func (c *Context) Setting() extpoints.SettingExtension {
|
||||
return c.settings
|
||||
}
|
||||
|
||||
// DB returns the contracts.DBService registered in the IoC container, or nil if not registered.
|
||||
func (c *Context) DB() contracts.DBService {
|
||||
svc, err := Inject[contracts.DBService](c)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return svc
|
||||
}
|
||||
|
||||
// Cache returns the contracts.CacheService registered in the IoC container, or nil if not registered.
|
||||
func (c *Context) Cache() contracts.CacheService {
|
||||
svc, err := Inject[contracts.CacheService](c)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return svc
|
||||
}
|
||||
|
||||
// OnDispose registers a cleanup callback function to be executed when this Context is disposed.
|
||||
// It accepts func() error, func(), or Disposer.
|
||||
func (c *Context) OnDispose(fn any) {
|
||||
|
||||
Reference in New Issue
Block a user