Skip to content

Commit

Permalink
refactor(logger): Factorizing way to fatal if err
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Dec 26, 2023
1 parent b0e71b2 commit b229d00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
16 changes: 4 additions & 12 deletions cmd/fibr/fibr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/httputils/v4/pkg/alcotest"
"github.com/ViBiOh/httputils/v4/pkg/httputils"
"github.com/ViBiOh/httputils/v4/pkg/logger"
"github.com/ViBiOh/httputils/v4/pkg/owasp"
"github.com/ViBiOh/httputils/v4/pkg/recoverer"
"github.com/ViBiOh/httputils/v4/pkg/server"
Expand Down Expand Up @@ -52,26 +53,17 @@ func main() {
ctx := context.Background()

clients, err := newClient(ctx, config)
if err != nil {
slog.ErrorContext(ctx, "clients", "error", err)
os.Exit(1)
}
logger.FatalfOnErr(ctx, err, "clients")

defer clients.Close(ctx)

adapters, err := newAdapters(config, clients)
if err != nil {
slog.ErrorContext(ctx, "adapters", "error", err)
os.Exit(1)
}
logger.FatalfOnErr(ctx, err, "adapters")

endCtx := clients.health.EndCtx()

services, err := newServices(endCtx, config, clients, adapters)
if err != nil {
slog.ErrorContext(ctx, "services", "error", err)
os.Exit(1)
}
logger.FatalfOnErr(ctx, err, "services")

stopOnDone := Starters{services.amqpThumbnail, services.amqpExif, services.sanitizer}
stopOnDone.Start(clients.health.DoneCtx())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/ViBiOh/auth/v2 v2.17.0
github.com/ViBiOh/exas v0.7.1
github.com/ViBiOh/flags v1.5.0
github.com/ViBiOh/httputils/v4 v4.70.0
github.com/ViBiOh/httputils/v4 v4.70.1
github.com/ViBiOh/vith v0.6.0
github.com/rabbitmq/amqp091-go v1.9.0
github.com/redis/go-redis/v9 v9.3.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/ViBiOh/exas v0.7.1 h1:nzh6E1668OFRgoTIJZJa1RybCW64Gd918qi0Z+0Q4WA=
github.com/ViBiOh/exas v0.7.1/go.mod h1:MvIWQZXpWgg45Vsde9bMV48Kb0J8frya8vimmrkQ04E=
github.com/ViBiOh/flags v1.5.0 h1:nwuFS8tAwtV6rTPpv2pCB+r12WjZYLjluW7yT+SeVpQ=
github.com/ViBiOh/flags v1.5.0/go.mod h1:39UMuTnKsIp6walgD8dK99KRCb4DJt9vPtbWehHh1T0=
github.com/ViBiOh/httputils/v4 v4.70.0 h1:w6du+u9499p6xsMheeOoBjlBbrk4nv2Sv15PlQ5QY34=
github.com/ViBiOh/httputils/v4 v4.70.0/go.mod h1:eyQeplQJxuXuxSGnGRr/NwVgu89QI8GUH8Pzl4Gki0A=
github.com/ViBiOh/httputils/v4 v4.70.1 h1:Vz0+24CBkjT8HVreX46txu8rbd/2f7ROximutdL0WJM=
github.com/ViBiOh/httputils/v4 v4.70.1/go.mod h1:cyn0nVJoDaHtY1PiiWcNU6rUeN2zxojf4pwQ4sClrjM=
github.com/ViBiOh/vith v0.6.0 h1:bdLmwgqUEWi3ivShtAhtM9gOZlWQzvZi2Z5b0BRSB1U=
github.com/ViBiOh/vith v0.6.0/go.mod h1:eRqtDU2uB8g85vll4spbnCV93DHyHNAYwXCMIBH1GuQ=
github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w=
Expand Down

0 comments on commit b229d00

Please sign in to comment.