container

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package container provides runtime dependency injection container for gorp framework. This file provides strongly typed access helpers for app-service style bindings. Reduces repetitive container type assertions in business and bootstrap code.

容器包提供 gorp 框架的运行时依赖注入容器实现。 本文件为 app-service 风格绑定提供强类型访问 helper。 减少业务代码和 bootstrap 代码中重复的容器类型断言。

Package container provides runtime dependency injection container for gorp framework. This file exposes security-related convenience helpers for JWT capability access. Keeps common auth service lookup compact for handlers, middleware, bootstrap hooks.

容器包提供 gorp 框架的运行时依赖注入容器实现。 本文件暴露聚焦安全能力的便捷 helper。 让 handler、middleware 和 bootstrap hook 获取 JWT 能力时保持简洁。

Package container provides runtime dependency injection container for gorp framework. This file exposes typed config access helpers on top of runtime container. Keeps config capability lookup consistent across bootstrap and application code.

容器包提供 gorp 框架的运行时依赖注入容器实现。 本文件在运行时容器之上暴露强类型配置访问 helper。 让 bootstrap 与 application 代码获取配置能力时保持一致。

Package container provides runtime dependency injection container for gorp framework. Manages direct bindings, deferred providers, singleton lifecycle, and provider boot order. Serves as central assembly point for providers used by bootstrap and application startup.

容器包提供 gorp 框架的运行时依赖注入容器实现。 管理直接绑定、延迟 provider、单例生命周期和 provider 启动顺序。 作为 bootstrap 与 application 启动阶段装配 provider 的核心承载点。

Package container provides runtime dependency injection container for gorp framework. This file offers provider introspection and diagnostics helper methods. Supports CLI or tooling queries without polluting core container contract.

容器包提供 gorp 框架的运行时依赖注入容器实现。 本文件提供 provider 维度的辅助查询和诊断能力。 支持 CLI 或工具侧查询,而不污染核心运行时容器契约。

Package container provides runtime dependency injection container for gorp framework. This file exposes strongly typed helper accessors for common capabilities. All helpers delegate to the generic MakeWith[T] / MustMakeWith[T] functions, eliminating bare type assertions and providing type-mismatch error messages.

容器包提供 gorp 框架的运行时依赖注入容器实现。 本文件在通用运行时容器之上暴露强类型辅助访问入口。 所有 helper 委托给泛型 MakeWith[T] / MustMakeWith[T], 消除裸类型断言,并在类型不匹配时提供可读错误信息。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

GetCache resolves the cache capability from the container.

GetCache 从容器中解析缓存能力。

func GetCacheOrPanic

func GetCacheOrPanic(c runtimecontract.Container) datacontract.Cache

GetCacheOrPanic resolves the cache capability and panics on failure.

GetCacheOrPanic 解析缓存能力,失败时 panic。

func GetConfigOrPanic

func GetConfigOrPanic(c runtimecontract.Container) datacontract.Config

GetConfigOrPanic resolves the config capability and panics on failure.

GetConfigOrPanic 解析配置能力,失败时 panic。

func GetCron

GetCron resolves the cron capability from the container.

GetCron 从容器中解析定时任务能力。

func GetCronOrPanic

GetCronOrPanic resolves the cron capability and panics on failure.

GetCronOrPanic 解析定时任务能力,失败时 panic。

func GetDB

GetDB resolves both Gorm and SQLX database handles from the container.

GetDB 从容器中解析 Gorm 和 SQLX 数据库句柄。

func GetDBOrPanic

func GetDBOrPanic(c runtimecontract.Container) (*gormdb.DB, *sqlx.DB)

GetDBOrPanic resolves both Gorm and SQLX database handles from the container. Panics if either is not available.

GetDBOrPanic 从容器中解析 Gorm 和 SQLX 数据库句柄,失败时 panic。 这两个句柄指向同一个数据库连接,业务可根据场景选择使用。

func GetDBRuntime

func GetDBRuntime(c runtimecontract.Container) (any, error)

GetDBRuntime resolves the database runtime object from the container.

GetDBRuntime 从容器中解析数据库运行时对象。

func GetDistributedLock

GetDistributedLock resolves the distributed lock capability from the container.

GetDistributedLock 从容器中解析分布式锁能力。

func GetDistributedLockOrPanic

func GetDistributedLockOrPanic(c runtimecontract.Container) datacontract.DistributedLock

GetDistributedLockOrPanic resolves the distributed lock capability and panics on failure.

GetDistributedLockOrPanic 解析分布式锁能力,失败时 panic。

func GetGRPCConnFactory

GetGRPCConnFactory resolves the gRPC connection factory from the container.

GetGRPCConnFactory 从容器中解析 gRPC 连接工厂。

func GetGRPCConnFactoryOrPanic

func GetGRPCConnFactoryOrPanic(c runtimecontract.Container) transportcontract.GRPCConnFactory

GetGRPCConnFactoryOrPanic resolves the gRPC connection factory and panics on failure.

GetGRPCConnFactoryOrPanic 解析 gRPC 连接工厂,失败时 panic。

func GetGRPCServerRegistrar

GetGRPCServerRegistrar resolves the gRPC server registrar from the container.

GetGRPCServerRegistrar 从容器中解析 gRPC 服务注册器。

func GetGRPCServerRegistrarOrPanic

func GetGRPCServerRegistrarOrPanic(c runtimecontract.Container) transportcontract.GRPCServerRegistrar

GetGRPCServerRegistrarOrPanic resolves the gRPC server registrar and panics on failure.

GetGRPCServerRegistrarOrPanic 解析 gRPC 服务注册器,失败时 panic。

func GetGorm

func GetGorm(c runtimecontract.Container) (*gormdb.DB, error)

GetGorm resolves the Gorm database handle from the container.

GetGorm 从容器中解析 Gorm 数据库句柄。

func GetGormOrPanic

func GetGormOrPanic(c runtimecontract.Container) *gormdb.DB

GetGormOrPanic resolves the Gorm database handle and panics on failure.

GetGormOrPanic 解析 Gorm 数据库句柄,失败时 panic。

func GetHTTP

GetHTTP resolves the HTTP service from the container.

GetHTTP 从容器中解析 HTTP 服务。

func GetHTTPOrPanic

GetHTTPOrPanic resolves the HTTP service and panics on failure.

GetHTTPOrPanic 解析 HTTP 服务,失败时 panic。

func GetHost

GetHost resolves the host capability from the container.

GetHost 从容器中解析 host 能力。

func GetJWT

GetJWT resolves the JWT service from the container.

GetJWT 从容器中解析 JWT 服务。

func GetJWTOrPanic

GetJWTOrPanic resolves the JWT service and panics on failure.

GetJWTOrPanic 解析 JWT 服务,失败时 panic。

func GetLogger

GetLogger resolves the logger capability from the container.

GetLogger 从容器中解析日志能力。

func GetLoggerOrPanic

GetLoggerOrPanic resolves the logger and panics on failure.

GetLoggerOrPanic 解析日志能力,失败时 panic。

func GetMessagePublisher

GetMessagePublisher resolves the message publisher from the container.

GetMessagePublisher 从容器中解析消息发布能力。

func GetMessagePublisherOrPanic

func GetMessagePublisherOrPanic(c runtimecontract.Container) integrationcontract.MessagePublisher

GetMessagePublisherOrPanic resolves the message publisher and panics on failure.

GetMessagePublisherOrPanic 解析消息发布能力,失败时 panic。

func GetMessageSubscriber

GetMessageSubscriber resolves the message subscriber from the container.

GetMessageSubscriber 从容器中解析消息订阅能力。

func GetMessageSubscriberOrPanic

func GetMessageSubscriberOrPanic(c runtimecontract.Container) integrationcontract.MessageSubscriber

GetMessageSubscriberOrPanic resolves the message subscriber and panics on failure.

GetMessageSubscriberOrPanic 解析消息订阅能力,失败时 panic。

func GetMiddlewareRegistry

GetMiddlewareRegistry resolves the middleware registry from the container.

GetMiddlewareRegistry 从容器中解析中间件注册表。

func GetMiddlewareRegistryOrPanic

func GetMiddlewareRegistryOrPanic(c runtimecontract.Container) transportcontract.MiddlewareRegistry

GetMiddlewareRegistryOrPanic resolves the middleware registry and panics on failure.

GetMiddlewareRegistryOrPanic 解析中间件注册表,失败时 panic。

func GetRedis

GetRedis resolves the Redis capability from the container.

GetRedis 从容器中解析 Redis 能力。

func GetRetry

GetRetry resolves the retry capability from the container.

GetRetry 从容器中解析重试策略能力。

func GetRetryOrPanic

GetRetryOrPanic resolves the retry capability and panics on failure.

GetRetryOrPanic 解析重试策略能力,失败时 panic。

func GetRouter

GetRouter resolves the HTTP router facade from the container.

GetRouter 从容器中解析 HTTP 路由门面。

func GetRouterOrPanic

GetRouterOrPanic resolves the HTTP router facade and panics on failure.

GetRouterOrPanic 解析 HTTP 路由门面,失败时 panic。

func GetSQLX

func GetSQLX(c runtimecontract.Container) (*sqlx.DB, error)

GetSQLX resolves the SQLX database handle from the container.

GetSQLX 从容器中解析 SQLX 数据库句柄。

func GetSQLXOrPanic

func GetSQLXOrPanic(c runtimecontract.Container) *sqlx.DB

GetSQLXOrPanic resolves the SQLX database handle and panics on failure.

GetSQLXOrPanic 解析 SQLX 数据库句柄,失败时 panic。

func GetServiceAuthenticator

GetServiceAuthenticator resolves the service authenticator from the container.

GetServiceAuthenticator 从容器中解析服务认证器。

func GetServiceAuthenticatorOrPanic

func GetServiceAuthenticatorOrPanic(c runtimecontract.Container) securitycontract.ServiceAuthenticator

GetServiceAuthenticatorOrPanic resolves the service authenticator and panics on failure.

GetServiceAuthenticatorOrPanic 解析服务认证器,失败时 panic。

func GetServiceTokenIssuer

GetServiceTokenIssuer resolves the service token issuer from the container.

GetServiceTokenIssuer 从容器中解析服务令牌签发器。

func GetServiceTokenIssuerOrPanic

func GetServiceTokenIssuerOrPanic(c runtimecontract.Container) securitycontract.ServiceTokenIssuer

GetServiceTokenIssuerOrPanic resolves the service token issuer and panics on failure.

GetServiceTokenIssuerOrPanic 解析服务令牌签发器,失败时 panic。

func GetValidator

GetValidator resolves the validator capability from the container.

GetValidator 从容器中解析参数校验能力。

func GetValidatorOrPanic

func GetValidatorOrPanic(c runtimecontract.Container) datacontract.Validator

GetValidatorOrPanic resolves the validator capability and panics on failure.

GetValidatorOrPanic 解析参数校验能力,失败时 panic。

func GetWebSocketServer

GetWebSocketServer resolves the WebSocket server from the container.

GetWebSocketServer 从容器中解析 WebSocket 服务器。

func GetWebSocketServerOrPanic

func GetWebSocketServerOrPanic(c runtimecontract.Container) transportcontract.WebSocketServer

GetWebSocketServerOrPanic resolves the WebSocket server and panics on failure.

GetWebSocketServerOrPanic 解析 WebSocket 服务器,失败时 panic。

func MakeAppService

func MakeAppService[T any](c runtimecontract.Container, key string) (T, error)

MakeAppService resolves an app service by key and casts it to the requested type.

MakeAppService 按 key 解析 app service,并转换成目标类型。

func MakeCache

MakeCache is an alias for GetCache.

MakeCache 是 GetCache 的别名。

func MakeConfig

MakeConfig resolves the config capability from the container.

MakeConfig 从容器中解析配置能力。

func MakeCron

MakeCron is an alias for GetCron.

MakeCron 是 GetCron 的别名。

func MakeDBRuntime

func MakeDBRuntime(c runtimecontract.Container) (any, error)

MakeDBRuntime is an alias for GetDBRuntime.

MakeDBRuntime 是 GetDBRuntime 的别名。

func MakeDistributedLock

MakeDistributedLock is an alias for GetDistributedLock.

MakeDistributedLock 是 GetDistributedLock 的别名。

func MakeGRPCConnFactory

MakeGRPCConnFactory is an alias for GetGRPCConnFactory.

MakeGRPCConnFactory 是 GetGRPCConnFactory 的别名。

func MakeGRPCServerRegistrar

MakeGRPCServerRegistrar is an alias for GetGRPCServerRegistrar.

MakeGRPCServerRegistrar 是 GetGRPCServerRegistrar 的别名。

func MakeGormDB

func MakeGormDB(c runtimecontract.Container) (*gormdb.DB, error)

MakeGormDB is an alias for GetGorm.

MakeGormDB 是 GetGorm 的别名。

func MakeHTTP

MakeHTTP is an alias for GetHTTP.

MakeHTTP 是 GetHTTP 的别名。

func MakeHost

MakeHost is an alias for GetHost.

MakeHost 是 GetHost 的别名。

func MakeLogger

MakeLogger is an alias for GetLogger.

MakeLogger 是 GetLogger 的别名。

func MakeMessagePublisher

MakeMessagePublisher is an alias for GetMessagePublisher.

MakeMessagePublisher 是 GetMessagePublisher 的别名。

func MakeMessageSubscriber

MakeMessageSubscriber is an alias for GetMessageSubscriber.

MakeMessageSubscriber 是 GetMessageSubscriber 的别名。

func MakeNamedWith

func MakeNamedWith[T any](c runtimecontract.Container, name, key string) (T, error)

MakeNamedWith resolves a named service and casts it to type T. Returns an error if the service is not bound, resolution fails, or the type does not match.

MakeNamedWith 解析命名服务并转换为类型 T。 如果服务未绑定、解析失败或类型不匹配,返回错误。

func MakeRedis

MakeRedis is an alias for GetRedis.

MakeRedis 是 GetRedis 的别名。

func MakeRetry

MakeRetry is an alias for GetRetry.

MakeRetry 是 GetRetry 的别名。

func MakeRouter

MakeRouter is an alias for GetRouter.

MakeRouter 是 GetRouter 的别名。

func MakeSQLX

func MakeSQLX(c runtimecontract.Container) (*sqlx.DB, error)

MakeSQLX is an alias for GetSQLX.

MakeSQLX 是 GetSQLX 的别名。

func MakeValidator

MakeValidator is an alias for GetValidator.

MakeValidator 是 GetValidator 的别名。

func MakeWith

func MakeWith[T any](c runtimecontract.Container, key string) (T, error)

MakeWith resolves a service by key and casts it to the requested type T. Returns an error if the service is not bound, resolution fails, or the type does not match. Prefer this over raw Make + type assertion for type safety.

MakeWith 按 key 解析服务并转换为类型 T。 如果服务未绑定、解析失败或类型不匹配,返回错误。 优先使用此函数而非裸 Make + 类型断言,以获得类型安全。

func MustMakeAppService

func MustMakeAppService[T any](c runtimecontract.Container, key string) T

MustMakeAppService resolves an app service by key and panics on failure. Uses comma-ok type assertion for a descriptive panic message on mismatch.

MustMakeAppService 按 key 解析 app service,失败时 panic。 使用 comma-ok 类型断言,在类型不匹配时给出描述性 panic 信息。

func MustMakeCache

MustMakeCache is an alias for GetCacheOrPanic.

MustMakeCache 是 GetCacheOrPanic 的别名。

func MustMakeConfig

func MustMakeConfig(c runtimecontract.Container) datacontract.Config

MustMakeConfig is an alias for GetConfigOrPanic.

MustMakeConfig 是 GetConfigOrPanic 的别名。

func MustMakeCron

MustMakeCron is an alias for GetCronOrPanic.

MustMakeCron 是 GetCronOrPanic 的别名。

func MustMakeDB

func MustMakeDB(c runtimecontract.Container) (*gormdb.DB, *sqlx.DB)

MustMakeDB is an alias for GetDBOrPanic.

MustMakeDB 是 GetDBOrPanic 的别名。

func MustMakeDistributedLock

func MustMakeDistributedLock(c runtimecontract.Container) datacontract.DistributedLock

MustMakeDistributedLock is an alias for GetDistributedLockOrPanic.

MustMakeDistributedLock 是 GetDistributedLockOrPanic 的别名。

func MustMakeGRPCConnFactory

MustMakeGRPCConnFactory is an alias for GetGRPCConnFactoryOrPanic.

MustMakeGRPCConnFactory 是 GetGRPCConnFactoryOrPanic 的别名。

func MustMakeGRPCServerRegistrar

func MustMakeGRPCServerRegistrar(c runtimecontract.Container) transportcontract.GRPCServerRegistrar

MustMakeGRPCServerRegistrar is an alias for GetGRPCServerRegistrarOrPanic.

MustMakeGRPCServerRegistrar 是 GetGRPCServerRegistrarOrPanic 的别名。

func MustMakeGorm

func MustMakeGorm(c runtimecontract.Container) *gormdb.DB

MustMakeGorm is an alias for GetGormOrPanic.

MustMakeGorm 是 GetGormOrPanic 的别名。

func MustMakeGormDB

func MustMakeGormDB(c runtimecontract.Container) *gormdb.DB

MustMakeGormDB is an alias for GetGormOrPanic.

MustMakeGormDB 是 GetGormOrPanic 的别名。

func MustMakeHTTP

MustMakeHTTP is an alias for GetHTTPOrPanic.

MustMakeHTTP 是 GetHTTPOrPanic 的别名。

func MustMakeJWT

MustMakeJWT is an alias for GetJWTOrPanic.

MustMakeJWT 是 GetJWTOrPanic 的别名。

func MustMakeJWTService

MustMakeJWTService resolves the JWT service and panics on failure.

MustMakeJWTService 解析 JWT 服务,失败时 panic。

func MustMakeLogger

MustMakeLogger is an alias for GetLoggerOrPanic.

MustMakeLogger 是 GetLoggerOrPanic 的别名。

func MustMakeMessagePublisher

MustMakeMessagePublisher is an alias for GetMessagePublisherOrPanic.

MustMakeMessagePublisher 是 GetMessagePublisherOrPanic 的别名。

func MustMakeMessageSubscriber

MustMakeMessageSubscriber is an alias for GetMessageSubscriberOrPanic.

MustMakeMessageSubscriber 是 GetMessageSubscriberOrPanic 的别名。

func MustMakeNamedWith

func MustMakeNamedWith[T any](c runtimecontract.Container, name, key string) T

MustMakeNamedWith resolves a named service and casts it to type T, panicking on failure.

MustMakeNamedWith 解析命名服务并转换为类型 T,失败时 panic。

func MustMakeRetry

MustMakeRetry is an alias for GetRetryOrPanic.

MustMakeRetry 是 GetRetryOrPanic 的别名。

func MustMakeRouter

MustMakeRouter is an alias for GetRouterOrPanic.

MustMakeRouter 是 GetRouterOrPanic 的别名。

func MustMakeSQLX

func MustMakeSQLX(c runtimecontract.Container) *sqlx.DB

MustMakeSQLX is an alias for GetSQLXOrPanic.

MustMakeSQLX 是 GetSQLXOrPanic 的别名。

func MustMakeValidator

func MustMakeValidator(c runtimecontract.Container) datacontract.Validator

MustMakeValidator is an alias for GetValidatorOrPanic.

MustMakeValidator 是 GetValidatorOrPanic 的别名。

func MustMakeWith

func MustMakeWith[T any](c runtimecontract.Container, key string) T

MustMakeWith resolves a service by key and casts it to type T, panicking on failure. Prefer this over raw MustMake + type assertion for type safety.

MustMakeWith 按 key 解析服务并转换为类型 T,失败时 panic。 优先使用此函数而非裸 MustMake + 类型断言,以获得类型安全。

func PingDBRuntime

func PingDBRuntime(dbAny any) error

PingDBRuntime performs a best-effort health check against different DB runtime shapes.

PingDBRuntime 针对不同数据库运行时形态执行尽力而为的健康检查。

Types

type Container

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

Container is the default runtime container implementation used by the framework.

Container 是框架使用的默认运行时容器实现。

func New

func New() *Container

New creates a new runtime container and self-binds the container contract.

New 创建一个新的运行时容器,并将容器契约自身注册进去。

func (*Container) Bind

func (c *Container) Bind(key string, factory runtimecontract.Factory, singleton bool)

Bind registers a factory under the given key. If the key is already bound, a warning is logged and the previous binding is replaced.

Bind 将指定 factory 注册到目标 key 之下。 如果 key 已绑定,打印警告日志并替换原有绑定。

func (*Container) DebugPrint

func (c *Container) DebugPrint() string

DebugPrint returns a human-readable snapshot of the container state.

DebugPrint 返回容器状态的人类可读快照。

func (*Container) Destroy

func (c *Container) Destroy() error

Destroy calls all registered closers in reverse order and marks the container as destroyed. After Destroy, Make/MakeNamed return ErrContainerDestroyed.

Destroy 按注册逆序调用所有 Closer,并将容器标记为已销毁。 销毁后 Make/MakeNamed 返回 ErrContainerDestroyed。

func (*Container) IsBind

func (c *Container) IsBind(key string) bool

IsBind reports whether the key is directly bound or promised by a deferred provider. 使用单次 RLock 避免 TOCTOU 竞态。

IsBind 返回目标 key 是否已直接绑定,或是否由延迟 provider 承诺提供。

func (*Container) IsBindNamed

func (c *Container) IsBindNamed(name, key string) bool

IsBindNamed reports whether a named binding exists.

IsBindNamed 返回指定命名绑定是否存在。

func (*Container) Make

func (c *Container) Make(key string) (any, error)

Make resolves a service by key. Returns ErrContainerDestroyed if the container has been destroyed. Returns CircularDependencyError if a circular dependency is detected.

Make 按 key 解析服务实例。 如果容器已销毁,返回 ErrContainerDestroyed。 如果检测到循环依赖,返回 CircularDependencyError。

func (*Container) MakeNamed

func (c *Container) MakeNamed(name, key string) (any, error)

MakeNamed resolves a named service by name and key. Returns ErrContainerDestroyed if the container has been destroyed. Returns CircularDependencyError if a circular dependency is detected.

MakeNamed 按名称和 key 解析命名服务实例。 如果容器已销毁,返回 ErrContainerDestroyed。 如果检测到循环依赖,返回 CircularDependencyError。

func (*Container) MustMake

func (c *Container) MustMake(key string) any

MustMake resolves a service by key and panics on failure. The panic message includes the key name for easier debugging.

MustMake 按 key 解析服务,失败时直接 panic。 panic 信息包含 key 名称以便调试。

func (*Container) MustMakeNamed

func (c *Container) MustMakeNamed(name, key string) any

MustMakeNamed resolves a named service by name and key and panics on failure. The panic message includes the name and key for easier debugging.

MustMakeNamed 按名称和 key 解析命名服务,失败时直接 panic。 panic 信息包含 name 和 key 以便调试。

func (*Container) NamedBind

func (c *Container) NamedBind(name, key string, factory runtimecontract.Factory, singleton bool)

NamedBind registers a named factory under the given key. Allows multiple implementations of the same key to coexist under different names. If the name+key combination is already bound, a warning is logged and the previous binding is replaced.

NamedBind 将命名 factory 绑定到目标 key 之下。 允许同一 key 的多个实现以不同名称共存。 如果 name+key 组合已绑定,打印警告日志并替换原有绑定。

func (*Container) ProviderDAG

func (c *Container) ProviderDAG() runtimecontract.ProviderDAG

ProviderDAG builds and returns the provider dependency graph. It analyzes all registered providers, their provides/depends declarations, and computes the recommended load order with cycle detection.

ProviderDAG 构建并返回 provider 依赖图。 分析所有已注册的 provider,其 provides/depends 声明, 计算推荐加载顺序并检测循环依赖。

func (*Container) ProviderNames

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

ProviderNames returns the registered provider names in lexicographical order.

ProviderNames 按字典序返回当前已注册的 provider 名称列表。

中文说明: - 这是一个仅供调试与框架命令使用的辅助方法。 - 它没有被放入公共 `contract.Container` 接口,避免把管理侧能力暴露成运行时通用契约。 - 当前主要服务于类似 `gorp provider list` 这类工具场景。

func (*Container) RegisterCloser

func (c *Container) RegisterCloser(key string, closer io.Closer)

RegisterCloser registers an io.Closer to be called during Destroy. Closers are called in reverse registration order.

RegisterCloser 注册一个 io.Closer,在 Destroy 时调用。 Closer 按注册逆序调用。

func (*Container) RegisterProvider

func (c *Container) RegisterProvider(p runtimecontract.ServiceProvider) error

RegisterProvider registers a provider into the container and loads it immediately when not deferred.

RegisterProvider 将 provider 注册进容器;若不是延迟 provider,则立刻装载。

func (*Container) RegisterProviders

func (c *Container) RegisterProviders(providers ...runtimecontract.ServiceProvider) error

RegisterProviders registers multiple providers in order.

RegisterProviders 按顺序注册多个 provider。

func (*Container) RegisteredProviders

func (c *Container) RegisteredProviders() []runtimecontract.ProviderInfo

RegisteredProviders returns information about all registered providers.

RegisteredProviders 返回所有已注册 provider 的信息。

Jump to

Keyboard shortcuts

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