Skip to content

Commit

Permalink
chore: tweak initialize process
Browse files Browse the repository at this point in the history
  • Loading branch information
Candinya committed Mar 25, 2024
1 parent 3539d2b commit c9d174c
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions internal/service/gateway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ func (s *Server) Run(ctx context.Context) error {

// Run echo server.
errorPool.Go(func(ctx context.Context) error {
// Prepare JWT
jwtClient, err := jwt.New(s.config.API.JWTKey)
if err != nil {
return fmt.Errorf("prepare JWT: %w", err)
}

// Prepare SIWE
siweClient, err := siwe.New(s.config.API.SIWEDomain, s.redis)
if err != nil {
return fmt.Errorf("prepare SIWE: %w", err)
}

// Connect to kafka for access logs
kafkaClient, err := accesslog.NewConsumer(
s.config.Kafka.Brokers,
Expand All @@ -62,14 +50,24 @@ func (s *Server) Run(ctx context.Context) error {
}

// Prepare processors
processorApp, err := processors.NewApp(s.controlClient, s.databaseClient.Raw())
if err != nil {
if processorApp, err := processors.NewApp(s.controlClient, s.databaseClient.Raw()); err != nil {
return fmt.Errorf("prepare processors: %w", err)
} else if err = kafkaClient.Start(processorApp.ProcessAccessLog); err != nil {
return fmt.Errorf("start kafka client: %w", err)
}

err = kafkaClient.Start(processorApp.ProcessAccessLog)
zap.L().Debug("processors started")

// Prepare JWT
jwtClient, err := jwt.New(s.config.API.JWTKey)
if err != nil {
return fmt.Errorf("start kafka: %w", err)
return fmt.Errorf("prepare JWT: %w", err)
}

// Prepare SIWE
siweClient, err := siwe.New(s.config.API.SIWEDomain, s.redis)
if err != nil {
return fmt.Errorf("prepare SIWE: %w", err)
}

// Prepare handler
Expand Down

0 comments on commit c9d174c

Please sign in to comment.