Enabled pprof parser component (#83)
This commit is contained in:
parent
70bf3f1059
commit
2283e84ed6
|
@ -80,7 +80,7 @@ func main() {
|
|||
consumer := pipeline.NewConsumer(vaaConsumeFunc, repository, parserVAAAPIClient, logger)
|
||||
consumer.Start(rootCtx)
|
||||
|
||||
server := infraestructure.NewServer(logger, config.Port, config.IsQueueConsumer(), sqsConsumer, db.Database)
|
||||
server := infraestructure.NewServer(logger, config.Port, config.PprofEnabled, config.IsQueueConsumer(), sqsConsumer, db.Database)
|
||||
server.Start()
|
||||
|
||||
logger.Info("Started wormhole-explorer-parser")
|
||||
|
|
|
@ -22,6 +22,7 @@ type Configuration struct {
|
|||
SQSUrl string `env:"SQS_URL"`
|
||||
VaaPayloadParserURL string `env:"VAA_PAYLOAD_PARSER_URL, required"`
|
||||
VaaPayloadParserTimeout int64 `env:"VAA_PAYLOAD_PARSER_TIMEOUT, required"`
|
||||
PprofEnabled bool `env:"PPROF_ENABLED,default=true"`
|
||||
}
|
||||
|
||||
// New creates a configuration with the values from .env file and environment variables.
|
||||
|
|
|
@ -3,6 +3,7 @@ package infraestructure
|
|||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
fiberLog "github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/gofiber/fiber/v2/middleware/pprof"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/parser/internal/sqs"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.uber.org/zap"
|
||||
|
@ -14,17 +15,24 @@ type Server struct {
|
|||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewServer(logger *zap.Logger, port string, isQueueConsumer bool, consumer *sqs.Consumer, db *mongo.Database) *Server {
|
||||
func NewServer(logger *zap.Logger, port string, pprofEnabled bool, isQueueConsumer bool, consumer *sqs.Consumer, db *mongo.Database) *Server {
|
||||
repository := NewRepository(db, logger)
|
||||
service := NewService(repository, consumer, isQueueConsumer, logger)
|
||||
ctrl := NewController(service)
|
||||
app := fiber.New()
|
||||
|
||||
// config use of middlware.
|
||||
if pprofEnabled {
|
||||
app.Use(pprof.New())
|
||||
}
|
||||
app.Use(fiberLog.New(fiberLog.Config{
|
||||
Format: "level=info timestamp=${time} method=${method} path=${path} status${status} request_id=${locals:requestid}\n",
|
||||
}))
|
||||
|
||||
api := app.Group("/api")
|
||||
api.Get("/health", ctrl.HealthCheck)
|
||||
api.Get("/ready", ctrl.ReadyCheck)
|
||||
|
||||
return &Server{
|
||||
app: app,
|
||||
port: port,
|
||||
|
|
Loading…
Reference in New Issue