app

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: BSD-3-Clause Imports: 37 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(configPath string, 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 WithMustDB

func WithMustDB() Option

func WithMustLocalCache

func WithMustLocalCache() Option

func WithMustRedis

func WithMustRedis() Option

func WithRegistrar

func WithRegistrar(registrar registry.ServiceRegistrar) Option

func WithScanConfig added in v0.1.1

func WithScanConfig[T any](c *T) 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 获取数据库连接 DB gorm 关系型数据库 -- 持久化

func (Options) LocalCache

func (o Options) LocalCache() cache.Cache

LocalCache 获取本地缓存 Interface CacheLocal 1.一级缓存 变动小、容量少。容量固定,有淘汰策略。 2.不适合分布式数据共享。

func (Options) Redis

func (o Options) Redis() redis.UniversalClient

Redis 获取redis client CacheDB 二级缓存 容量大,有网络IO延迟

Directories

Path Synopsis
server

Jump to

Keyboard shortcuts

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