Documentation
¶
Overview ¶
Package runtime provides ORM backend abstraction and unified runtime services. This provider binds multiple contracts based on the configured backend:
ORM 运行时包,提供 ORM 后端抽象和统一的运行时服务。 此 Provider 根据配置的后端绑定多个契约:
- ORMBackendKey: The backend name (gorm/sqlx/ent)
- DBRuntimeKey: The actual DB client (GORM/SQLX/Ent)
- MigratorKey: The migrator (GORM, except Ent)
- SQLExecutorKey: The SQL executor (SQLX)
Configuration via config.yaml:
通过 config.yaml 配置:
database: backend: gorm # or sqlx, ent
Eg:
// 注册 Provider app.Register(runtime.NewProvider()) // 获取统一运行时服务 backend := c.MustMake(datacontract.ORMBackendKey).(string) dbRuntime := c.MustMake(datacontract.DBRuntimeKey)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct{}
Provider registers ORM backend abstraction and unified runtime services.
Provider 注册 ORM 后端抽象和统一的运行时服务。
func NewProvider ¶
func NewProvider() *Provider
NewProvider creates a new runtime provider instance.
NewProvider 创建新的运行时 Provider 实例。
func (*Provider) Boot ¶
func (p *Provider) Boot(runtimecontract.Container) error
Boot is a no-op for runtime provider.
Boot 运行时 Provider 无启动逻辑。
func (*Provider) DependsOn ¶
DependsOn returns the keys this provider depends on. Runtime provider depends on Config for backend selection.
DependsOn 返回该 provider 依赖的 key。 Runtime provider 依赖 Config 获取后端选择。
func (*Provider) IsDefer ¶
IsDefer returns false, runtime should be initialized immediately.
IsDefer 返回 false,运行时服务应立即初始化。
func (*Provider) Name ¶
Name returns the provider name "orm.runtime".
Name 返回 Provider 名称 "orm.runtime"。