app

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 24 Imported by: 0

README

application-launcher

应用程序启动器

Documentation

Index

Constants

View Source
const (
	Disable = iota
	Enable
)

Variables

This section is empty.

Functions

func AmqpPub

func AmqpPub(m rabbit.Message) error

func GetAmqp

func GetAmqp() (session rabbit.Session)

func GetCache

func GetCache() (c cache.C)

func GetMqtt

func GetMqtt() (session mqtt.Session)

func GetNamedOrm

func GetNamedOrm(aliaName string) *persistence.OrmContext

func GetOrm

func GetOrm() *persistence.OrmContext

func GetRpc added in v0.0.2

func GetRpc() (session rpc.Session)

func MqttPub

func MqttPub(topic string, qos byte, retained bool, data []byte) error

func MqttPublish

func MqttPublish(topic string, data []byte) error

func Query

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

func Transaction

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

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

func (*ApplicationBuilder) ComponentAfter

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

func (*ApplicationBuilder) ComponentBefore

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

func (*ApplicationBuilder) EnableAmqp

func (*ApplicationBuilder) EnableCache

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

func (*ApplicationBuilder) EnableDatabase

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

func (*ApplicationBuilder) EnableMqtt

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

func (*ApplicationBuilder) EnableOrmLog

func (h *ApplicationBuilder) EnableOrmLog() *ApplicationBuilder

func (*ApplicationBuilder) EnableRpcClient added in v0.0.2

func (h *ApplicationBuilder) EnableRpcClient(rpcOpts ...rpc.RpcClientOptions) *ApplicationBuilder

func (*ApplicationBuilder) EnableRpcServer added in v0.0.2

func (h *ApplicationBuilder) EnableRpcServer(rpcOpts ...rpc.RpcServerOptions) *ApplicationBuilder

默认80端口

func (*ApplicationBuilder) EnableStaticWeb

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

func (*ApplicationBuilder) EnableTokenValidator

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

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

func (*ApplicationBuilder) EnableWeb

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

func (*ApplicationBuilder) HealthyHandler

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

func (*ApplicationBuilder) LoadConfig

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

func (*ApplicationBuilder) PrintVersion

func (h *ApplicationBuilder) PrintVersion() *ApplicationBuilder

func (*ApplicationBuilder) ReadyHandler

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

func (*ApplicationBuilder) RegisterAmqpHandlers

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

RegisterAmqpHandlers 注册amqp handler

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

func (*ApplicationBuilder) RegisterRpcMethods added in v0.0.2

func (h *ApplicationBuilder) RegisterRpcMethods(methods ...any) *ApplicationBuilder

func (*ApplicationBuilder) SetMonitorPrefix

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

func (*ApplicationBuilder) SetWebLogLevel

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

type OperatorChangeInfo

type OperatorChangeInfo struct {
	OperatorInfo
	UpdateOperator int `orm:"column(moperator)"`
}

OperatorChangeInfo 不可与 OperatorInfo 同时使用

type OperatorInfo

type OperatorInfo struct {
	CreateOperator int `orm:"column(coperator)"`
}

type Pager

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

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

func (p *Pager) Offset() int

func (*Pager) Total

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

type PagerResponse

type PagerResponse struct {
	Response
	Pager
}

type Pk

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

type Response

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

func (*Response) SetCode

func (r *Response) SetCode(code int)

type ResponseWrapper

type ResponseWrapper struct {
	Response
	Data interface{} `json:"data,omitempty"`
}

type TableChangeInfo

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

TableChangeInfo 不可与 TableInfo 同时使用

type TableInfo

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

type Tenant

type Tenant struct {
	Org int `orm:"column(org)"` // org为tenant标记
}

Tenant 多租户

type TenantPk

type TenantPk struct {
	Pk
	Tenant
}

TenantPk 不可与 Pk 同时使用

type TokenValidatorBuilder

type TokenValidatorBuilder func(injectFunc TokenValidatorInjectFunc)

type TokenValidatorInjectFunc

type TokenValidatorInjectFunc func(storage token.Storage)

Directories

Path Synopsis
alg
application
api
contrib
midware
web

Jump to

Keyboard shortcuts

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