parent
42a8154142
commit
e6e4a49f13
|
@ -2,10 +2,8 @@ package inputreader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gomodule/redigo/redis"
|
"github.com/gomodule/redigo/redis"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RedisLPOPReader is a abstraction of LPOP list
|
// RedisLPOPReader is a abstraction of LPOP list
|
||||||
|
@ -17,14 +15,12 @@ type RedisLPOPReader struct {
|
||||||
d int
|
d int
|
||||||
// D4 Queue storing
|
// D4 Queue storing
|
||||||
q string
|
q string
|
||||||
// Time in minute before retrying
|
|
||||||
retryPeriod time.Duration
|
|
||||||
// Current buffer
|
// Current buffer
|
||||||
buf []byte
|
buf []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLPOPReader creates a new RedisLPOPReader
|
// NewLPOPReader creates a new RedisLPOPReader
|
||||||
func NewLPOPReader(rc *redis.Conn, db int, queue string, rt int) (*RedisLPOPReader, error) {
|
func NewLPOPReader(rc *redis.Conn, db int, queue string) (*RedisLPOPReader, error) {
|
||||||
rr := *rc
|
rr := *rc
|
||||||
|
|
||||||
if _, err := rr.Do("SELECT", db); err != nil {
|
if _, err := rr.Do("SELECT", db); err != nil {
|
||||||
|
@ -33,10 +29,9 @@ func NewLPOPReader(rc *redis.Conn, db int, queue string, rt int) (*RedisLPOPRead
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &RedisLPOPReader{
|
r := &RedisLPOPReader{
|
||||||
r: rc,
|
r: rc,
|
||||||
d: db,
|
d: db,
|
||||||
q: queue,
|
q: queue,
|
||||||
retryPeriod: time.Duration(rt) * time.Minute,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, nil
|
return r, nil
|
||||||
|
|
Loading…
Reference in New Issue