gen

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeGormModel - type gorm model gen
	TypeGormModel = "gorm_model"
	// TypeBeegoModel - type beego model gen
	TypeBeegoModel = "beego_model"
	// TypeService - type service gen
	TypeService = "service"
)

Variables

This section is empty.

Functions

func Register

func Register(name string, adapter Instance)

Register makes a Generator adapter available by the adapter name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type Config

type Config struct {
	Package    string           `json:"package"`
	GenPath    string           `json:"gen_path"`
	AllInOne   bool             `json:"all_in_one"`
	ModelCfg   ModelGenConfig   `json:"model_cfg"`
	ServiceCfg ServiceGenConfig `json:"service_cfg"`
}

Config - init config

type Generator

type Generator interface {
	// Gen - gen file
	Gen() error

	// start gc routine based on config settings.
	StartAndGC(config Config) error
}

Generator interface contains all behaviors for model generator adapter.

func NewGenerator

func NewGenerator(adapterName string, config Config) (adapter Generator, err error)

NewGenerator Create a new Generator driver by adapter name and config setting. it will start gc automatically.

type Instance

type Instance func() Generator

Instance is a function create a new Generator Instance

type Item

type Item struct {
	Name      string   `json:"name"`
	Relations []string `json:"relations"`
	Detail    string   `json:"detail"`
}

Item - gen item

type ModelGenConfig added in v0.0.6

type ModelGenConfig struct {
	Items        []Item `json:"items"`
	MaxIdleConns int64  `json:"max_idle_conns"`
	MaxOpenConns int64  `json:"set_max_open_conns"`
}

ModelGenConfig - model config

type SItem added in v0.0.6

type SItem struct {
	Req      interface{} `json:"req"`
	Dst      interface{} `json:"dst"`
	Index    int64       `json:"index"`
	CheckApp bool        `json:"check_app"`
}

SItem - service config item

type ServiceGenConfig added in v0.0.6

type ServiceGenConfig struct {
	Items       []SItem         `json:"items"`
	ImportPaths []string        `json:"import_paths"`
	IgnoreName  map[string]bool `json:"ignore_name"`
	KeepName    map[string]bool `json:"keep_name"`
}

ServiceGenConfig - service config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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