refactor: unit testable units and cleaner dep injection
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"cloud.google.com/go/firestore"
|
||||
pbaero "github.com/flowy-live/llink/genproto/aero"
|
||||
pbpusher "github.com/flowy-live/llink/genproto/llink/pusher"
|
||||
"github.com/flowy-live/llink/internal/billing"
|
||||
"github.com/flowy-live/llink/internal/db"
|
||||
"github.com/flowy-live/llink/internal/human"
|
||||
"github.com/flowy-live/llink/internal/network"
|
||||
@@ -68,7 +67,7 @@ func main() {
|
||||
|
||||
// Initialize services
|
||||
humanSvc := human.NewService(db.Pool())
|
||||
networkSvc := network.NewService(db.Pool(), aeroSvc, billing.Noop(), nil)
|
||||
networkSvc := network.NewReader(db.Pool())
|
||||
|
||||
slog.Info("starting email notification cycle")
|
||||
if err := runNotificationCycle(ctx, firestoreClient, aeroSvc, pusherSvc, humanSvc, networkSvc); err != nil {
|
||||
@@ -84,12 +83,12 @@ func runNotificationCycle(
|
||||
aeroSvc pbaero.PrimaryClient,
|
||||
pusherSvc pbpusher.PusherServiceClient,
|
||||
humanSvc human.Service,
|
||||
networkSvc network.Service,
|
||||
networkReader network.Reader,
|
||||
) error {
|
||||
now := time.Now()
|
||||
|
||||
// Load all networks
|
||||
networks, err := networkSvc.ListAll(ctx)
|
||||
networks, err := networkReader.ListAll(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing networks: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user