Skip to content

Commit e10d929

Browse files
Implement RCM code
Signed-off-by: Niranjani Vivek <niranjaniv@google.com>
1 parent 5b93368 commit e10d929

File tree

7 files changed

+598
-25
lines changed

7 files changed

+598
-25
lines changed

translib/db/db.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ type Options struct {
168168
KeySeparator string //Overriden by the DB config file's separator.
169169
IsWriteDisabled bool //Is write/set mode disabled ?
170170
IsCacheEnabled bool //Is cache (Per Connection) allowed?
171+
// Redis connection pools do not support transactional Redis operations.
172+
// If the DB object will be used to perform transactions, the Transacation
173+
// flag must be set to request a unique Redis client. Transactions include
174+
// SCAN and MULTI.
175+
TransactionsRequired bool
171176

172177
// OnChange caching for the DBs passed from Translib's Subscribe Infra
173178
// to the Apps. SDB is the SubscribeDB() returned handle on which

translib/db/db_redis_opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func adjustRedisOpts(dbOpt *Options) *redis.Options {
144144
return &redisOpts
145145
}
146146

147-
func init() {
147+
func initializeRedisOpts() {
148148
flag.StringVar(&goRedisOpts, "go_redis_opts", "", "Options for go-redis")
149149
}
150150

translib/db/db_stats.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
"reflect"
2424
"sync"
2525
"time"
26-
27-
"github.com/go-redis/redis/v7"
2826
)
2927

3028
////////////////////////////////////////////////////////////////////////////////
@@ -524,29 +522,9 @@ func (config *DBStatsConfig) readFromDB() error {
524522

525523
func readRedis(key string) (map[string]string, error) {
526524

527-
ipAddr := DefaultRedisLocalTCPEP
528-
dbId := int(ConfigDB)
529-
dbPassword := ""
530-
if dbInstName := getDBInstName(ConfigDB); dbInstName != "" {
531-
if isDbInstPresent(dbInstName) {
532-
ipAddr = getDbTcpAddr(dbInstName)
533-
dbId = getDbId(dbInstName)
534-
dbPassword = getDbPassword(dbInstName)
535-
}
536-
}
537-
538-
client := redis.NewClient(&redis.Options{
539-
Network: "tcp",
540-
Addr: ipAddr,
541-
Password: dbPassword,
542-
DB: dbId,
543-
DialTimeout: 0,
544-
PoolSize: 1,
545-
})
525+
client := RedisClient(ConfigDB)
526+
defer CloseRedisClient(client)
546527

547528
fields, e := client.HGetAll(key).Result()
548-
549-
client.Close()
550-
551529
return fields, e
552530
}

0 commit comments

Comments
 (0)