mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
update vendor/ dir to latest w/o heroku, moby
had to lock a lot of things in place
This commit is contained in:
4
vendor/github.com/garyburd/redigo/redis/conn.go
generated
vendored
4
vendor/github.com/garyburd/redigo/redis/conn.go
generated
vendored
@@ -370,6 +370,10 @@ func (c *conn) writeCommand(cmd string, args []interface{}) (err error) {
|
||||
}
|
||||
case nil:
|
||||
err = c.writeString("")
|
||||
case Argument:
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprint(&buf, arg.RedisArg())
|
||||
err = c.writeBytes(buf.Bytes())
|
||||
default:
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprint(&buf, arg)
|
||||
|
||||
14
vendor/github.com/garyburd/redigo/redis/conn_test.go
generated
vendored
14
vendor/github.com/garyburd/redigo/redis/conn_test.go
generated
vendored
@@ -46,6 +46,14 @@ func dialTestConn(r io.Reader, w io.Writer) redis.DialOption {
|
||||
})
|
||||
}
|
||||
|
||||
type durationArg struct {
|
||||
time.Duration
|
||||
}
|
||||
|
||||
func (t durationArg) RedisArg() interface{} {
|
||||
return t.Seconds()
|
||||
}
|
||||
|
||||
var writeTests = []struct {
|
||||
args []interface{}
|
||||
expected string
|
||||
@@ -82,6 +90,10 @@ var writeTests = []struct {
|
||||
[]interface{}{"SET", "key", nil},
|
||||
"*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$0\r\n\r\n",
|
||||
},
|
||||
{
|
||||
[]interface{}{"SET", "key", durationArg{time.Minute}},
|
||||
"*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$2\r\n60\r\n",
|
||||
},
|
||||
{
|
||||
[]interface{}{"ECHO", true, false},
|
||||
"*3\r\n$4\r\nECHO\r\n$1\r\n1\r\n$1\r\n0\r\n",
|
||||
@@ -447,7 +459,7 @@ var dialErrors = []struct {
|
||||
"localhost",
|
||||
"invalid redis URL scheme",
|
||||
},
|
||||
// The error message for invalid hosts is diffferent in different
|
||||
// The error message for invalid hosts is different in different
|
||||
// versions of Go, so just check that there is an error message.
|
||||
{
|
||||
"redis://weird url",
|
||||
|
||||
2
vendor/github.com/garyburd/redigo/redis/pool_test.go
generated
vendored
2
vendor/github.com/garyburd/redigo/redis/pool_test.go
generated
vendored
@@ -437,8 +437,8 @@ func startGoroutines(p *redis.Pool, cmd string, args ...interface{}) chan error
|
||||
go func() {
|
||||
c := p.Get()
|
||||
_, err := c.Do(cmd, args...)
|
||||
errs <- err
|
||||
c.Close()
|
||||
errs <- err
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
18
vendor/github.com/garyburd/redigo/redis/redis.go
generated
vendored
18
vendor/github.com/garyburd/redigo/redis/redis.go
generated
vendored
@@ -39,3 +39,21 @@ type Conn interface {
|
||||
// Receive receives a single reply from the Redis server
|
||||
Receive() (reply interface{}, err error)
|
||||
}
|
||||
|
||||
// Argument is implemented by types which want to control how their value is
|
||||
// interpreted when used as an argument to a redis command.
|
||||
type Argument interface {
|
||||
// RedisArg returns the interface that represents the value to be used
|
||||
// in redis commands.
|
||||
RedisArg() interface{}
|
||||
}
|
||||
|
||||
// Scanner is implemented by types which want to control how their value is
|
||||
// interpreted when read from redis.
|
||||
type Scanner interface {
|
||||
// RedisScan assigns a value from a redis value.
|
||||
//
|
||||
// An error should be returned if the value cannot be stored without
|
||||
// loss of information.
|
||||
RedisScan(src interface{}) error
|
||||
}
|
||||
|
||||
6
vendor/github.com/garyburd/redigo/redis/reply.go
generated
vendored
6
vendor/github.com/garyburd/redigo/redis/reply.go
generated
vendored
@@ -333,7 +333,7 @@ func StringMap(result interface{}, err error) (map[string]string, error) {
|
||||
key, okKey := values[i].([]byte)
|
||||
value, okValue := values[i+1].([]byte)
|
||||
if !okKey || !okValue {
|
||||
return nil, errors.New("redigo: ScanMap key not a bulk string value")
|
||||
return nil, errors.New("redigo: StringMap key not a bulk string value")
|
||||
}
|
||||
m[string(key)] = string(value)
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func IntMap(result interface{}, err error) (map[string]int, error) {
|
||||
for i := 0; i < len(values); i += 2 {
|
||||
key, ok := values[i].([]byte)
|
||||
if !ok {
|
||||
return nil, errors.New("redigo: ScanMap key not a bulk string value")
|
||||
return nil, errors.New("redigo: IntMap key not a bulk string value")
|
||||
}
|
||||
value, err := Int(values[i+1], nil)
|
||||
if err != nil {
|
||||
@@ -381,7 +381,7 @@ func Int64Map(result interface{}, err error) (map[string]int64, error) {
|
||||
for i := 0; i < len(values); i += 2 {
|
||||
key, ok := values[i].([]byte)
|
||||
if !ok {
|
||||
return nil, errors.New("redigo: ScanMap key not a bulk string value")
|
||||
return nil, errors.New("redigo: Int64Map key not a bulk string value")
|
||||
}
|
||||
value, err := Int64(values[i+1], nil)
|
||||
if err != nil {
|
||||
|
||||
28
vendor/github.com/garyburd/redigo/redis/scan.go
generated
vendored
28
vendor/github.com/garyburd/redigo/redis/scan.go
generated
vendored
@@ -110,6 +110,25 @@ func convertAssignInt(d reflect.Value, s int64) (err error) {
|
||||
}
|
||||
|
||||
func convertAssignValue(d reflect.Value, s interface{}) (err error) {
|
||||
if d.Kind() != reflect.Ptr {
|
||||
if d.CanAddr() {
|
||||
d2 := d.Addr()
|
||||
if d2.CanInterface() {
|
||||
if scanner, ok := d2.Interface().(Scanner); ok {
|
||||
return scanner.RedisScan(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if d.CanInterface() {
|
||||
// Already a reflect.Ptr
|
||||
if d.IsNil() {
|
||||
d.Set(reflect.New(d.Type().Elem()))
|
||||
}
|
||||
if scanner, ok := d.Interface().(Scanner); ok {
|
||||
return scanner.RedisScan(s)
|
||||
}
|
||||
}
|
||||
|
||||
switch s := s.(type) {
|
||||
case []byte:
|
||||
err = convertAssignBulkString(d, s)
|
||||
@@ -135,11 +154,15 @@ func convertAssignArray(d reflect.Value, s []interface{}) error {
|
||||
}
|
||||
|
||||
func convertAssign(d interface{}, s interface{}) (err error) {
|
||||
if scanner, ok := d.(Scanner); ok {
|
||||
return scanner.RedisScan(s)
|
||||
}
|
||||
|
||||
// Handle the most common destination types using type switches and
|
||||
// fall back to reflection for all other types.
|
||||
switch s := s.(type) {
|
||||
case nil:
|
||||
// ingore
|
||||
// ignore
|
||||
case []byte:
|
||||
switch d := d.(type) {
|
||||
case *string:
|
||||
@@ -219,6 +242,8 @@ func convertAssign(d interface{}, s interface{}) (err error) {
|
||||
|
||||
// Scan copies from src to the values pointed at by dest.
|
||||
//
|
||||
// Scan uses RedisScan if available otherwise:
|
||||
//
|
||||
// The values pointed at by dest must be an integer, float, boolean, string,
|
||||
// []byte, interface{} or slices of these types. Scan uses the standard strconv
|
||||
// package to convert bulk strings to numeric and boolean types.
|
||||
@@ -359,6 +384,7 @@ var errScanStructValue = errors.New("redigo.ScanStruct: value must be non-nil po
|
||||
//
|
||||
// Fields with the tag redis:"-" are ignored.
|
||||
//
|
||||
// Each field uses RedisScan if available otherwise:
|
||||
// Integer, float, boolean, string and []byte fields are supported. Scan uses the
|
||||
// standard strconv package to convert bulk string values to numeric and
|
||||
// boolean types.
|
||||
|
||||
58
vendor/github.com/garyburd/redigo/redis/scan_test.go
generated
vendored
58
vendor/github.com/garyburd/redigo/redis/scan_test.go
generated
vendored
@@ -19,10 +19,32 @@ import (
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/garyburd/redigo/redis"
|
||||
)
|
||||
|
||||
type durationScan struct {
|
||||
time.Duration `redis:"sd"`
|
||||
}
|
||||
|
||||
func (t *durationScan) RedisScan(src interface{}) (err error) {
|
||||
if t == nil {
|
||||
return fmt.Errorf("nil pointer")
|
||||
}
|
||||
switch src := src.(type) {
|
||||
case string:
|
||||
t.Duration, err = time.ParseDuration(src)
|
||||
case []byte:
|
||||
t.Duration, err = time.ParseDuration(string(src))
|
||||
case int64:
|
||||
t.Duration = time.Duration(src)
|
||||
default:
|
||||
err = fmt.Errorf("cannot convert from %T to %T", src, t)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
var scanConversionTests = []struct {
|
||||
src interface{}
|
||||
dest interface{}
|
||||
@@ -59,6 +81,11 @@ var scanConversionTests = []struct {
|
||||
{[]interface{}{[]byte("1"), []byte("2")}, []float64{1, 2}},
|
||||
{[]interface{}{[]byte("1")}, []byte{1}},
|
||||
{[]interface{}{[]byte("1")}, []bool{true}},
|
||||
{"1m", durationScan{Duration: time.Minute}},
|
||||
{[]byte("1m"), durationScan{Duration: time.Minute}},
|
||||
{time.Minute.Nanoseconds(), durationScan{Duration: time.Minute}},
|
||||
{[]interface{}{[]byte("1m")}, []durationScan{durationScan{Duration: time.Minute}}},
|
||||
{[]interface{}{[]byte("1m")}, []*durationScan{&durationScan{Duration: time.Minute}}},
|
||||
}
|
||||
|
||||
func TestScanConversion(t *testing.T) {
|
||||
@@ -86,6 +113,8 @@ var scanConversionErrorTests = []struct {
|
||||
{int64(-1), byte(0)},
|
||||
{[]byte("junk"), false},
|
||||
{redis.Error("blah"), false},
|
||||
{redis.Error("blah"), durationScan{Duration: time.Minute}},
|
||||
{"invalid", durationScan{Duration: time.Minute}},
|
||||
}
|
||||
|
||||
func TestScanConversionError(t *testing.T) {
|
||||
@@ -158,6 +187,8 @@ type s1 struct {
|
||||
Bt bool
|
||||
Bf bool
|
||||
s0
|
||||
Sd durationScan `redis:"sd"`
|
||||
Sdp *durationScan `redis:"sdp"`
|
||||
}
|
||||
|
||||
var scanStructTests = []struct {
|
||||
@@ -166,8 +197,31 @@ var scanStructTests = []struct {
|
||||
value interface{}
|
||||
}{
|
||||
{"basic",
|
||||
[]string{"i", "-1234", "u", "5678", "s", "hello", "p", "world", "b", "t", "Bt", "1", "Bf", "0", "X", "123", "y", "456"},
|
||||
&s1{I: -1234, U: 5678, S: "hello", P: []byte("world"), B: true, Bt: true, Bf: false, s0: s0{X: 123, Y: 456}},
|
||||
[]string{
|
||||
"i", "-1234",
|
||||
"u", "5678",
|
||||
"s", "hello",
|
||||
"p", "world",
|
||||
"b", "t",
|
||||
"Bt", "1",
|
||||
"Bf", "0",
|
||||
"X", "123",
|
||||
"y", "456",
|
||||
"sd", "1m",
|
||||
"sdp", "1m",
|
||||
},
|
||||
&s1{
|
||||
I: -1234,
|
||||
U: 5678,
|
||||
S: "hello",
|
||||
P: []byte("world"),
|
||||
B: true,
|
||||
Bt: true,
|
||||
Bf: false,
|
||||
s0: s0{X: 123, Y: 456},
|
||||
Sd: durationScan{Duration: time.Minute},
|
||||
Sdp: &durationScan{Duration: time.Minute},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
3
vendor/github.com/garyburd/redigo/redis/test_test.go
generated
vendored
3
vendor/github.com/garyburd/redigo/redis/test_test.go
generated
vendored
@@ -96,7 +96,8 @@ func (s *Server) watch(r io.Reader, ready chan error) {
|
||||
text = scn.Text()
|
||||
fmt.Fprintf(serverLog, "%s\n", text)
|
||||
if !listening {
|
||||
if strings.Contains(text, "The server is now ready to accept connections on port") {
|
||||
if strings.Contains(text, " * Ready to accept connections") ||
|
||||
strings.Contains(text, " * The server is now ready to accept connections on port") {
|
||||
listening = true
|
||||
ready <- nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user