svc

package
v2.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbConfig added in v2.0.9

type DbConfig struct {
	Driver string
	Dsn    string
	// or schema for pg
	TablePrefix      string
	TableGlob        string
	TableExcludeGlob string
	// whether generate gen.go file
	GenGenGo    bool
	Orm         string
	Soft        string
	Service     string
	Omitempty   bool
	TypeMapping string
}

type ISvc

type ISvc interface {
	SetWatcher(w *watcher.Watcher)
	GetWatcher() *watcher.Watcher
	GetDir() string
	Http()
	Init()
	Crud()
	Push(cfg PushConfig)
	Deploy(k8sfile string)
	Shutdown(k8sfile string)
	GenClient()
	DoRun()
	DoRestart()
	DoWatch()
	Run(watch bool)
	Upgrade(version string)
	Grpc()
}

func NewSvc

func NewSvc(dir string, opts ...SvcOption) ISvc

NewSvc new Svc instance

type PushConfig added in v2.0.3

type PushConfig struct {
	Repo   string
	Prefix string
	Ver    string
}

type Svc

type Svc struct {

	// Handler indicates whether generate default http handler implementation code or not
	Handler bool
	// Client is client language name
	Client bool
	// Omitempty indicates whether omit empty when marshal structs to json
	Omitempty bool
	// Doc indicates whether generate OpenAPI 3.0 json doc file
	Doc bool
	// DocPath is OpenAPI 3.0 json doc file path used for generating client code
	DocPath string
	// Env is service base url environment variable name used for generating client code
	Env string
	// ClientPkg is client package name
	ClientPkg string

	// for being compatible with legacy code purpose only
	RoutePatternStrategy int

	// ModName is go module name
	ModName string

	// PostmanCollectionPath is postman collection v2.1 compatible file disk path
	PostmanCollectionPath string
	// DotenvPath dotenv format config file disk path only for integration testing purpose
	DotenvPath string

	// AllowGetWithReqBody indicates whether allow get http request with request body.
	// If true, when you defined a get api with struct type parameter in svc.go file,
	// it will try to decode json format encoded request body.
	AllowGetWithReqBody bool

	DbConfig *DbConfig

	JsonCase      string
	CaseConverter func(string) string
	// contains filtered or unexported fields
}

Svc wraps all config properties for commands

func (*Svc) Crud added in v2.4.3

func (receiver *Svc) Crud()

func (*Svc) Deploy

func (receiver *Svc) Deploy(k8sfile string)

Deploy deploys project to kubernetes. If k8sfile flag not set, it will be deployed as deployment kind using *_deployment.yaml file in the project root,

func (*Svc) DoRestart

func (receiver *Svc) DoRestart()

TODO there is a bug here on windows

func (*Svc) DoRun

func (receiver *Svc) DoRun()

func (*Svc) DoWatch

func (receiver *Svc) DoWatch()

func (*Svc) GenClient

func (receiver *Svc) GenClient()

GenClient generates http client code from OpenAPI3.0 description json file, only support Golang currently.

func (*Svc) GenIntegrationTestingCode

func (receiver *Svc) GenIntegrationTestingCode()

GenIntegrationTestingCode generates integration testing code from postman collection v2.1 compatible file

func (*Svc) GetDir

func (receiver *Svc) GetDir() string

func (*Svc) GetWatcher

func (receiver *Svc) GetWatcher() *watcher.Watcher

func (*Svc) Grpc

func (receiver *Svc) Grpc()

func (*Svc) Http

func (receiver *Svc) Http()

Http generates main function, config files, db connection function, http routes, http handlers, service interface and service implementation from the result of ast parsing svc.go file in the project root. It may panic if validation failed

func (*Svc) Init

func (receiver *Svc) Init()

Init inits a project

func (*Svc) Push

func (receiver *Svc) Push(cfg PushConfig)

Push executes go mod vendor command first, then build docker image and push to remote image repository It also generates deployment kind and statefulset kind yaml files for kubernetes deploy, if these files already exist, it will only change the image version in each file, so you can edit these files manually to fit your need.

func (*Svc) Run

func (receiver *Svc) Run(watch bool)

Run runs the project locally. Recommend to set watch flag to enable watch mode for rapid development.

func (*Svc) SetRunner added in v2.0.9

func (receiver *Svc) SetRunner(runner executils.Runner)

func (*Svc) SetWatcher

func (receiver *Svc) SetWatcher(w *watcher.Watcher)

func (*Svc) Shutdown

func (receiver *Svc) Shutdown(k8sfile string)

Shutdown stops and removes the project from kubernetes. If k8sfile flag not set, it will use *_deployment.yaml file in the project root, so if you had already set k8sfile flag when you deploy the project, you should set the same k8sfile flag.

func (*Svc) Upgrade

func (receiver *Svc) Upgrade(version string)

Upgrade upgrades go-doudou to latest release version

type SvcOption

type SvcOption func(svc *Svc)

func WithAllowGetWithReqBody added in v2.1.9

func WithAllowGetWithReqBody(allowGetWithReqBody bool) SvcOption

func WithCaseConverter added in v2.1.7

func WithCaseConverter(fn func(string) string) SvcOption

func WithDbConfig added in v2.0.9

func WithDbConfig(dbConfig *DbConfig) SvcOption

func WithDocPath added in v2.0.4

func WithDocPath(docfile string) SvcOption

func WithHttp2Grpc added in v2.1.9

func WithHttp2Grpc(http2grpc bool) SvcOption

func WithJsonCase added in v2.1.7

func WithJsonCase(jsonCase string) SvcOption

func WithModName

func WithModName(modName string) SvcOption

func WithModule added in v2.1.6

func WithModule(module bool) SvcOption

func WithOmitempty added in v2.3.8

func WithOmitempty(omitempty bool) SvcOption

func WithProjectType added in v2.4.3

func WithProjectType(projectType string) SvcOption

func WithProtoGenerator added in v2.1.6

func WithProtoGenerator(protoGenerator v3.ProtoGenerator) SvcOption

func WithRunner

func WithRunner(runner executils.Runner) SvcOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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