app

package
v0.0.0-...-db9179b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: BSD-3-Clause Imports: 34 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RpcDial

func RpcDial(serverName string) (*grpc.ClientConn, error)

func RunMustHttpServer

func RunMustHttpServer(app *App, register func(e *gin.Engine, a *Options))

func RunMustRpcServer

func RunMustRpcServer(app *App, register func(server *grpc.Server, app *Options))

Types

type App

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

func New

func New(opts ...Option) *App

func (*App) Run

func (a *App) Run() error

Run run server 1.注册服务 2.退出相关组件或服务

func (*App) Stop

func (a *App) Stop() error

Stop 手动停止服务

type Option

type Option func(o *Options)

func WithAfterStart

func WithAfterStart(fn func(context.Context) error) Option

WithAfterStart run funcs after app starts

func WithAfterStop

func WithAfterStop(fn func(context.Context) error) Option

WithAfterStop run funcs after app stops

func WithAppId

func WithAppId(id string) Option

func WithBeforeStart

func WithBeforeStart(fn func(context.Context) error) Option

WithBeforeStart run funcs before app starts

func WithBeforeStop

func WithBeforeStop(fn func(context.Context) error) Option

WithBeforeStop run funcs before app stops

func WithEndpoints

func WithEndpoints(endpoints []*url.URL) Option

func WithGinServer

func WithGinServer(router func(e *gin.Engine, a *Options)) Option

func WithGrpcServer

func WithGrpcServer(svr func(rpcServer *grpc.Server, a *Options)) Option

func WithLogger

func WithLogger() Option

func WithMustConfig

func WithMustConfig[T any](filename string, fn func(cfg *conf.ServiceConfig[T])) Option

func WithMustDB

func WithMustDB(tables ...[]string) Option

func WithMustLocalCache

func WithMustLocalCache() Option

func WithMustRedis

func WithMustRedis() Option

func WithRegistrar

func WithRegistrar(registrar registry.ServiceRegistrar) Option

func WithRegistrarTimeout

func WithRegistrarTimeout(rt time.Duration) Option

func WithSignal

func WithSignal(sigs []os.Signal) Option

type Options

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

func (Options) Conf

func (o Options) Conf() *conf.Basic

Conf 获取公共配置(eg app info、logger config、db config 、redis config)

func (Options) DB

func (o Options) DB() *gorm.DB

DB 获取数据库默认client

func (Options) DBByKey

func (o Options) DBByKey(key string) *gorm.DB

DBByKey 获取数据库client

func (Options) LocalCache

func (o Options) LocalCache() cache.Cache

LocalCache 获取本地缓存 Interface

func (Options) Redis

func (o Options) Redis() redis.UniversalClient

Redis 获取redis client

Jump to

Keyboard shortcuts

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