Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: introduce isyncstore interface #660

Merged
merged 3 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/pkg/service/sync/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type handler struct {
rpc.UnimplementedFlagSyncServiceServer
syncStore *syncStore.SyncStore
syncStore syncStore.ISyncStore
logger *logger.Logger
}

Expand Down
5 changes: 2 additions & 3 deletions core/pkg/service/sync/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
26 changes: 26 additions & 0 deletions core/pkg/sync-store/interface.go
Original file line number Diff line number Diff line change
@@ -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 {
james-milligan marked this conversation as resolved.
Show resolved Hide resolved
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
}
4 changes: 3 additions & 1 deletion flagd-proxy/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down