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
@@ -12,7 +12,6 @@ import (
"github.com/flowy-live/llink/internal"
"github.com/flowy-live/llink/internal/auth"
"github.com/flowy-live/llink/internal/billing"
"github.com/flowy-live/llink/internal/db"
"github.com/flowy-live/llink/internal/network"
"github.com/flowy-live/llink/internal/pusher"
@@ -37,8 +36,8 @@ func main() {
pusherRedis := internal.ConnectAndTestRedis(db.RedisDBPusher)
// Services
authSvc := auth.NewAuthService(authRedis, nil, nil) // nil aeroSvc / fbAuth — pusher only calls GetSession
networkSvc := network.NewService(db.Pool(), nil, billing.Noop(), nil) // nil aeroSvc / noop billing / nil firestore — pusher never mutates membership
authSvc := auth.NewAuthService(authRedis, nil, nil) // nil aeroSvc / fbAuth — pusher only calls GetSession
networkReader := network.NewReader(db.Pool()) // pusher only checks membership
// Pod identity (use hostname in k8s, which is the pod name)
podID, err := os.Hostname()
@@ -52,7 +51,7 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
authorizer := pusher.NewAuthorizer(networkSvc)
authorizer := pusher.NewAuthorizer(networkReader)
hub := pusher.NewHub(bridge, authorizer)
bridge.SetHub(hub)
server := pusher.NewServer(ctx, hub, bridge, authSvc)