diff --git a/core/pkg/service/sync/handler.go b/core/pkg/service/sync/handler.go index 2e2ceb33c..3ab2fb457 100644 --- a/core/pkg/service/sync/handler.go +++ b/core/pkg/service/sync/handler.go @@ -12,7 +12,7 @@ import ( type handler struct { rpc.UnimplementedFlagSyncServiceServer - syncStore *syncStore.SyncStore + syncStore syncStore.ISyncStore logger *logger.Logger } diff --git a/core/pkg/service/sync/server.go b/core/pkg/service/sync/server.go index dea29ac36..80a0195e6 100644 --- a/core/pkg/service/sync/server.go +++ b/core/pkg/service/sync/server.go @@ -25,12 +25,11 @@ type Server struct { config iservice.Configuration } -func NewServer(ctx context.Context, logger *logger.Logger) *Server { - syncStore := syncStore.NewSyncStore(ctx, logger) +func NewServer(logger *logger.Logger, store syncStore.ISyncStore) *Server { return &Server{ handler: &handler{ logger: logger, - syncStore: syncStore, + syncStore: store, }, Logger: logger, } diff --git a/core/pkg/sync-store/interface.go b/core/pkg/sync-store/interface.go new file mode 100644 index 000000000..3e5a71977 --- /dev/null +++ b/core/pkg/sync-store/interface.go @@ -0,0 +1,26 @@ +package store + +import ( + "context" + + isync "github.com/open-feature/flagd/core/pkg/sync" +) + +// ISyncStore defines the interface for the sync store +type ISyncStore interface { + FetchAllFlags( + ctx context.Context, + key interface{}, + target string, + ) (isync.DataSync, error) + RegisterSubscription( + ctx context.Context, + target string, + key interface{}, + dataSync chan isync.DataSync, + errChan chan error, + ) + + // metrics hooks + GetActiveSubscriptionsInt64() int64 +} diff --git a/flagd-proxy/cmd/start.go b/flagd-proxy/cmd/start.go index b7df5b241..a145f0fbf 100644 --- a/flagd-proxy/cmd/start.go +++ b/flagd-proxy/cmd/start.go @@ -13,6 +13,7 @@ import ( "github.com/open-feature/flagd/core/pkg/logger" "github.com/open-feature/flagd/core/pkg/service" syncServer "github.com/open-feature/flagd/core/pkg/service/sync" + syncStore "github.com/open-feature/flagd/core/pkg/sync-store" "github.com/spf13/cobra" "github.com/spf13/viper" "go.uber.org/zap/zapcore" @@ -61,7 +62,8 @@ var startCmd = &cobra.Command{ ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - s := syncServer.NewServer(ctx, logger) + syncStore := syncStore.NewSyncStore(ctx, logger) + s := syncServer.NewServer(logger, syncStore) cfg := service.Configuration{ ReadinessProbe: func() bool { return true }, Port: viper.GetUint16(portFlagName),