app

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: BSD-3-Clause Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

Stop 手动停止服务

type Option

type Option func(o *Options)

func WithAppID

func WithAppID(id string) Option

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(s *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() Option

func WithMustLocalCache

func WithMustLocalCache() Option

func WithMustRedis

func WithMustRedis() Option

func WithRegistrar

func WithRegistrar(registrar registry.ServiceRegistrar) Option

func WithSignal

func WithSignal(sigs []os.Signal) Option

type Options

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

func (*Options) AppID

func (o *Options) AppID() string

AppID 获取应用程序启动实例ID

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() *db.DBManager

DB 获取数据库连接

func (Options) LocalCache

func (o Options) LocalCache() cache.Cache

LocalCache 获取本地缓存 Interface

func (Options) Redis

func (o Options) Redis() redis.UniversalClient

Redis 获取redis client

Directories

Path Synopsis
server

Jump to

Keyboard shortcuts

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