Skip to content

[FSSDK-9632] feat: Implement notification consistency across agent nodes #399

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

Merged
merged 36 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9388b0b
start basic implementation
pulak-opti Sep 4, 2023
31de5ed
resolve conflict
pulak-opti Sep 7, 2023
16649cd
change notification.go logic
pulak-opti Sep 5, 2023
6a36c7e
modify notification handler
pulak-opti Sep 5, 2023
57a4c60
Update config
pulak-opti Sep 7, 2023
c3b8bc8
add redis pubsub struct
pulak-opti Sep 8, 2023
97dffae
update config
pulak-opti Sep 8, 2023
bfe5b7c
implement & use redis center as notification.center
pulak-opti Sep 11, 2023
6669a59
use opticlient from middleware
pulak-opti Sep 11, 2023
eeeb53b
rename notification handler name
pulak-opti Sep 12, 2023
93c7a69
update config management
pulak-opti Sep 12, 2023
a2e9f0b
update notidication sender
pulak-opti Sep 12, 2023
a973468
cleaner syncup code
pulak-opti Sep 12, 2023
23c72d2
update test
pulak-opti Sep 12, 2023
d43935a
add notification filtering
pulak-opti Sep 12, 2023
30e5c0a
fix bug
pulak-opti Sep 12, 2023
f6fad82
rename syncer struct
pulak-opti Sep 13, 2023
fe55787
not using pointers
pulak-opti Sep 13, 2023
fd63389
fix test
pulak-opti Sep 13, 2023
17e9dd8
implement data channel
pulak-opti Sep 13, 2023
7e1d356
update tests
pulak-opti Sep 14, 2023
1055851
add unit tests for default receiver
pulak-opti Sep 14, 2023
2d6e428
add unit tests for redis receiver
pulak-opti Sep 14, 2023
1a18bb1
add unit test
pulak-opti Sep 15, 2023
1a32830
add comments
pulak-opti Sep 15, 2023
e6eafa7
clean up
pulak-opti Sep 15, 2023
6c34e84
fix license header year
pulak-opti Sep 15, 2023
1dcec22
resolve conflicts
pulak-opti Oct 20, 2023
e364e21
update config
pulak-opti Oct 20, 2023
b21f103
use default response writer
pulak-opti Oct 23, 2023
0e8a997
filter on sdk keys
pulak-opti Oct 23, 2023
ce403f7
update unit test
pulak-opti Oct 23, 2023
0ec42f2
fix failing acceptance test
pulak-opti Oct 23, 2023
d42c1b4
Merge branch 'master' into pulak/fix-k8s-notifications
pulak-opti Nov 2, 2023
143e667
Merge branch 'master' into pulak/fix-k8s-notifications
pulak-opti Nov 6, 2023
d8744a2
rename
pulak-opti Nov 6, 2023
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
4 changes: 2 additions & 2 deletions cmd/optimizely/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func main() {

ctx, cancel := context.WithCancel(context.Background()) // Create default service context
sg := server.NewGroup(ctx, conf.Server) // Create a new server group to manage the individual http listeners
optlyCache := optimizely.NewCache(ctx, conf.Client, sdkMetricsRegistry)
optlyCache := optimizely.NewCache(ctx, *conf, sdkMetricsRegistry)
optlyCache.Init(conf.SDKKeys)

// goroutine to check for signals to gracefully shutdown listeners
Expand All @@ -281,7 +281,7 @@ func main() {
cancel()
}()

apiRouter := routers.NewDefaultAPIRouter(optlyCache, conf.API, agentMetricsRegistry)
apiRouter := routers.NewDefaultAPIRouter(optlyCache, *conf, agentMetricsRegistry)
adminRouter := routers.NewAdminRouter(*conf)

log.Info().Str("version", conf.Version).Msg("Starting services.")
Expand Down
14 changes: 14 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,17 @@ runtime:
## To just read the current rate, pass rate < 0.
## (For n>1 the details of sampling may change.)
mutexProfileFraction: 0

## synchronization should be enabled when multiple replicas of agent is deployed
## if notification synchronization is enabled, then the active notification event-stream API
## will get the notifications from multiple replicas
synchronization:
pubsub:
redis:
host: "redis.demo.svc:6379"
password: ""
database: 0
channel: "optimizely-sync"
notification:
enable: false
default: "redis"
43 changes: 35 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ func NewDefaultConfig() *AgentConfig {
Webhook: WebhookConfig{
Port: "8085",
},
Synchronization: SyncConfig{
Pubsub: map[string]interface{}{
"redis": map[string]interface{}{
"host": "localhost:6379",
"password": "",
"database": 0,
"channel": "optimizely-notifications",
},
},
Notification: NotificationConfig{
Enable: false,
Default: "redis",
},
},
}

return &config
Expand All @@ -139,14 +153,27 @@ type AgentConfig struct {

SDKKeys []string `yaml:"sdkKeys" json:"sdkKeys"`

Admin AdminConfig `json:"admin"`
API APIConfig `json:"api"`
Log LogConfig `json:"log"`
Tracing TracingConfig `json:"tracing"`
Client ClientConfig `json:"client"`
Runtime RuntimeConfig `json:"runtime"`
Server ServerConfig `json:"server"`
Webhook WebhookConfig `json:"webhook"`
Admin AdminConfig `json:"admin"`
API APIConfig `json:"api"`
Log LogConfig `json:"log"`
Tracing TracingConfig `json:"tracing"`
Client ClientConfig `json:"client"`
Runtime RuntimeConfig `json:"runtime"`
Server ServerConfig `json:"server"`
Webhook WebhookConfig `json:"webhook"`
Synchronization SyncConfig `json:"synchronization"`
}

// SyncConfig contains Synchronization configuration for the multiple Agent nodes
type SyncConfig struct {
Pubsub map[string]interface{} `json:"pubsub"`
Notification NotificationConfig `json:"notification"`
}

// NotificationConfig contains Notification Synchronization configuration for the multiple Agent nodes
type NotificationConfig struct {
Enable bool `json:"enable"`
Default string `json:"default"`
}

// HTTPSDisabledWarning is logged when keyfile and certfile are not provided in server configuration
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.3.0
github.com/lestrrat-go/jwx v0.9.0
github.com/optimizely/go-sdk v1.8.4-0.20230515121609-7ffed835c991
github.com/optimizely/go-sdk v1.8.4-0.20230911163718-b10e161e39b8
github.com/orcaman/concurrent-map v1.0.0
github.com/prometheus/client_golang v1.11.0
github.com/rakyll/statik v0.1.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/optimizely/go-sdk v1.8.4-0.20230515121609-7ffed835c991 h1:bRoRDKRa7EgSTCEb54qaDuU6IDegQKQumun8buDV/cY=
github.com/optimizely/go-sdk v1.8.4-0.20230515121609-7ffed835c991/go.mod h1:06VK8mwwQTEh7QzP+qivf16tXtXEpoeblqtlhfvWEgk=
github.com/optimizely/go-sdk v1.8.4-0.20230911163718-b10e161e39b8 h1:1LhZsu7IB7LR3PzwIzfP56cdOkUAKRXxW1wljd352sg=
github.com/optimizely/go-sdk v1.8.4-0.20230911163718-b10e161e39b8/go.mod h1:zITWqffjOXsae/Z0PlCN5kgJRgJF/0g/k8RBEsxNrxg=
github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HDbW65HOY=
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
Expand Down
Loading