app

package module
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 24 Imported by: 83

README

App Starter

Go project version issues Go Report Card Source graph License

Delete tag

$ git tag -d v0.4.0
Deleted tag 'v0.4.0' (was f74dcae)

$ git push origin :v0.4.0
To https://github.com/lishimeng/app-starter.git
 - [deleted]         3.3.0.1492

Documentation

Index

Constants

View Source
const (
	DockerfileName = "Dockerfile"
	BuildFileName  = "build.sh"
)

Variables

This section is empty.

Functions

func GenerateDockerfile added in v1.7.2

func GenerateDockerfile(config ApplicationConfig) (err error)

func GetAmqp added in v1.8.0

func GetAmqp() (session rabbit.Session)

func GetCache added in v1.4.0

func GetCache() (c cache.C)

func GetMqtt added in v1.10.0

func GetMqtt() (session mqtt.Session)

func GetNamedOrm added in v1.6.9

func GetNamedOrm(aliaName string) *persistence.OrmContext

func GetOrm

func GetOrm() *persistence.OrmContext

func Query added in v1.6.6

func Query(h func(ctx persistence.OrmContext) (err error)) (err error)

func Transaction added in v1.6.6

func Transaction(h func(ctx persistence.TxContext) error) (err error)

Types

type Application

type Application interface {
	Start(buildHandler func(ctx context.Context, builder *ApplicationBuilder) error, onTerminate func(string)) error
}

func New

func New() (instance Application)

type ApplicationBuilder added in v1.2.1

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

func (*ApplicationBuilder) ComponentAfter added in v1.2.1

func (h *ApplicationBuilder) ComponentAfter(component func(context.Context) (err error)) *ApplicationBuilder

func (*ApplicationBuilder) ComponentBefore added in v1.2.1

func (h *ApplicationBuilder) ComponentBefore(component func(context.Context) (err error)) *ApplicationBuilder

func (*ApplicationBuilder) EnableAmqp added in v1.8.0

func (*ApplicationBuilder) EnableCache added in v1.4.0

func (h *ApplicationBuilder) EnableCache(redisOpts cache.RedisOptions, cacheOpts cache.Options) *ApplicationBuilder

func (*ApplicationBuilder) EnableDatabase added in v1.2.1

func (h *ApplicationBuilder) EnableDatabase(config persistence.BaseConfig,
	models ...interface{}) *ApplicationBuilder

func (*ApplicationBuilder) EnableMqtt added in v1.10.0

func (h *ApplicationBuilder) EnableMqtt(options ...mqtt.ClientOption) *ApplicationBuilder

func (*ApplicationBuilder) EnableOrmLog added in v1.7.3

func (h *ApplicationBuilder) EnableOrmLog() *ApplicationBuilder

func (*ApplicationBuilder) EnableStaticWeb added in v1.2.1

func (h *ApplicationBuilder) EnableStaticWeb(assetFile func() http.FileSystem) *ApplicationBuilder

func (*ApplicationBuilder) EnableTokenValidator added in v1.9.0

func (h *ApplicationBuilder) EnableTokenValidator(builder TokenValidatorBuilder) *ApplicationBuilder

EnableTokenValidator 验证Token,使用RedisTokenValidator前需要enableCache

func (*ApplicationBuilder) EnableWeb added in v1.2.1

func (h *ApplicationBuilder) EnableWeb(listen string, components ...server.Component) *ApplicationBuilder

func (*ApplicationBuilder) HealthyHandler added in v1.5.0

func (h *ApplicationBuilder) HealthyHandler(handler func() int) *ApplicationBuilder

func (*ApplicationBuilder) LoadConfig added in v1.2.1

func (h *ApplicationBuilder) LoadConfig(config interface{}, callback func(etc.Loader)) (err error)

func (*ApplicationBuilder) PrintVersion added in v1.7.3

func (h *ApplicationBuilder) PrintVersion() *ApplicationBuilder

func (*ApplicationBuilder) ReadyHandler added in v1.5.0

func (h *ApplicationBuilder) ReadyHandler(handler func() int) *ApplicationBuilder

func (*ApplicationBuilder) RegisterAmqpHandlers added in v1.10.2

func (h *ApplicationBuilder) RegisterAmqpHandlers(handlers ...amqp.Handler) *ApplicationBuilder

RegisterAmqpHandlers 注册amqp handler

业务类任务使用延时执行策略,在连接型任务之后执行

func (*ApplicationBuilder) SetMonitorPrefix added in v1.5.0

func (h *ApplicationBuilder) SetMonitorPrefix(prefix string) *ApplicationBuilder

func (*ApplicationBuilder) SetWebLogLevel added in v1.3.3

func (h *ApplicationBuilder) SetWebLogLevel(lvl string) *ApplicationBuilder

type ApplicationConfig added in v1.7.2

type ApplicationConfig struct {
	Name               string `json:"name,omitempty"`
	MainPath           string `json:"mainPath,omitempty"`
	DockerOrganization string `json:"dockerOrganization,omitempty"`
	DateCmd            string `json:"dateCmd"`
	CompilerCmd        string `json:"compilerCmd"`
}

type Pager added in v1.1.3

type Pager struct {
	TotalPage int           `json:"totalPage"` // 总页数
	PageSize  int           `json:"pageSize"`  // 页面大小
	PageNum   int           `json:"pageNum"`   // 页号
	More      int           `json:"more"`      // 是否有下一页
	Data      []interface{} `json:"items,omitempty"`
}

func QueryList added in v1.6.6

func QueryList(req Pager,
	dataPtr interface{},
	queryHandler func(ctx persistence.OrmContext) (qs orm.QuerySeter),
	orderHandler func(persistence.OrmContext, orm.QuerySeter) (qs orm.QuerySeter),
	processHandler ...func(ctx persistence.OrmContext, dataPtr interface{}) error,

) (p Pager, err error)

func (*Pager) Offset added in v1.6.6

func (p *Pager) Offset() int

func (*Pager) Total added in v1.6.6

func (p *Pager) Total(count int64) int

type PagerResponse added in v1.1.3

type PagerResponse struct {
	Response
	Pager
}

type Pk added in v1.9.11

type Pk struct {
	// ID
	Id int `orm:"pk;auto;column(id)"`
}

type Response added in v1.1.3

type Response struct {
	Code    interface{} `json:"code,omitempty"`
	Success interface{} `json:"success,omitempty"`
	Message string      `json:"message,omitempty"`
}

func (*Response) SetCode added in v1.1.3

func (r *Response) SetCode(code int) *Response

func (*Response) SetSuccess added in v1.1.3

func (r *Response) SetSuccess(success bool) *Response

type TableChangeInfo added in v1.9.11

type TableChangeInfo struct {
	// 状态
	Status int `orm:"column(status)"`
	// 创建时间
	CreateTime time.Time `orm:"auto_now_add;type(datetime);column(ctime)"`
	// 修改时间
	UpdateTime time.Time `orm:"auto_now;type(datetime);column(mtime)"`
}

type TableInfo added in v1.9.11

type TableInfo struct {
	// 创建时间
	CreateTime time.Time `orm:"auto_now_add;type(datetime);column(ctime)"`
}

type TokenValidatorBuilder added in v1.9.0

type TokenValidatorBuilder func(injectFunc TokenValidatorInjectFunc)

type TokenValidatorInjectFunc added in v1.9.0

type TokenValidatorInjectFunc func(storage token.Storage)

Directories

Path Synopsis
application
api

Jump to

Keyboard shortcuts

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