fix #15
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Selly-Modules/natsio v0.0.0-20220321031929-3fe4271f1bbc
|
github.com/Selly-Modules/natsio v0.0.0-20220321031929-3fe4271f1bbc
|
||||||
github.com/Selly-Modules/redisdb v1.0.1-0.20220325073544-1ab40b99b8b9
|
github.com/Selly-Modules/redisdb v1.0.1-0.20220325075428-59ae8ffc4812
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -6,6 +6,8 @@ github.com/Selly-Modules/redisdb v1.0.1-0.20220325035325-562d8c6f642c h1:GP+wjV8
|
||||||
github.com/Selly-Modules/redisdb v1.0.1-0.20220325035325-562d8c6f642c/go.mod h1:J2GWyoHN5b8RfZXUJmGnEFw7Z4UIogUM4Ry76DstktQ=
|
github.com/Selly-Modules/redisdb v1.0.1-0.20220325035325-562d8c6f642c/go.mod h1:J2GWyoHN5b8RfZXUJmGnEFw7Z4UIogUM4Ry76DstktQ=
|
||||||
github.com/Selly-Modules/redisdb v1.0.1-0.20220325073544-1ab40b99b8b9 h1:TTI8SL4lPHRhxqHi0OGC2uFJCrNq9/l47pkZmtjAj5I=
|
github.com/Selly-Modules/redisdb v1.0.1-0.20220325073544-1ab40b99b8b9 h1:TTI8SL4lPHRhxqHi0OGC2uFJCrNq9/l47pkZmtjAj5I=
|
||||||
github.com/Selly-Modules/redisdb v1.0.1-0.20220325073544-1ab40b99b8b9/go.mod h1:J2GWyoHN5b8RfZXUJmGnEFw7Z4UIogUM4Ry76DstktQ=
|
github.com/Selly-Modules/redisdb v1.0.1-0.20220325073544-1ab40b99b8b9/go.mod h1:J2GWyoHN5b8RfZXUJmGnEFw7Z4UIogUM4Ry76DstktQ=
|
||||||
|
github.com/Selly-Modules/redisdb v1.0.1-0.20220325075428-59ae8ffc4812 h1:Y2/O7z/nkcapWGtqVrJtK3q+aDCwp/vsPchpWTQRdY0=
|
||||||
|
github.com/Selly-Modules/redisdb v1.0.1-0.20220325075428-59ae8ffc4812/go.mod h1:J2GWyoHN5b8RfZXUJmGnEFw7Z4UIogUM4Ry76DstktQ=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
|
|
|
@ -37,15 +37,38 @@ func handleSyncDataToServiceAppier(pattern string, typeData string) {
|
||||||
fmt.Println("keyProductPattern", pattern)
|
fmt.Println("keyProductPattern", pattern)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
keys, values := redisdb.GetWithPrefixPattern(pattern, limitGetKeyRedis)
|
keys, values := redisdb.GetWithPrefixPattern(pattern)
|
||||||
if len(keys) == 0 {
|
if len(keys) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("keys:", keys)
|
processSyncToServiceAppier(typeData, values)
|
||||||
fmt.Println("values", values)
|
|
||||||
|
|
||||||
payload := toBytes(values)
|
// Del keys
|
||||||
|
for _, key := range keys {
|
||||||
|
redisdb.DelKey(context.Background(), key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// processSyncToServiceAppier ...
|
||||||
|
func processSyncToServiceAppier(typeData string, values []string) {
|
||||||
|
for {
|
||||||
|
if len(values) <= 20 {
|
||||||
|
syncDataByList(typeData, values)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = values[0:19]
|
||||||
|
syncDataByList(typeData, list)
|
||||||
|
values = values[20:]
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// syncDataByList ...
|
||||||
|
func syncDataByList(typeData string, data []string) {
|
||||||
|
payload := toBytes(data)
|
||||||
// Convert data
|
// Convert data
|
||||||
switch typeData {
|
switch typeData {
|
||||||
case RedisSyncProduct:
|
case RedisSyncProduct:
|
||||||
|
@ -67,10 +90,4 @@ func handleSyncDataToServiceAppier(pattern string, typeData string) {
|
||||||
case RedisSyncPropertyValue:
|
case RedisSyncPropertyValue:
|
||||||
Pull{}.PropertyValueUpsert(payload)
|
Pull{}.PropertyValueUpsert(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Del keys
|
|
||||||
for _, key := range keys {
|
|
||||||
redisdb.DelKey(context.Background(), key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue