svc

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateDataType added in v1.0.4

func ValidateDataType(dir string)

func ValidateRestApi added in v1.0.4

func ValidateRestApi(dir string, ic astutils.InterfaceCollector)

ValidateRestApi is checking whether parameter types in each of service interface methods valid or not Only support at most one golang non-built-in type as parameter in a service interface method because go-doudou cannot put more than one parameter into request body except v3.FileModel. If there are v3.FileModel parameters, go-doudou will assume you want a multipart/form-data api Support struct, map[string]ANY, built-in type and corresponding slice only Not support anonymous struct as parameter

Types

type ISvc added in v1.0.6

type ISvc interface {
	SetWatcher(w *watcher.Watcher)
	GetWatcher() *watcher.Watcher
	GetDir() string
	Http()
	Init()
	Push(repo string)
	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 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
	// Jsonattrcase is attribute case converter name when marshal structs to json
	Jsonattrcase string
	// 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

	// ImagePrefix is image name prefix string used for building and pushing docker image
	ImagePrefix 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
	// contains filtered or unexported fields
}

Svc wraps all config properties for commands

func (*Svc) Deploy

func (receiver *Svc) Deploy(k8sfile string)

Deploy deploys project to kubernetes. If k8sfile flag not set, it will be deployed as statefulset kind using statefulset.yaml file in the project root, so if you want to deploy a monolithic project, please set k8sfile flag.

func (*Svc) DoRestart added in v1.0.4

func (receiver *Svc) DoRestart()

TODO there is a bug here on windows

func (*Svc) DoRun added in v1.0.4

func (receiver *Svc) DoRun()

func (*Svc) DoWatch added in v1.0.4

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 added in v1.2.2

func (receiver *Svc) GenIntegrationTestingCode()

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

func (*Svc) GetDir added in v1.0.4

func (receiver *Svc) GetDir() string

func (*Svc) GetWatcher added in v1.0.4

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

func (*Svc) Grpc added in v1.2.11

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(repo string)

Push executes go mod vendor command first, then build docker image and push to remote image repository It also generates deployment kind(for monolithic) and statefulset kind(for microservice) 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) SetWatcher added in v1.0.4

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 statefulset.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 added in v1.0.4

type SvcOption func(svc *Svc)

func WithImagePrefix added in v1.0.6

func WithImagePrefix(imagePrefix string) SvcOption

func WithModName added in v1.0.6

func WithModName(modName string) SvcOption

func WithRunner added in v1.0.4

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