Skip to content

Commit

Permalink
📦 dependency: updated codebase and upgraded deps #8 #6
Browse files Browse the repository at this point in the history
  • Loading branch information
arisnguyen215 committed Dec 9, 2023
1 parent 7bf2d10 commit efef7ea
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/go-redis/redis"
"github.com/sivaosorg/govm/logger"
"github.com/sivaosorg/govm/redisx"
"github.com/sivaosorg/redisconn/redisconn"
"github.com/sivaosorg/redisconn"
)

func main() {
Expand Down Expand Up @@ -75,7 +75,7 @@ import (
"github.com/go-redis/redis"
"github.com/sivaosorg/govm/logger"
"github.com/sivaosorg/govm/redisx"
"github.com/sivaosorg/redisconn/redisconn"
"github.com/sivaosorg/redisconn"
)

func main() {
Expand Down
13 changes: 4 additions & 9 deletions redisconn/redisconn.go → redisconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
)

var (
instance *Redis
_logger = logger.NewLogger()
_logger = logger.NewLogger()
)

func NewRedis() *Redis {
Expand Down Expand Up @@ -44,16 +43,12 @@ func (r *Redis) GetConn() *redis.Client {
}

func NewClient(config redisx.RedisConfig) (*Redis, dbx.Dbx) {
instance := NewRedis()
s := dbx.NewDbx().SetDatabase(config.Database)
if !config.IsEnabled {
s.SetConnected(false).
SetMessage("Redis unavailable").
SetError(fmt.Errorf(s.Message))
instance = NewRedis().SetState(*s)
return instance, *s
}
if instance != nil {
s.SetConnected(true).SetNewInstance(false)
instance.SetState(*s)
return instance, *s
}
Expand All @@ -66,14 +61,14 @@ func NewClient(config redisx.RedisConfig) (*Redis, dbx.Dbx) {
err := client.Ping().Err()
if err != nil {
s.SetConnected(false).SetError(err).SetMessage(err.Error())
instance = NewRedis().SetState(*s)
instance.SetState(*s)
return instance, *s
}
if config.DebugMode {
_logger.Info(fmt.Sprintf("Redis client connection:: %s", config.Json()))
_logger.Info(fmt.Sprintf("Connected successfully to redis cache:: %s/%s", config.UrlConn, config.Database))
}
s.SetConnected(true).SetMessage("Connected successfully").SetPid(os.Getpid()).SetNewInstance(true)
instance = NewRedis().SetConn(client).SetState(*s)
instance.SetConn(client).SetState(*s)
return instance, *s
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit efef7ea

Please sign in to comment.