Skip to content

Commit

Permalink
refactor: Better usage of fx
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioabreu committed Jan 15, 2024
1 parent 2a124a0 commit 82b1c33
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
6 changes: 3 additions & 3 deletions cmd/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/mauricioabreu/mosaic-video/internal/config"
"github.com/mauricioabreu/mosaic-video/internal/logging"
"github.com/mauricioabreu/mosaic-video/internal/player"
"github.com/mauricioabreu/mosaic-video/internal/storage"
"github.com/mauricioabreu/mosaic-video/internal/storage/s3"
"github.com/spf13/cobra"
"go.uber.org/fx"
)
Expand All @@ -22,9 +22,9 @@ func Player() *cobra.Command {
}

app := fx.New(
config.Module,
storage.Module,
fx.Provide(
config.NewConfig,
s3.NewClient,
logging.NewLogger,
player.NewHlsPlaylistHandler,
player.NewHlsPlayerHandler,
Expand Down
12 changes: 7 additions & 5 deletions cmd/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/joho/godotenv"
"github.com/mauricioabreu/mosaic-video/internal/config"
"github.com/mauricioabreu/mosaic-video/internal/logging"
"github.com/mauricioabreu/mosaic-video/internal/storage"
"github.com/mauricioabreu/mosaic-video/internal/storage/s3"
"github.com/mauricioabreu/mosaic-video/internal/uploader"
"github.com/spf13/cobra"
"go.uber.org/fx"
Expand All @@ -22,10 +22,12 @@ func Store() *cobra.Command {
}

app := fx.New(
config.Module,
fx.Provide(logging.NewLogger),
uploader.Module,
storage.Module,
fx.Provide(
config.NewConfig,
logging.NewLogger,
uploader.NewHandler,
s3.NewClient,
),
fx.Invoke(uploader.Run),
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func Work() *cobra.Command {
}

app := fx.New(
config.Module,
fx.Provide(
config.NewConfig,
logging.NewLogger,
locking.NewRedisLocker,
),
Expand Down
5 changes: 0 additions & 5 deletions internal/config/module.go

This file was deleted.

8 changes: 0 additions & 8 deletions internal/storage/module.go

This file was deleted.

0 comments on commit 82b1c33

Please sign in to comment.