33 lines
439 B
Go
33 lines
439 B
Go
package redis
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/go-redis/redis"
|
|
"time"
|
|
)
|
|
|
|
func RedisPullStart(parse chan<- *string, client *redis.Client) {
|
|
|
|
pong, err := client.Ping().Result()
|
|
|
|
if err != nil {
|
|
panic("redis连接失败")
|
|
}
|
|
|
|
fmt.Println(pong, err)
|
|
|
|
for {
|
|
|
|
vals, err := client.BLPop(0, "filebeat").Result()
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
time.Sleep(time.Second * 10)
|
|
}
|
|
|
|
if len(vals) == 2 {
|
|
parse <- &vals[1]
|
|
}
|
|
}
|
|
}
|