@@ -16,13 +16,14 @@ func (r *redisProviderInitializer) ValidateConfig(cf ProviderConfig) error {
16
16
return nil
17
17
}
18
18
19
- func (r * redisProviderInitializer ) CreateProvider (cf ProviderConfig ) (Provider , error ) {
19
+ func (r * redisProviderInitializer ) CreateProvider (cf ProviderConfig , log wrapper. Log ) (Provider , error ) {
20
20
rp := redisProvider {
21
21
config : cf ,
22
22
client : wrapper .NewRedisClusterClient (wrapper.FQDNCluster {
23
23
FQDN : cf .serviceName ,
24
24
Host : cf .serviceHost ,
25
25
Port : int64 (cf .servicePort )}),
26
+ log : log ,
26
27
}
27
28
err := rp .Init (cf .username , cf .password , cf .timeout )
28
29
return & rp , err
@@ -31,14 +32,21 @@ func (r *redisProviderInitializer) CreateProvider(cf ProviderConfig) (Provider,
31
32
type redisProvider struct {
32
33
config ProviderConfig
33
34
client wrapper.RedisClient
35
+ log wrapper.Log
34
36
}
35
37
36
38
func (rp * redisProvider ) GetProviderType () string {
37
39
return PROVIDER_TYPE_REDIS
38
40
}
39
41
40
42
func (rp * redisProvider ) Init (username string , password string , timeout uint32 ) error {
41
- return rp .client .Init (rp .config .username , rp .config .password , int64 (rp .config .timeout ), wrapper .WithDataBase (rp .config .database ))
43
+ err := rp .client .Init (rp .config .username , rp .config .password , int64 (rp .config .timeout ), wrapper .WithDataBase (rp .config .database ))
44
+ if rp .client .Ready () {
45
+ rp .log .Info ("redis init successfully" )
46
+ } else {
47
+ rp .log .Error ("redis init failed, will try later" )
48
+ }
49
+ return err
42
50
}
43
51
44
52
func (rp * redisProvider ) Get (key string , cb wrapper.RedisResponseCallback ) error {
0 commit comments