refactor: unit testable units and cleaner dep injection

This commit is contained in:
Arjun Patel
2026-04-27 16:07:28 -07:00
parent 013c453dd3
commit 48d6d5cb07
26 changed files with 761 additions and 617 deletions
+3 -4
View File
@@ -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)
}