Documentation
¶
Index ¶
- Variables
- func NewApplication(ctx *bootstrap.Context, assets Assets, modules module.Modules) (*kratos.App, func(), error)
- func NewApplicationWithOptions(ctx *bootstrap.Context, assets Assets, modules module.Modules, ...) (*kratos.App, func(), error)
- type ApplicationOption
- func WithGRPCMiddlewares(middlewares ...kratosMiddleware.Middleware) ApplicationOption
- func WithHTTPMiddlewares(middlewares ...kratosMiddleware.Middleware) ApplicationOption
- func WithHealthChecks(checks ...module.HealthCheck) ApplicationOption
- func WithQueue(queue kitQueue.Queue) ApplicationOption
- func WithQueueConsumers(consumers ...module.QueueConsumer) ApplicationOption
- func WithSSERegistry(registry *coreSSE.Registry) ApplicationOption
- func WithSSEServer(server *sseServer.Server) ApplicationOption
- func WithSSEServerListener(listener net.Listener) ApplicationOption
- func WithSSEStreams(streams ...module.SSEStream) ApplicationOption
- func WithScripts(scripts ...module.Script) ApplicationOption
- func WithServers(servers ...kratosTransport.Server) ApplicationOption
- func WithStartupHooks(hooks ...module.StartupHook) ApplicationOption
- func WithStaticMounts(mounts ...module.StaticMount) ApplicationOption
- func WithTasks(tasks ...module.Task) ApplicationOption
- type Assets
- type Runtime
- type RuntimeAware
Constants ¶
This section is empty.
Variables ¶
var ProviderSet = wire.NewSet(NewApplication)
ProviderSet 是 Core 对外唯一的 Wire 依赖注入入口。外部组合根只需要把本集合加入自己的 wire.Build;Core 内部的运行时对象图会由 NewApplication 统一创建,内部包不会泄漏到宿主项目的生成代码中。
Functions ¶
Types ¶
type ApplicationOption ¶
type ApplicationOption = option
ApplicationOption 表示宿主可传入的 Core 应用装配选项。
func WithGRPCMiddlewares ¶
func WithGRPCMiddlewares(middlewares ...kratosMiddleware.Middleware) ApplicationOption
WithGRPCMiddlewares 追加 gRPC 服务端拦截器。
func WithHTTPMiddlewares ¶
func WithHTTPMiddlewares(middlewares ...kratosMiddleware.Middleware) ApplicationOption
WithHTTPMiddlewares 追加 HTTP 服务端拦截器。
func WithHealthChecks ¶
func WithHealthChecks(checks ...module.HealthCheck) ApplicationOption
WithHealthChecks 追加组合根提供的就绪检查。
func WithQueue ¶
func WithQueue(queue kitQueue.Queue) ApplicationOption
WithQueue 注入队列适配器;未注入时由 Core 根据配置创建。
func WithQueueConsumers ¶
func WithQueueConsumers(consumers ...module.QueueConsumer) ApplicationOption
WithQueueConsumers 追加组合根提供的队列消费者。
func WithSSERegistry ¶
func WithSSERegistry(registry *coreSSE.Registry) ApplicationOption
WithSSERegistry 使用调用方创建的 SSE 注册表。
func WithSSEServer ¶
func WithSSEServer(server *sseServer.Server) ApplicationOption
WithSSEServer 注入由宿主创建的 SSE 服务。
func WithSSEServerListener ¶
func WithSSEServerListener(listener net.Listener) ApplicationOption
WithSSEServerListener 注入由 Core 管理生命周期的独立 SSE 监听器。
func WithSSEStreams ¶
func WithSSEStreams(streams ...module.SSEStream) ApplicationOption
WithSSEStreams 追加组合根提供的 SSE 流。
func WithScripts ¶
func WithScripts(scripts ...module.Script) ApplicationOption
WithScripts 追加组合根提供的启动脚本。
func WithServers ¶
func WithServers(servers ...kratosTransport.Server) ApplicationOption
WithServers 追加需要跟随 Core 生命周期运行的后台服务。
func WithStartupHooks ¶
func WithStartupHooks(hooks ...module.StartupHook) ApplicationOption
WithStartupHooks 追加组合根提供的启动钩子。
func WithStaticMounts ¶
func WithStaticMounts(mounts ...module.StaticMount) ApplicationOption
WithStaticMounts 追加组合根提供的静态资源挂载。
type Assets ¶
type Assets struct {
// OpenAPIData 是可选的 Core 基础服务 OpenAPI YAML 或 JSON 内容。
OpenAPIData []byte
// DocsData 是可选的项目文档生成器输出 JSON 内容。
DocsData []byte
// Migrations 是可选的 Core 基础服务版本化迁移资源。
Migrations []gormmigration.Migration
}
Assets 是宿主项目传入 Core 的构建期资源。
type Runtime ¶
type Runtime struct {
// Context 是 Core 使用的宿主启动上下文。
Context *bootstrap.Context
// Cache 是 Core 与模块共享的缓存客户端。
Cache cache.Cache
// Queue 是 Core 与模块共享的队列客户端。
Queue queue.Queue
// Database 是 Core 与模块共享的数据库客户端。
Database *databaseGorm.Client
// Pprof 是 Core 使用的性能分析客户端。
Pprof pprof.Pprof
// Authenticator 是 Core 与模块共享的认证器。
Authenticator authnEngine.Authenticator
// Authorizer 是 Core 与模块共享的鉴权引擎。
Authorizer authzEngine.Engine
// UserToken 是 Core 与模块共享的用户令牌存储。
UserToken *authData.UserToken
// JWTConfig 是 Core 使用的 JWT 配置。
JWTConfig *bootstrapConfigv1.Authentication_Jwt
// TaskRegistry 是 Core 与模块共享的任务注册表。
TaskRegistry *coreTask.Registry
// JobScheduler 是 Core 与模块共享的持久化定时任务调度器。
JobScheduler coreTask.JobScheduler
// OpenAPIRegistry 是 Core 与模块共享的 OpenAPI 注册表。
OpenAPIRegistry *coreOpenAPI.Registry
// SSEServer 是 Core 与模块共享的 SSE 服务。
SSEServer *sseServer.Server
// SSERegistry 是模块共享的 SSE 流注册表。
SSERegistry *coreSSE.Registry
// SSEPublisher 是模块共享的 SSE 消息发布器。
SSEPublisher *coreSSE.Publisher
}
Runtime 是 Core 初始化完成后向外部业务模块公开的共享运行时。
type RuntimeAware ¶
type RuntimeAware interface {
// Initialize 使用 Core 运行时完成模块装配,并返回模块资源清理函数。
Initialize(*Runtime) (func(), error)
}
RuntimeAware 表示需要在 Core 运行时就绪后完成业务装配的外部模块。