module

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet 收集宿主模块和独立资源,并派生模型、国际化、OpenAPI 和迁移资源快照。

Functions

This section is empty.

Types

type I18n

type I18n []ResourcesItem

I18n 是模块国际化文件资源集合。

func NewI18nFromResources

func NewI18nFromResources(resources Resources) I18n

NewI18nFromResources 收集模块资源中的国际化文件系统。

type Migration

type Migration struct {
	// Name 是迁移模块的稳定标识。
	Name string
	// FS 是迁移脚本所在的文件系统。
	FS fs.FS
	// Path 是迁移版本目录在文件系统中的根路径。
	Path string
	// Dependencies 是当前迁移模块依赖的其他迁移模块名称。
	Dependencies []string
}

Migration 描述一个模块提供的版本化数据库迁移资源。

type Migrations

type Migrations []Migration

Migrations 是模块数据库迁移资源集合。

func NewMigrations

func NewMigrations(resources Resources) Migrations

NewMigrations 收集模块资源中的数据库迁移资源。

type Models

type Models map[string][]interface{}

Models 按数据源名称保存模块提供的数据库模型。

func NewModels

func NewModels(resources Resources) Models

NewModels 按数据源名称汇总模块资源中的数据库模型。

type Module

type Module interface {
	// RegisterGRPC 将模块 gRPC 服务注册到宿主。
	RegisterGRPC(grpc.ServiceRegistrar)
	// RegisterHTTP 将模块 HTTP 服务注册到宿主。
	RegisterHTTP(*http.Server)
	// RegisterMCP 将模块 MCP 工具注册到宿主。
	RegisterMCP(*mcp.Server)
}

Module 定义宿主业务模块向 Core 提供的协议注册能力。

type Modules

type Modules []Module

Modules 聚合多个宿主业务模块,并统一转发协议注册。

func (Modules) RegisterGRPC

func (modules Modules) RegisterGRPC(registrar grpc.ServiceRegistrar)

RegisterGRPC 将全部模块 gRPC 服务注册到宿主。

func (Modules) RegisterHTTP

func (modules Modules) RegisterHTTP(server *http.Server)

RegisterHTTP 将全部模块 HTTP 路由注册到宿主。

func (Modules) RegisterMCP

func (modules Modules) RegisterMCP(server *mcp.Server)

RegisterMCP 将全部模块 MCP 工具注册到宿主。

type OpenAPI

type OpenAPI []ResourcesItem

OpenAPI 是模块 OpenAPI 文档资源集合。

func NewOpenAPIFromResources

func NewOpenAPIFromResources(resources Resources) OpenAPI

NewOpenAPIFromResources 收集模块资源中的 OpenAPI 文件系统。

type Resource added in v0.0.6

type Resource interface {
	// ProjectKey 是宿主项目的稳定标识,用于 OpenAPI 命名空间;留空时使用 kratos-core。
	ProjectKey() string
	// ProjectName 是宿主项目展示名称,留空时使用 ProjectKey。
	ProjectName() string
	// Models 是宿主数据库自动迁移所需的模型。
	Models() Models
	// I18n 是宿主项目语言 JSON 文件系统,文件名应使用 locale 标识。
	I18n() fs.FS
	// OpenAPI 是宿主项目生成的 Swagger/OpenAPI 文件系统集合,包含默认 openapi.yaml 和可选的 openapi.<locale>.yaml。
	OpenAPI() fs.FS
	// Migrations 是宿主提供的数据库迁移资源。
	Migrations() Migrations
}

Resource 定义宿主向 Core 提供的一组静态资源。

type Resources

type Resources []Resource

Resources 聚合多个宿主提供的静态资源。

type ResourcesItem

type ResourcesItem struct {
	// FS 是资源所在的文件系统。
	FS fs.FS
	// ProjectKey 是宿主项目的稳定标识,用于 OpenAPI 命名空间;留空时使用 kratos-core。
	ProjectKey string
	// ProjectName 是宿主项目展示名称,留空时使用 ProjectKey。
	ProjectName string
}

ResourcesItem 描述一组带项目归属信息的文件系统资源。

Jump to

Keyboard shortcuts

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