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 -5
View File
@@ -18,7 +18,6 @@ import (
"time"
"cloud.google.com/go/firestore"
"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"
@@ -41,8 +40,7 @@ func main() {
defer fs.Close()
humanSvc := human.NewService(db.Pool())
// billing/aero/fs unused here — we only call ListAllMemberships.
networkSvc := network.NewService(db.Pool(), nil, billing.Noop(), nil)
networkSvc := network.NewReader(db.Pool())
started := time.Now()
written, scanned, err := reconcile(ctx, fs, humanSvc, networkSvc)
@@ -61,14 +59,14 @@ func reconcile(
ctx context.Context,
fs *firestore.Client,
humanSvc human.Service,
networkSvc network.Service,
networkReader network.Reader,
) (written, scanned int, err error) {
humans, err := humanSvc.ListAll(ctx)
if err != nil {
return 0, 0, err
}
memberships, err := networkSvc.ListAllMemberships(ctx)
memberships, err := networkReader.ListAllMemberships(ctx)
if err != nil {
return 0, 0, err
}