Fix import path.

This commit is contained in:
Vladimir Mihailenco 2014-06-18 16:47:21 +03:00
parent deb41df992
commit 5ea8ad46d6
4 changed files with 33 additions and 40 deletions

View File

@ -4,13 +4,12 @@ services:
- redis-server - redis-server
go: go:
- 1.0
- 1.1 - 1.1
- 1.2 - 1.2
- tip - tip
install: install:
- go get github.com/vmihailenco/bufio - go get gopkg.in/bufio.v1
- go get github.com/golang/glog - go get github.com/golang/glog
- go get launchpad.net/gocheck - go get launchpad.net/gocheck
- go get gopkg.in/redis.v1 - go get gopkg.in/redis.v1

View File

@ -5,6 +5,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"gopkg.in/bufio.v1"
) )
var ( var (
@ -25,7 +27,7 @@ var (
type Cmder interface { type Cmder interface {
args() []string args() []string
parseReply(reader) error parseReply(*bufio.Reader) error
setErr(error) setErr(error)
writeTimeout() *time.Duration writeTimeout() *time.Duration
@ -126,7 +128,7 @@ func (cmd *Cmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *Cmd) parseReply(rd reader) error { func (cmd *Cmd) parseReply(rd *bufio.Reader) error {
cmd.val, cmd.err = parseReply(rd, parseSlice) cmd.val, cmd.err = parseReply(rd, parseSlice)
return cmd.err return cmd.err
} }
@ -157,7 +159,7 @@ func (cmd *SliceCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *SliceCmd) parseReply(rd reader) error { func (cmd *SliceCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, parseSlice) v, err := parseReply(rd, parseSlice)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -193,7 +195,7 @@ func (cmd *StatusCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *StatusCmd) parseReply(rd reader) error { func (cmd *StatusCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, nil) v, err := parseReply(rd, nil)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -229,7 +231,7 @@ func (cmd *IntCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *IntCmd) parseReply(rd reader) error { func (cmd *IntCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, nil) v, err := parseReply(rd, nil)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -267,7 +269,7 @@ func (cmd *DurationCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *DurationCmd) parseReply(rd reader) error { func (cmd *DurationCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, nil) v, err := parseReply(rd, nil)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -303,7 +305,7 @@ func (cmd *BoolCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *BoolCmd) parseReply(rd reader) error { func (cmd *BoolCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, nil) v, err := parseReply(rd, nil)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -339,7 +341,7 @@ func (cmd *StringCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *StringCmd) parseReply(rd reader) error { func (cmd *StringCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, nil) v, err := parseReply(rd, nil)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -371,7 +373,7 @@ func (cmd *FloatCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *FloatCmd) parseReply(rd reader) error { func (cmd *FloatCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, nil) v, err := parseReply(rd, nil)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -407,7 +409,7 @@ func (cmd *StringSliceCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *StringSliceCmd) parseReply(rd reader) error { func (cmd *StringSliceCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, parseStringSlice) v, err := parseReply(rd, parseStringSlice)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -443,7 +445,7 @@ func (cmd *BoolSliceCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *BoolSliceCmd) parseReply(rd reader) error { func (cmd *BoolSliceCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, parseBoolSlice) v, err := parseReply(rd, parseBoolSlice)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -479,7 +481,7 @@ func (cmd *StringStringMapCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *StringStringMapCmd) parseReply(rd reader) error { func (cmd *StringStringMapCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, parseStringStringMap) v, err := parseReply(rd, parseStringStringMap)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -515,7 +517,7 @@ func (cmd *StringFloatMapCmd) String() string {
return cmdString(cmd, cmd.val) return cmdString(cmd, cmd.val)
} }
func (cmd *StringFloatMapCmd) parseReply(rd reader) error { func (cmd *StringFloatMapCmd) parseReply(rd *bufio.Reader) error {
v, err := parseReply(rd, parseStringFloatMap) v, err := parseReply(rd, parseStringFloatMap)
if err != nil { if err != nil {
cmd.err = err cmd.err = err
@ -552,7 +554,7 @@ func (cmd *ScanCmd) String() string {
return cmdString(cmd, cmd.keys) return cmdString(cmd, cmd.keys)
} }
func (cmd *ScanCmd) parseReply(rd reader) error { func (cmd *ScanCmd) parseReply(rd *bufio.Reader) error {
vi, err := parseReply(rd, parseSlice) vi, err := parseReply(rd, parseSlice)
if err != nil { if err != nil {
cmd.err = err cmd.err = err

View File

@ -5,10 +5,10 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"github.com/vmihailenco/bufio" "gopkg.in/bufio.v1"
) )
type multiBulkParser func(rd reader, n int64) (interface{}, error) type multiBulkParser func(rd *bufio.Reader, n int64) (interface{}, error)
var ( var (
errReaderTooSmall = errors.New("redis: reader is too small") errReaderTooSmall = errors.New("redis: reader is too small")
@ -33,15 +33,7 @@ func appendCmd(buf []byte, args []string) []byte {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
type reader interface { func readLine(rd *bufio.Reader) ([]byte, error) {
ReadLine() ([]byte, bool, error)
Read([]byte) (int, error)
ReadN(n int) ([]byte, error)
Buffered() int
Peek(int) ([]byte, error)
}
func readLine(rd reader) ([]byte, error) {
line, isPrefix, err := rd.ReadLine() line, isPrefix, err := rd.ReadLine()
if err != nil { if err != nil {
return line, err return line, err
@ -52,12 +44,12 @@ func readLine(rd reader) ([]byte, error) {
return line, nil return line, nil
} }
func readN(rd reader, n int) ([]byte, error) { func readN(rd *bufio.Reader, n int) ([]byte, error) {
b, err := rd.ReadN(n) b, err := rd.ReadN(n)
if err == bufio.ErrBufferFull { if err == bufio.ErrBufferFull {
newB := make([]byte, n) tmp := make([]byte, n)
r := copy(newB, b) r := copy(tmp, b)
b = newB b = tmp
for { for {
nn, err := rd.Read(b[r:]) nn, err := rd.Read(b[r:])
@ -78,7 +70,7 @@ func readN(rd reader, n int) ([]byte, error) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
func parseReq(rd reader) ([]string, error) { func parseReq(rd *bufio.Reader) ([]string, error) {
line, err := readLine(rd) line, err := readLine(rd)
if err != nil { if err != nil {
return nil, err return nil, err
@ -118,7 +110,7 @@ func parseReq(rd reader) ([]string, error) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
func parseReply(rd reader, p multiBulkParser) (interface{}, error) { func parseReply(rd *bufio.Reader, p multiBulkParser) (interface{}, error) {
line, err := readLine(rd) line, err := readLine(rd)
if err != nil { if err != nil {
return nil, err return nil, err
@ -166,7 +158,7 @@ func parseReply(rd reader, p multiBulkParser) (interface{}, error) {
return nil, fmt.Errorf("redis: can't parse %q", line) return nil, fmt.Errorf("redis: can't parse %q", line)
} }
func parseSlice(rd reader, n int64) (interface{}, error) { func parseSlice(rd *bufio.Reader, n int64) (interface{}, error) {
vals := make([]interface{}, 0, n) vals := make([]interface{}, 0, n)
for i := int64(0); i < n; i++ { for i := int64(0); i < n; i++ {
v, err := parseReply(rd, parseSlice) v, err := parseReply(rd, parseSlice)
@ -181,7 +173,7 @@ func parseSlice(rd reader, n int64) (interface{}, error) {
return vals, nil return vals, nil
} }
func parseStringSlice(rd reader, n int64) (interface{}, error) { func parseStringSlice(rd *bufio.Reader, n int64) (interface{}, error) {
vals := make([]string, 0, n) vals := make([]string, 0, n)
for i := int64(0); i < n; i++ { for i := int64(0); i < n; i++ {
vi, err := parseReply(rd, nil) vi, err := parseReply(rd, nil)
@ -197,7 +189,7 @@ func parseStringSlice(rd reader, n int64) (interface{}, error) {
return vals, nil return vals, nil
} }
func parseBoolSlice(rd reader, n int64) (interface{}, error) { func parseBoolSlice(rd *bufio.Reader, n int64) (interface{}, error) {
vals := make([]bool, 0, n) vals := make([]bool, 0, n)
for i := int64(0); i < n; i++ { for i := int64(0); i < n; i++ {
vi, err := parseReply(rd, nil) vi, err := parseReply(rd, nil)
@ -213,7 +205,7 @@ func parseBoolSlice(rd reader, n int64) (interface{}, error) {
return vals, nil return vals, nil
} }
func parseStringStringMap(rd reader, n int64) (interface{}, error) { func parseStringStringMap(rd *bufio.Reader, n int64) (interface{}, error) {
m := make(map[string]string, n/2) m := make(map[string]string, n/2)
for i := int64(0); i < n; i += 2 { for i := int64(0); i < n; i += 2 {
keyI, err := parseReply(rd, nil) keyI, err := parseReply(rd, nil)
@ -239,7 +231,7 @@ func parseStringStringMap(rd reader, n int64) (interface{}, error) {
return m, nil return m, nil
} }
func parseStringFloatMap(rd reader, n int64) (interface{}, error) { func parseStringFloatMap(rd *bufio.Reader, n int64) (interface{}, error) {
m := make(map[string]float64, n/2) m := make(map[string]float64, n/2)
for i := int64(0); i < n; i += 2 { for i := int64(0); i < n; i += 2 {
keyI, err := parseReply(rd, nil) keyI, err := parseReply(rd, nil)

View File

@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/vmihailenco/bufio" "gopkg.in/bufio.v1"
) )
var ( var (
@ -34,7 +34,7 @@ type pool interface {
type conn struct { type conn struct {
netcn net.Conn netcn net.Conn
rd reader rd *bufio.Reader
inUse bool inUse bool
usedAt time.Time usedAt time.Time