sqlkratos

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, opts GeneratorOptions) error

Types

type Generator

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

func NewGenerator

func NewGenerator() *Generator

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context, opts GeneratorOptions) error

func (*Generator) WriteDataPackageCode

func (g *Generator) WriteDataPackageCode(
	outputPath string,
	orm string,
	projectName string,
	serviceName string,
	name string,
	moduleName, moduleVersion string,
	protoFields []generators.DataField,
) error

func (*Generator) WriteDataWireSetCode

func (g *Generator) WriteDataWireSetCode(
	outputPath string,
	projectModule string,
	serviceName string,
	allFunctions []string,
) error

WriteDataWireSetCode 生成 data 层的 wire_set,支持 client 和 data 两个包的函数

func (*Generator) WriteMainCode

func (g *Generator) WriteMainCode(
	outputPath string,

	projectName string,
	serviceName string,

	servers []string,
) error

func (*Generator) WriteServerPackageCode

func (g *Generator) WriteServerPackageCode(
	outputPath string,
	projectName string,
	serviceType string,
	serviceName string,
	services map[string]string,
) error

func (*Generator) WriteServicePackageCode

func (g *Generator) WriteServicePackageCode(
	outputPath string,
	projectName string,
	serviceName string,
	name string,
	targetModuleName, sourceModuleName, moduleVersion string,
	useRepo, isGrpcService bool,
) error

func (*Generator) WriteWireCode

func (g *Generator) WriteWireCode(
	outputPath string,

	projectName string,
	serviceName string,
) error

func (*Generator) WriteWireSetCode

func (g *Generator) WriteWireSetCode(
	outputPath string,
	projectModule string,
	serviceName string,
	packageName string,
	postfix string,
	services []string,
) error

type GeneratorOption

type GeneratorOption func(*GeneratorOptions)

func WithExcludedTables

func WithExcludedTables(tables []string) GeneratorOption

func WithIncludedTables

func WithIncludedTables(tables []string) GeneratorOption

func WithModuleName

func WithModuleName(name string) GeneratorOption

func WithModuleVersion

func WithModuleVersion(ver string) GeneratorOption

func WithOutputPath

func WithOutputPath(path string) GeneratorOption

func WithSource

func WithSource(dsn string) GeneratorOption

func WithSourceModuleName

func WithSourceModuleName(name string) GeneratorOption

type GeneratorOptions

type GeneratorOptions struct {
	Driver string
	Source string // Data Source name (DSN), e.g., "mysql://user:pass@tcp(localhost:3306)/dbname"

	IncludedTables []string
	ExcludedTables []string

	OutputPath string

	SourceModuleName string // for REST service, the Source module name
	ModuleName       string
	ModuleVersion    string

	// ProtoPackageStrategy controls how proto packages are organized.
	// "per-table" - each table gets its own proto package (e.g. user.service.v1)
	// "by-service" - all tables under a service share one proto package (e.g. admin.service.v1)
	// "custom" - use the package name from TableCustomPackages for each table
	ProtoPackageStrategy string

	// TableCustomPackages maps table name -> custom proto package name.
	// Only used when ProtoPackageStrategy is "custom".
	TableCustomPackages map[string]string

	OrmType string // ORM type, e.g., "gorm", "sqlx", "ent"

	ProjectName string
	ServiceName string

	Servers []string

	UseRepo bool

	GenerateProto    bool
	GenerateServer   bool
	GenerateService  bool
	GenerateORM      bool
	GenerateData     bool
	GenerateMain     bool
	GenerateConfig   bool
	GenerateMakefile bool
}

Jump to

Keyboard shortcuts

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