Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
pulak-opti committed Nov 6, 2023
1 parent 143e667 commit d8744a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ synchronization:
host: "redis.demo.svc:6379"
password: ""
database: 0
channel: "optimizely-notifications"
channel: "optimizely-sync"
notification:
enable: false
default: "redis"
2 changes: 1 addition & 1 deletion pkg/handlers/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func RedisNotificationReceiver(conf config.SyncConfig) NotificationReceiverFunc
return nil, errors.New("sdk key not found")
}

redisSyncer, err := syncer.NewRedisNotificationSyncer(&zerolog.Logger{}, conf, sdkKey)
redisSyncer, err := syncer.NewRedisSyncer(&zerolog.Logger{}, conf, sdkKey)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/optimizely/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func defaultLoader(
}

if agentConf.Synchronization.Notification.Enable {
redisSyncer, err := syncer.NewRedisNotificationSyncer(&zerolog.Logger{}, agentConf.Synchronization, sdkKey)
redisSyncer, err := syncer.NewRedisSyncer(&zerolog.Logger{}, agentConf.Synchronization, sdkKey)
if err != nil {
return nil, err
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (

const (
// PubSubDefaultChan will be used as default pubsub channel name
PubSubDefaultChan = "optimizely-notifications"
PubSubDefaultChan = "optimizely-sync"
// PubSubRedis is the name of pubsub type of Redis
PubSubRedis = "redis"
)

var (
ncCache = make(map[string]*RedisNotificationSyncer)
ncCache = make(map[string]*RedisSyncer)
mutexLock = &sync.Mutex{}
)

Expand All @@ -48,8 +48,8 @@ type Event struct {
Message interface{} `json:"message"`
}

// RedisNotificationSyncer defines Redis pubsub configuration
type RedisNotificationSyncer struct {
// RedisSyncer defines Redis pubsub configuration
type RedisSyncer struct {
ctx context.Context
Host string
Password string
Expand All @@ -59,8 +59,8 @@ type RedisNotificationSyncer struct {
sdkKey string
}

// NewRedisNotificationSyncer returns an instance of RedisNotificationSyncer
func NewRedisNotificationSyncer(logger *zerolog.Logger, conf config.SyncConfig, sdkKey string) (*RedisNotificationSyncer, error) {
// NewRedisSyncer returns an instance of RedisNotificationSyncer
func NewRedisSyncer(logger *zerolog.Logger, conf config.SyncConfig, sdkKey string) (*RedisSyncer, error) {
mutexLock.Lock()
defer mutexLock.Unlock()

Expand Down Expand Up @@ -104,7 +104,7 @@ func NewRedisNotificationSyncer(logger *zerolog.Logger, conf config.SyncConfig,
logger = &zerolog.Logger{}
}

nc := &RedisNotificationSyncer{
nc := &RedisSyncer{
ctx: context.Background(),
Host: host,
Password: password,
Expand All @@ -117,23 +117,23 @@ func NewRedisNotificationSyncer(logger *zerolog.Logger, conf config.SyncConfig,
return nc, nil
}

func (r *RedisNotificationSyncer) WithContext(ctx context.Context) *RedisNotificationSyncer {
func (r *RedisSyncer) WithContext(ctx context.Context) *RedisSyncer {
r.ctx = ctx
return r
}

// AddHandler is empty but needed to implement notification.Center interface
func (r *RedisNotificationSyncer) AddHandler(_ notification.Type, _ func(interface{})) (int, error) {
func (r *RedisSyncer) AddHandler(_ notification.Type, _ func(interface{})) (int, error) {
return 0, nil
}

// RemoveHandler is empty but needed to implement notification.Center interface
func (r *RedisNotificationSyncer) RemoveHandler(_ int, t notification.Type) error {
func (r *RedisSyncer) RemoveHandler(_ int, t notification.Type) error {
return nil
}

// Send will send the notification to the specified channel in the Redis pubsub
func (r *RedisNotificationSyncer) Send(t notification.Type, n interface{}) error {
func (r *RedisSyncer) Send(t notification.Type, n interface{}) error {
event := Event{
Type: t,
Message: n,
Expand Down

0 comments on commit d8744a2

Please sign in to comment.