From 7f893296b024458d9726961ed854f225e9618bcd Mon Sep 17 00:00:00 2001 From: Douglas-Lee Date: Mon, 14 Oct 2024 23:53:27 +0800 Subject: [PATCH] perf: add MCache --- app/app.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/app/app.go b/app/app.go index 5b27638..2a5f602 100644 --- a/app/app.go +++ b/app/app.go @@ -99,19 +99,13 @@ func (app *Application) initialize() error { } app.db = db - metrics, err := metrics.New(cfg.MetricsConfig) - if err != nil { - return err - } - app.metrics = metrics - // queue queue := taskqueue.NewRedisQueue(taskqueue.RedisTaskQueueOptions{ Client: client, - }, app.log, metrics) + }, app.log) app.queue = queue - app.dispatcher = dispatcher.NewDispatcher(log.Sugar(), queue, db, metrics) + app.dispatcher = dispatcher.NewDispatcher(log.Sugar(), queue, db) // worker if cfg.WorkerConfig.Enabled { @@ -120,7 +114,7 @@ func (app *Application) initialize() error { PoolConcurrency: int(cfg.WorkerConfig.Pool.Concurrency), } deliverer := deliverer.NewHTTPDeliverer(&cfg.WorkerConfig.Deliverer) - app.worker = worker.NewWorker(opts, db, deliverer, queue, app.metrics) + app.worker = worker.NewWorker(opts, db, deliverer, queue) } // admin @@ -131,7 +125,7 @@ func (app *Application) initialize() error { // gateway if cfg.ProxyConfig.IsEnabled() { - app.gateway = proxy.NewGateway(&cfg.ProxyConfig, db, app.dispatcher, app.metrics) + app.gateway = proxy.NewGateway(&cfg.ProxyConfig, db, app.dispatcher) } return nil @@ -153,7 +147,6 @@ func (app *Application) Start() error { if err := app.bus.Start(); err != nil { return err } - if app.admin != nil { app.admin.Start() } @@ -188,6 +181,7 @@ func (app *Application) Stop() error { app.log.Infof("stopped") }() + app.bus.Stop() // TODO: timeout if app.admin != nil { app.admin.Stop() @@ -199,10 +193,6 @@ func (app *Application) Stop() error { app.worker.Stop() } - if app.metrics != nil { - app.metrics.Stop() - } - app.started = false app.stop <- struct{}{}