summaryrefslogtreecommitdiffstats
path: root/Godeps
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-08-02 09:17:37 -0800
committerCorey Hulen <corey@hulen.com>2015-08-02 09:17:37 -0800
commit4d1562c5de377741734a0ad4e8eb30a83d301262 (patch)
tree74d1d7821b3863231c2d9429b6ccb48728661b30 /Godeps
parentadc8def9e06a7908d5f092088922dc26cbb277df (diff)
parentd93bf60248f066542d0851a7b6847f925975d77f (diff)
downloadchat-4d1562c5de377741734a0ad4e8eb30a83d301262.tar.gz
chat-4d1562c5de377741734a0ad4e8eb30a83d301262.tar.bz2
chat-4d1562c5de377741734a0ad4e8eb30a83d301262.zip
Merge pull request #273 from mattermost/mm-1355
Fixes mm-1355 adds rate limiting apis
Diffstat (limited to 'Godeps')
-rw-r--r--Godeps/Godeps.json56
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value.go142
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value_test.go60
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/string_value.go88
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/config.go101
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials.go288
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials_test.go236
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/error.go26
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/example.ini8
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handler_functions.go78
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers.go65
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers_test.go24
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator.go80
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator_test.go85
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request.go149
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request_test.go118
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/service.go142
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/types.go63
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/version.go5
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.go24
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.json67
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_map.go78
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_test.go25
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build.go30
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build_test.go1167
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go198
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal.go26
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_error.go31
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_test.go1361
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/build.go215
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/payload.go43
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/unmarshal.go174
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/build_test.go2571
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/restxml.go48
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/unmarshal_test.go1171
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/build.go262
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go251
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go100
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4.go296
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4_test.go89
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/api.go2738
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations.go20
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations_test.go20
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/examples_test.go714
-rw-r--r--Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/service.go59
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go54
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo_test.go27
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go65
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go455
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn_test.go542
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go169
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go117
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go389
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool_test.go674
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go144
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub_test.go150
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go44
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go364
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply_test.go166
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go513
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan_test.go412
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go86
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/script_test.go93
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/test_test.go38
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/zpop_example_test.go113
-rw-r--r--Godeps/_workspace/src/github.com/golang/groupcache/lru/lru.go121
-rw-r--r--Godeps/_workspace/src/github.com/golang/groupcache/lru/lru_test.go73
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/.gitignore10
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/.travis.yml10
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/LICENSE12
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/README.md80
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/common_test.go65
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/delayer.go109
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/delayer_test.go65
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/doc.go77
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/README.md12
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/custom/main.go90
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-many/main.go79
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/main.go74
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/siege-urls4
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/interval/main.go69
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/main.go97
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/test-filebin0 -> 65536 bytes
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/examples/rate-limit/main.go101
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/interval.go164
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/interval_test.go114
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/memstats.go214
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/memstats_test.go64
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/misc/pre-commit38
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/rate.go116
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/rate_test.go101
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/store.go31
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/store/doc.go2
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/store/mem.go90
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/store/mem_test.go43
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/store/redis.go85
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/store/redis_test.go66
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/throttler.go86
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/varyby.go78
-rw-r--r--Godeps/_workspace/src/github.com/throttled/throttled/varyby_test.go56
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/.travis.yml11
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/LICENSE27
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/Makefile2
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/README.md4
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/buffer.go413
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/buffer_test.go527
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/bufio.go728
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/bufio_test.go1418
-rw-r--r--Godeps/_workspace/src/gopkg.in/bufio.v1/export_test.go9
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/.travis.yml19
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/LICENSE27
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/Makefile3
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/README.md46
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/command.go597
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/commands.go1246
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/doc.go4
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/error.go23
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/example_test.go180
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/export_test.go5
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/multi.go138
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/parser.go262
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/parser_test.go54
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/pipeline.go91
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/pool.go405
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/pubsub.go134
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit.go53
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go31
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/redis.go231
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/redis_test.go3333
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/script.go52
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/sentinel.go291
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/sentinel_test.go185
-rw-r--r--Godeps/_workspace/src/gopkg.in/redis.v2/testdata/sentinel.conf6
133 files changed, 7126 insertions, 24132 deletions
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index db1468c07..aa46b11ed 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -26,41 +26,17 @@
"Rev": "f90152b7e0ae845938ce1258d90072fd116131ac"
},
{
- "ImportPath": "github.com/awslabs/aws-sdk-go/aws",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
- },
- {
- "ImportPath": "github.com/awslabs/aws-sdk-go/internal/endpoints",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
- },
- {
- "ImportPath": "github.com/awslabs/aws-sdk-go/internal/protocol/query",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
- },
- {
- "ImportPath": "github.com/awslabs/aws-sdk-go/internal/protocol/rest",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
- },
- {
- "ImportPath": "github.com/awslabs/aws-sdk-go/internal/protocol/restxml",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
- },
- {
- "ImportPath": "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
- },
- {
- "ImportPath": "github.com/awslabs/aws-sdk-go/internal/signer/v4",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
+ "ImportPath": "github.com/braintree/manners",
+ "Comment": "0.3.1-2-g5280e25",
+ "Rev": "5280e250f2795914acbeb2bf3b55dd5a2d1fba52"
},
{
- "ImportPath": "github.com/awslabs/aws-sdk-go/service/route53",
- "Rev": "44bfbd5e852715e1acfcd49da3f5688e4b5377ac"
+ "ImportPath": "github.com/garyburd/redigo/internal",
+ "Rev": "a47585eaae68b1d14b02940d2af1b9194f3caa9c"
},
{
- "ImportPath": "github.com/braintree/manners",
- "Comment": "0.3.1-2-g5280e25",
- "Rev": "5280e250f2795914acbeb2bf3b55dd5a2d1fba52"
+ "ImportPath": "github.com/garyburd/redigo/redis",
+ "Rev": "a47585eaae68b1d14b02940d2af1b9194f3caa9c"
},
{
"ImportPath": "github.com/go-gorp/gorp",
@@ -81,6 +57,10 @@
"Rev": "ad637a587dd8314770a1084481dd7b5d4fa1232f"
},
{
+ "ImportPath": "github.com/golang/groupcache/lru",
+ "Rev": "604ed5785183e59ae2789449d89e73f3a2a77987"
+ },
+ {
"ImportPath": "github.com/gorilla/context",
"Rev": "215affda49addc4c8ef7e2534915df2c8c35c6cd"
},
@@ -119,6 +99,10 @@
"Rev": "dab07ac62d4905d3e48d17dc549c684ac3b7c15a"
},
{
+ "ImportPath": "github.com/throttled/throttled",
+ "Rev": "fe4c91d601f05354c8a7feba917ab9d3b634f68d"
+ },
+ {
"ImportPath": "github.com/vaughan0/go-ini",
"Rev": "a98ad7ee00ec53921f08832bc06ecf7fd600e6a1"
},
@@ -131,19 +115,9 @@
"Rev": "eb11b45157c1b71f30b3cec66306f1cd779a689e"
},
{
- "ImportPath": "gopkg.in/bufio.v1",
- "Comment": "v1",
- "Rev": "567b2bfa514e796916c4747494d6ff5132a1dfce"
- },
- {
"ImportPath": "gopkg.in/fsnotify.v1",
"Comment": "v1.2.0",
"Rev": "96c060f6a6b7e0d6f75fddd10efeaca3e5d1bcb0"
- },
- {
- "ImportPath": "gopkg.in/redis.v2",
- "Comment": "v2.3.2",
- "Rev": "e6179049628164864e6e84e973cfb56335748dea"
}
]
}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value.go
deleted file mode 100644
index ce4c5e27a..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package awsutil
-
-import (
- "reflect"
- "regexp"
- "strconv"
- "strings"
-)
-
-var indexRe = regexp.MustCompile(`(.+)\[(-?\d+)?\]$`)
-
-func rValuesAtPath(v interface{}, path string, create bool) []reflect.Value {
- pathparts := strings.Split(path, "||")
- if len(pathparts) > 1 {
- for _, pathpart := range pathparts {
- vals := rValuesAtPath(v, pathpart, create)
- if vals != nil && len(vals) > 0 {
- return vals
- }
- }
- return nil
- }
-
- values := []reflect.Value{reflect.Indirect(reflect.ValueOf(v))}
- components := strings.Split(path, ".")
- for len(values) > 0 && len(components) > 0 {
- var index *int64
- var indexStar bool
- c := strings.TrimSpace(components[0])
- if c == "" { // no actual component, illegal syntax
- return nil
- } else if c != "*" && strings.ToLower(c[0:1]) == c[0:1] {
- // TODO normalize case for user
- return nil // don't support unexported fields
- }
-
- // parse this component
- if m := indexRe.FindStringSubmatch(c); m != nil {
- c = m[1]
- if m[2] == "" {
- index = nil
- indexStar = true
- } else {
- i, _ := strconv.ParseInt(m[2], 10, 32)
- index = &i
- indexStar = false
- }
- }
-
- nextvals := []reflect.Value{}
- for _, value := range values {
- // pull component name out of struct member
- if value.Kind() != reflect.Struct {
- continue
- }
-
- if c == "*" { // pull all members
- for i := 0; i < value.NumField(); i++ {
- if f := reflect.Indirect(value.Field(i)); f.IsValid() {
- nextvals = append(nextvals, f)
- }
- }
- continue
- }
-
- value = value.FieldByName(c)
- if create && value.Kind() == reflect.Ptr && value.IsNil() {
- value.Set(reflect.New(value.Type().Elem()))
- value = value.Elem()
- } else {
- value = reflect.Indirect(value)
- }
-
- if value.IsValid() {
- nextvals = append(nextvals, value)
- }
- }
- values = nextvals
-
- if indexStar || index != nil {
- nextvals = []reflect.Value{}
- for _, value := range values {
- value := reflect.Indirect(value)
- if value.Kind() != reflect.Slice {
- continue
- }
-
- if indexStar { // grab all indices
- for i := 0; i < value.Len(); i++ {
- idx := reflect.Indirect(value.Index(i))
- if idx.IsValid() {
- nextvals = append(nextvals, idx)
- }
- }
- continue
- }
-
- // pull out index
- i := int(*index)
- if i >= value.Len() { // check out of bounds
- if create {
- // TODO resize slice
- } else {
- continue
- }
- } else if i < 0 { // support negative indexing
- i = value.Len() + i
- }
- value = reflect.Indirect(value.Index(i))
-
- if value.IsValid() {
- nextvals = append(nextvals, value)
- }
- }
- values = nextvals
- }
-
- components = components[1:]
- }
- return values
-}
-
-// ValuesAtPath returns a list of objects at the lexical path inside of a structure
-func ValuesAtPath(i interface{}, path string) []interface{} {
- if rvals := rValuesAtPath(i, path, false); rvals != nil {
- vals := make([]interface{}, len(rvals))
- for i, rval := range rvals {
- vals[i] = rval.Interface()
- }
- return vals
- }
- return nil
-}
-
-// SetValueAtPath sets an object at the lexical path inside of a structure
-func SetValueAtPath(i interface{}, path string, v interface{}) {
- if rvals := rValuesAtPath(i, path, true); rvals != nil {
- for _, rval := range rvals {
- rval.Set(reflect.ValueOf(v))
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value_test.go
deleted file mode 100644
index 881927365..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/path_value_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package awsutil_test
-
-import (
- "testing"
-
- "github.com/awslabs/aws-sdk-go/aws/awsutil"
- "github.com/stretchr/testify/assert"
-)
-
-type Struct struct {
- A []Struct
- a []Struct
- B *Struct
- D *Struct
- C string
-}
-
-var data = Struct{
- A: []Struct{Struct{C: "value1"}, Struct{C: "value2"}, Struct{C: "value3"}},
- a: []Struct{Struct{C: "value1"}, Struct{C: "value2"}, Struct{C: "value3"}},
- B: &Struct{B: &Struct{C: "terminal"}, D: &Struct{C: "terminal2"}},
- C: "initial",
-}
-
-func TestValueAtPathSuccess(t *testing.T) {
- assert.Equal(t, []interface{}{"initial"}, awsutil.ValuesAtPath(data, "C"))
- assert.Equal(t, []interface{}{"value1"}, awsutil.ValuesAtPath(data, "A[0].C"))
- assert.Equal(t, []interface{}{"value2"}, awsutil.ValuesAtPath(data, "A[1].C"))
- assert.Equal(t, []interface{}{"value3"}, awsutil.ValuesAtPath(data, "A[2].C"))
- assert.Equal(t, []interface{}{"value3"}, awsutil.ValuesAtPath(data, "A[-1].C"))
- assert.Equal(t, []interface{}{"value1", "value2", "value3"}, awsutil.ValuesAtPath(data, "A[].C"))
- assert.Equal(t, []interface{}{"terminal"}, awsutil.ValuesAtPath(data, "B . B . C"))
- assert.Equal(t, []interface{}{"terminal", "terminal2"}, awsutil.ValuesAtPath(data, "B.*.C"))
- assert.Equal(t, []interface{}{"initial"}, awsutil.ValuesAtPath(data, "A.D.X || C"))
-}
-
-func TestValueAtPathFailure(t *testing.T) {
- assert.Equal(t, []interface{}(nil), awsutil.ValuesAtPath(data, "C.x"))
- assert.Equal(t, []interface{}(nil), awsutil.ValuesAtPath(data, ".x"))
- assert.Equal(t, []interface{}{}, awsutil.ValuesAtPath(data, "X.Y.Z"))
- assert.Equal(t, []interface{}{}, awsutil.ValuesAtPath(data, "A[100].C"))
- assert.Equal(t, []interface{}{}, awsutil.ValuesAtPath(data, "A[3].C"))
- assert.Equal(t, []interface{}{}, awsutil.ValuesAtPath(data, "B.B.C.Z"))
- assert.Equal(t, []interface{}(nil), awsutil.ValuesAtPath(data, "a[-1].C"))
- assert.Equal(t, []interface{}{}, awsutil.ValuesAtPath(nil, "A.B.C"))
-}
-
-func TestSetValueAtPathSuccess(t *testing.T) {
- var s Struct
- awsutil.SetValueAtPath(&s, "C", "test1")
- awsutil.SetValueAtPath(&s, "B.B.C", "test2")
- awsutil.SetValueAtPath(&s, "B.D.C", "test3")
- assert.Equal(t, "test1", s.C)
- assert.Equal(t, "test2", s.B.B.C)
- assert.Equal(t, "test3", s.B.D.C)
-
- awsutil.SetValueAtPath(&s, "B.*.C", "test0")
- assert.Equal(t, "test0", s.B.B.C)
- assert.Equal(t, "test0", s.B.D.C)
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/string_value.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/string_value.go
deleted file mode 100644
index 2e90f8da4..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/awsutil/string_value.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package awsutil
-
-import (
- "bytes"
- "fmt"
- "reflect"
- "strings"
-)
-
-func StringValue(i interface{}) string {
- var buf bytes.Buffer
- stringValue(reflect.ValueOf(i), 0, &buf)
- return buf.String()
-}
-
-func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) {
- for v.Kind() == reflect.Ptr {
- v = v.Elem()
- }
-
- switch v.Kind() {
- case reflect.Struct:
- buf.WriteString("{\n")
-
- names := []string{}
- for i := 0; i < v.Type().NumField(); i++ {
- name := v.Type().Field(i).Name
- f := v.Field(i)
- if name[0:1] == strings.ToLower(name[0:1]) {
- continue // ignore unexported fields
- }
- if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() {
- continue // ignore unset fields
- }
- names = append(names, name)
- }
-
- for i, n := range names {
- val := v.FieldByName(n)
- buf.WriteString(strings.Repeat(" ", indent+2))
- buf.WriteString(n + ": ")
- stringValue(val, indent+2, buf)
-
- if i < len(names)-1 {
- buf.WriteString(",\n")
- }
- }
-
- buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
- case reflect.Slice:
- nl, id, id2 := "", "", ""
- if v.Len() > 3 {
- nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2)
- }
- buf.WriteString("[" + nl)
- for i := 0; i < v.Len(); i++ {
- buf.WriteString(id2)
- stringValue(v.Index(i), indent+2, buf)
-
- if i < v.Len()-1 {
- buf.WriteString("," + nl)
- }
- }
-
- buf.WriteString(nl + id + "]")
- case reflect.Map:
- buf.WriteString("{\n")
-
- for i, k := range v.MapKeys() {
- buf.WriteString(strings.Repeat(" ", indent+2))
- buf.WriteString(k.String() + ": ")
- stringValue(v.MapIndex(k), indent+2, buf)
-
- if i < v.Len()-1 {
- buf.WriteString(",\n")
- }
- }
-
- buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
- default:
- format := "%v"
- switch v.Interface().(type) {
- case string:
- format = "%q"
- }
- fmt.Fprintf(buf, format, v.Interface())
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/config.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/config.go
deleted file mode 100644
index 6cc6da42e..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/config.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package aws
-
-import (
- "io"
- "net/http"
- "os"
-)
-
-const DEFAULT_RETRIES = -1
-
-var DefaultConfig = &Config{
- Credentials: DefaultCreds(),
- Endpoint: "",
- Region: os.Getenv("AWS_REGION"),
- DisableSSL: false,
- ManualSend: false,
- HTTPClient: http.DefaultClient,
- LogLevel: 0,
- Logger: os.Stdout,
- MaxRetries: DEFAULT_RETRIES,
- DisableParamValidation: false,
-}
-
-type Config struct {
- Credentials CredentialsProvider
- Endpoint string
- Region string
- DisableSSL bool
- ManualSend bool
- HTTPClient *http.Client
- LogLevel uint
- Logger io.Writer
- MaxRetries int
- DisableParamValidation bool
-}
-
-func (c Config) Merge(newcfg *Config) *Config {
- cfg := Config{}
-
- if newcfg != nil && newcfg.Credentials != nil {
- cfg.Credentials = newcfg.Credentials
- } else {
- cfg.Credentials = c.Credentials
- }
-
- if newcfg != nil && newcfg.Endpoint != "" {
- cfg.Endpoint = newcfg.Endpoint
- } else {
- cfg.Endpoint = c.Endpoint
- }
-
- if newcfg != nil && newcfg.Region != "" {
- cfg.Region = newcfg.Region
- } else {
- cfg.Region = c.Region
- }
-
- if newcfg != nil && newcfg.DisableSSL {
- cfg.DisableSSL = newcfg.DisableSSL
- } else {
- cfg.DisableSSL = c.DisableSSL
- }
-
- if newcfg != nil && newcfg.ManualSend {
- cfg.ManualSend = newcfg.ManualSend
- } else {
- cfg.ManualSend = c.ManualSend
- }
-
- if newcfg != nil && newcfg.HTTPClient != nil {
- cfg.HTTPClient = newcfg.HTTPClient
- } else {
- cfg.HTTPClient = c.HTTPClient
- }
-
- if newcfg != nil && newcfg.LogLevel != 0 {
- cfg.LogLevel = newcfg.LogLevel
- } else {
- cfg.LogLevel = c.LogLevel
- }
-
- if newcfg != nil && newcfg.Logger != nil {
- cfg.Logger = newcfg.Logger
- } else {
- cfg.Logger = c.Logger
- }
-
- if newcfg != nil && newcfg.MaxRetries != DEFAULT_RETRIES {
- cfg.MaxRetries = newcfg.MaxRetries
- } else {
- cfg.MaxRetries = c.MaxRetries
- }
-
- if newcfg != nil && newcfg.DisableParamValidation {
- cfg.DisableParamValidation = newcfg.DisableParamValidation
- } else {
- cfg.DisableParamValidation = c.DisableParamValidation
- }
-
- return &cfg
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials.go
deleted file mode 100644
index 4490c674a..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials.go
+++ /dev/null
@@ -1,288 +0,0 @@
-package aws
-
-import (
- "bufio"
- "encoding/json"
- "errors"
- "fmt"
- "net/http"
- "os"
- "path/filepath"
- "sync"
- "time"
-
- "github.com/vaughan0/go-ini"
-)
-
-var currentTime = time.Now
-
-// Credentials are used to authenticate and authorize calls that you make to
-// AWS.
-type Credentials struct {
- AccessKeyID string
- SecretAccessKey string
- SessionToken string
-}
-
-// A CredentialsProvider is a provider of credentials.
-type CredentialsProvider interface {
- // Credentials returns a set of credentials (or an error if no credentials
- // could be provided).
- Credentials() (*Credentials, error)
-}
-
-var (
- // ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be
- // found in the process's environment.
- ErrAccessKeyIDNotFound = fmt.Errorf("AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment")
- // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key
- // can't be found in the process's environment.
- ErrSecretAccessKeyNotFound = fmt.Errorf("AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment")
-)
-
-type DefaultCredentialsProvider struct {
-}
-
-func (p *DefaultCredentialsProvider) Credentials() (*Credentials, error) {
- env, err := EnvCreds()
- if err == nil {
- return env.Credentials()
- }
-
- profile, err := ProfileCreds("", "", 10*time.Minute)
- if err == nil {
- profileCreds, err := profile.Credentials()
- if err == nil {
- return profileCreds, nil
- }
- }
-
- return IAMCreds().Credentials()
-}
-
-func DefaultCreds() CredentialsProvider {
- return &DefaultCredentialsProvider{}
-}
-
-// DetectCreds returns a CredentialsProvider based on the available information.
-//
-// If the access key ID and secret access key are provided, it returns a basic
-// provider.
-//
-// If credentials are available via environment variables, it returns an
-// environment provider.
-//
-// If a profile configuration file is available in the default location and has
-// a default profile configured, it returns a profile provider.
-//
-// Otherwise, it returns an IAM instance provider.
-func DetectCreds(accessKeyID, secretAccessKey, sessionToken string) CredentialsProvider {
- if accessKeyID != "" && secretAccessKey != "" {
- return Creds(accessKeyID, secretAccessKey, sessionToken)
- }
-
- env, err := EnvCreds()
- if err == nil {
- return env
- }
-
- profile, err := ProfileCreds("", "", 10*time.Minute)
- if err != nil {
- return IAMCreds()
- }
-
- _, err = profile.Credentials()
- if err != nil {
- return IAMCreds()
- }
-
- return profile
-}
-
-// EnvCreds returns a static provider of AWS credentials from the process's
-// environment, or an error if none are found.
-func EnvCreds() (CredentialsProvider, error) {
- id := os.Getenv("AWS_ACCESS_KEY_ID")
- if id == "" {
- id = os.Getenv("AWS_ACCESS_KEY")
- }
-
- secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
- if secret == "" {
- secret = os.Getenv("AWS_SECRET_KEY")
- }
-
- if id == "" {
- return nil, ErrAccessKeyIDNotFound
- }
-
- if secret == "" {
- return nil, ErrSecretAccessKeyNotFound
- }
-
- return Creds(id, secret, os.Getenv("AWS_SESSION_TOKEN")), nil
-}
-
-// Creds returns a static provider of credentials.
-func Creds(accessKeyID, secretAccessKey, sessionToken string) CredentialsProvider {
- return staticCredentialsProvider{
- creds: Credentials{
- AccessKeyID: accessKeyID,
- SecretAccessKey: secretAccessKey,
- SessionToken: sessionToken,
- },
- }
-}
-
-// IAMCreds returns a provider which pulls credentials from the local EC2
-// instance's IAM roles.
-func IAMCreds() CredentialsProvider {
- return &iamProvider{}
-}
-
-// ProfileCreds returns a provider which pulls credentials from the profile
-// configuration file.
-func ProfileCreds(filename, profile string, expiry time.Duration) (CredentialsProvider, error) {
- if filename == "" {
- homeDir := os.Getenv("HOME") // *nix
- if homeDir == "" { // Windows
- homeDir = os.Getenv("USERPROFILE")
- }
- if homeDir == "" {
- return nil, errors.New("User home directory not found.")
- }
-
- filename = filepath.Join(homeDir, ".aws", "credentials")
- }
-
- if profile == "" {
- profile = "default"
- }
-
- return &profileProvider{
- filename: filename,
- profile: profile,
- expiry: expiry,
- }, nil
-}
-
-type profileProvider struct {
- filename string
- profile string
- expiry time.Duration
-
- creds Credentials
- m sync.Mutex
- expiration time.Time
-}
-
-func (p *profileProvider) Credentials() (*Credentials, error) {
- p.m.Lock()
- defer p.m.Unlock()
-
- if p.expiration.After(currentTime()) {
- return &p.creds, nil
- }
-
- config, err := ini.LoadFile(p.filename)
- if err != nil {
- return nil, err
- }
- profile := config.Section(p.profile)
-
- accessKeyID, ok := profile["aws_access_key_id"]
- if !ok {
- return nil, fmt.Errorf("profile %s in %s did not contain aws_access_key_id", p.profile, p.filename)
- }
-
- secretAccessKey, ok := profile["aws_secret_access_key"]
- if !ok {
- return nil, fmt.Errorf("profile %s in %s did not contain aws_secret_access_key", p.profile, p.filename)
- }
-
- sessionToken := profile["aws_session_token"]
-
- p.creds = Credentials{
- AccessKeyID: accessKeyID,
- SecretAccessKey: secretAccessKey,
- SessionToken: sessionToken,
- }
- p.expiration = currentTime().Add(p.expiry)
-
- return &p.creds, nil
-}
-
-type iamProvider struct {
- creds Credentials
- m sync.Mutex
- expiration time.Time
-}
-
-var metadataCredentialsEndpoint = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
-
-// IAMClient is the HTTP client used to query the metadata endpoint for IAM
-// credentials.
-var IAMClient = http.Client{
- Timeout: 1 * time.Second,
-}
-
-func (p *iamProvider) Credentials() (*Credentials, error) {
- p.m.Lock()
- defer p.m.Unlock()
-
- if p.expiration.After(currentTime()) {
- return &p.creds, nil
- }
-
- var body struct {
- Expiration time.Time
- AccessKeyID string
- SecretAccessKey string
- Token string
- }
-
- resp, err := IAMClient.Get(metadataCredentialsEndpoint)
- if err != nil {
- return nil, fmt.Errorf("listing IAM credentials")
- }
- defer func() {
- _ = resp.Body.Close()
- }()
-
- // Take the first line of the body of the metadata endpoint
- s := bufio.NewScanner(resp.Body)
- if !s.Scan() {
- return nil, fmt.Errorf("unable to find default IAM credentials")
- } else if s.Err() != nil {
- return nil, fmt.Errorf("%s listing IAM credentials", s.Err())
- }
-
- resp, err = IAMClient.Get(metadataCredentialsEndpoint + s.Text())
- if err != nil {
- return nil, fmt.Errorf("getting %s IAM credentials", s.Text())
- }
- defer func() {
- _ = resp.Body.Close()
- }()
-
- if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
- return nil, fmt.Errorf("decoding %s IAM credentials", s.Text())
- }
-
- p.creds = Credentials{
- AccessKeyID: body.AccessKeyID,
- SecretAccessKey: body.SecretAccessKey,
- SessionToken: body.Token,
- }
- p.expiration = body.Expiration
-
- return &p.creds, nil
-}
-
-type staticCredentialsProvider struct {
- creds Credentials
-}
-
-func (p staticCredentialsProvider) Credentials() (*Credentials, error) {
- return &p.creds, nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials_test.go
deleted file mode 100644
index 3143cebd6..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials_test.go
+++ /dev/null
@@ -1,236 +0,0 @@
-package aws
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "os"
- "testing"
- "time"
-)
-
-func TestEnvCreds(t *testing.T) {
- os.Clearenv()
- os.Setenv("AWS_ACCESS_KEY_ID", "access")
- os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
- os.Setenv("AWS_SESSION_TOKEN", "token")
-
- prov, err := EnvCreds()
- if err != nil {
- t.Fatal(err)
- }
-
- creds, err := prov.Credentials()
- if err != nil {
- t.Fatal(err)
- }
-
- if v, want := creds.AccessKeyID, "access"; v != want {
- t.Errorf("Access key ID was %v, expected %v", v, want)
- }
-
- if v, want := creds.SecretAccessKey, "secret"; v != want {
- t.Errorf("Secret access key was %v, expected %v", v, want)
- }
-
- if v, want := creds.SessionToken, "token"; v != want {
- t.Errorf("Security token was %v, expected %v", v, want)
- }
-}
-
-func TestEnvCredsNoAccessKeyID(t *testing.T) {
- os.Clearenv()
- os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
-
- prov, err := EnvCreds()
- if err != ErrAccessKeyIDNotFound {
- t.Fatalf("ErrAccessKeyIDNotFound expected, but was %#v/%#v", prov, err)
- }
-}
-
-func TestEnvCredsNoSecretAccessKey(t *testing.T) {
- os.Clearenv()
- os.Setenv("AWS_ACCESS_KEY_ID", "access")
-
- prov, err := EnvCreds()
- if err != ErrSecretAccessKeyNotFound {
- t.Fatalf("ErrSecretAccessKeyNotFound expected, but was %#v/%#v", prov, err)
- }
-}
-
-func TestEnvCredsAlternateNames(t *testing.T) {
- os.Clearenv()
- os.Setenv("AWS_ACCESS_KEY", "access")
- os.Setenv("AWS_SECRET_KEY", "secret")
-
- prov, err := EnvCreds()
- if err != nil {
- t.Fatal(err)
- }
-
- creds, err := prov.Credentials()
- if err != nil {
- t.Fatal(err)
- }
-
- if v, want := creds.AccessKeyID, "access"; v != want {
- t.Errorf("Access key ID was %v, expected %v", v, want)
- }
-
- if v, want := creds.SecretAccessKey, "secret"; v != want {
- t.Errorf("Secret access key was %v, expected %v", v, want)
- }
-}
-
-func TestIAMCreds(t *testing.T) {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.RequestURI == "/" {
- fmt.Fprintln(w, "/creds")
- } else {
- fmt.Fprintln(w, `{
- "AccessKeyId" : "accessKey",
- "SecretAccessKey" : "secret",
- "Token" : "token",
- "Expiration" : "2014-12-16T01:51:37Z"
-}`)
- }
- }))
- defer server.Close()
-
- defer func(s string) {
- metadataCredentialsEndpoint = s
- }(metadataCredentialsEndpoint)
- metadataCredentialsEndpoint = server.URL
-
- defer func() {
- currentTime = time.Now
- }()
- currentTime = func() time.Time {
- return time.Date(2014, 12, 15, 21, 26, 0, 0, time.UTC)
- }
-
- prov := IAMCreds()
- creds, err := prov.Credentials()
- if err != nil {
- t.Fatal(err)
- }
-
- if v, want := creds.AccessKeyID, "accessKey"; v != want {
- t.Errorf("AcccessKeyID was %v, but expected %v", v, want)
- }
-
- if v, want := creds.SecretAccessKey, "secret"; v != want {
- t.Errorf("SecretAccessKey was %v, but expected %v", v, want)
- }
-
- if v, want := creds.SessionToken, "token"; v != want {
- t.Errorf("SessionToken was %v, but expected %v", v, want)
- }
-}
-
-func TestProfileCreds(t *testing.T) {
- prov, err := ProfileCreds("example.ini", "", 10*time.Minute)
- if err != nil {
- t.Fatal(err)
- }
-
- creds, err := prov.Credentials()
- if err != nil {
- t.Fatal(err)
- }
-
- if v, want := creds.AccessKeyID, "accessKey"; v != want {
- t.Errorf("AcccessKeyID was %v, but expected %v", v, want)
- }
-
- if v, want := creds.SecretAccessKey, "secret"; v != want {
- t.Errorf("SecretAccessKey was %v, but expected %v", v, want)
- }
-
- if v, want := creds.SessionToken, "token"; v != want {
- t.Errorf("SessionToken was %v, but expected %v", v, want)
- }
-}
-
-func TestProfileCredsWithoutToken(t *testing.T) {
- prov, err := ProfileCreds("example.ini", "no_token", 10*time.Minute)
- if err != nil {
- t.Fatal(err)
- }
-
- creds, err := prov.Credentials()
- if err != nil {
- t.Fatal(err)
- }
-
- if v, want := creds.AccessKeyID, "accessKey"; v != want {
- t.Errorf("AcccessKeyID was %v, but expected %v", v, want)
- }
-
- if v, want := creds.SecretAccessKey, "secret"; v != want {
- t.Errorf("SecretAccessKey was %v, but expected %v", v, want)
- }
-
- if v, want := creds.SessionToken, ""; v != want {
- t.Errorf("SessionToken was %v, but expected %v", v, want)
- }
-}
-
-func BenchmarkProfileCreds(b *testing.B) {
- prov, err := ProfileCreds("example.ini", "", 10*time.Minute)
- if err != nil {
- b.Fatal(err)
- }
-
- b.ResetTimer()
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, err := prov.Credentials()
- if err != nil {
- b.Fatal(err)
- }
- }
- })
-}
-
-func BenchmarkIAMCreds(b *testing.B) {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.RequestURI == "/" {
- fmt.Fprintln(w, "/creds")
- } else {
- fmt.Fprintln(w, `{
- "AccessKeyId" : "accessKey",
- "SecretAccessKey" : "secret",
- "Token" : "token",
- "Expiration" : "2014-12-16T01:51:37Z"
-}`)
- }
- }))
- defer server.Close()
-
- defer func(s string) {
- metadataCredentialsEndpoint = s
- }(metadataCredentialsEndpoint)
- metadataCredentialsEndpoint = server.URL
-
- defer func() {
- currentTime = time.Now
- }()
- currentTime = func() time.Time {
- return time.Date(2014, 12, 15, 21, 26, 0, 0, time.UTC)
- }
-
- b.ResetTimer()
-
- prov := IAMCreds()
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, err := prov.Credentials()
- if err != nil {
- b.Fatal(err)
- }
- }
- })
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/error.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/error.go
deleted file mode 100644
index 6b8989911..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/error.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package aws
-
-import "time"
-
-// An APIError is an error returned by an AWS API.
-type APIError struct {
- StatusCode int // HTTP status code e.g. 200
- Code string
- Message string
- RequestID string
- Retryable bool
- RetryDelay time.Duration
- RetryCount uint
-}
-
-func (e APIError) Error() string {
- return e.Message
-}
-
-func Error(e error) *APIError {
- if err, ok := e.(APIError); ok {
- return &err
- } else {
- return nil
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/example.ini b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/example.ini
deleted file mode 100644
index aa2dc506a..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/example.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[default]
-aws_access_key_id = accessKey
-aws_secret_access_key = secret
-aws_session_token = token
-
-[no_token]
-aws_access_key_id = accessKey
-aws_secret_access_key = secret
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handler_functions.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handler_functions.go
deleted file mode 100644
index 4de0f4a11..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handler_functions.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package aws
-
-import (
- "fmt"
- "io"
- "time"
-)
-
-var sleepDelay = func(delay time.Duration) {
- time.Sleep(delay)
-}
-
-type lener interface {
- Len() int
-}
-
-func BuildContentLength(r *Request) {
- if r.HTTPRequest.Header.Get("Content-Length") != "" {
- return
- }
-
- var length int64
- switch body := r.Body.(type) {
- case nil:
- length = 0
- case lener:
- length = int64(body.Len())
- case io.Seeker:
- cur, _ := body.Seek(0, 1)
- end, _ := body.Seek(0, 2)
- body.Seek(cur, 0) // make sure to seek back to original location
- length = end - cur
- default:
- panic("Cannot get length of body, must provide `ContentLength`")
- }
-
- r.HTTPRequest.ContentLength = length
- r.HTTPRequest.Header.Set("Content-Length", fmt.Sprintf("%d", length))
-}
-
-func UserAgentHandler(r *Request) {
- r.HTTPRequest.Header.Set("User-Agent", SDKName+"/"+SDKVersion)
-}
-
-func SendHandler(r *Request) {
- r.HTTPResponse, r.Error = r.Service.Config.HTTPClient.Do(r.HTTPRequest)
-}
-
-func ValidateResponseHandler(r *Request) {
- if r.HTTPResponse.StatusCode == 0 || r.HTTPResponse.StatusCode >= 400 {
- err := APIError{
- StatusCode: r.HTTPResponse.StatusCode,
- RetryCount: r.RetryCount,
- }
- r.Error = err
- err.Retryable = r.Service.ShouldRetry(r)
- err.RetryDelay = r.Service.RetryRules(r)
- r.Error = err
- }
-}
-
-func AfterRetryHandler(r *Request) {
- delay := 0 * time.Second
- willRetry := false
-
- if err := Error(r.Error); err != nil {
- delay = err.RetryDelay
- if err.Retryable && r.RetryCount < r.Service.MaxRetries() {
- r.RetryCount++
- willRetry = true
- }
- }
-
- if willRetry {
- r.Error = nil
- sleepDelay(delay)
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers.go
deleted file mode 100644
index f7c135fed..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package aws
-
-import "container/list"
-
-type Handlers struct {
- Validate HandlerList
- Build HandlerList
- Sign HandlerList
- Send HandlerList
- ValidateResponse HandlerList
- Unmarshal HandlerList
- UnmarshalMeta HandlerList
- UnmarshalError HandlerList
- Retry HandlerList
- AfterRetry HandlerList
-}
-
-func (h *Handlers) copy() Handlers {
- return Handlers{
- Validate: h.Validate.copy(),
- Build: h.Build.copy(),
- Sign: h.Sign.copy(),
- Send: h.Send.copy(),
- ValidateResponse: h.ValidateResponse.copy(),
- Unmarshal: h.Unmarshal.copy(),
- UnmarshalError: h.UnmarshalError.copy(),
- UnmarshalMeta: h.UnmarshalMeta.copy(),
- Retry: h.Retry.copy(),
- AfterRetry: h.AfterRetry.copy(),
- }
-}
-
-// Clear removes callback functions for all handlers
-func (h *Handlers) Clear() {
- h.Validate.Init()
- h.Build.Init()
- h.Send.Init()
- h.Sign.Init()
- h.Unmarshal.Init()
- h.UnmarshalMeta.Init()
- h.UnmarshalError.Init()
- h.ValidateResponse.Init()
- h.Retry.Init()
- h.AfterRetry.Init()
-}
-
-type HandlerList struct {
- list.List
-}
-
-func (l HandlerList) copy() HandlerList {
- var n HandlerList
- for e := l.Front(); e != nil; e = e.Next() {
- h := e.Value.(func(*Request))
- n.PushBack(h)
- }
- return n
-}
-
-func (l *HandlerList) Run(r *Request) {
- for e := l.Front(); e != nil; e = e.Next() {
- h := e.Value.(func(*Request))
- h(r)
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers_test.go
deleted file mode 100644
index 89e87cc49..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/handlers_test.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package aws
-
-import "testing"
-
-func TestHandlerList(t *testing.T) {
- r := &Request{}
- l := HandlerList{}
- l.PushBack(func(r *Request) { r.Data = Boolean(true) })
- l.Run(r)
- if r.Data == nil {
- t.Error("Expected handler to execute")
- }
-}
-
-func TestMultipleHandlers(t *testing.T) {
- r := &Request{}
- l := HandlerList{}
- l.PushBack(func(r *Request) { r.Data = Boolean(true) })
- l.PushBack(func(r *Request) { r.Data = nil })
- l.Run(r)
- if r.Data != nil {
- t.Error("Expected handler to execute")
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator.go
deleted file mode 100644
index e1cb5cea5..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package aws
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-func ValidateParameters(r *Request) {
- if r.ParamsFilled() {
- v := validator{errors: []string{}}
- v.validateAny(reflect.ValueOf(r.Params), "")
-
- if count := len(v.errors); count > 0 {
- format := "%d validation errors:\n- %s"
- msg := fmt.Sprintf(format, count, strings.Join(v.errors, "\n- "))
- r.Error = APIError{Code: "InvalidParameter", Message: msg}
- }
- }
-}
-
-type validator struct {
- errors []string
-}
-
-func (v *validator) validateAny(value reflect.Value, path string) {
- value = reflect.Indirect(value)
- if !value.IsValid() {
- return
- }
-
- switch value.Kind() {
- case reflect.Struct:
- v.validateStruct(value, path)
- case reflect.Slice:
- for i := 0; i < value.Len(); i++ {
- v.validateAny(value.Index(i), path+fmt.Sprintf("[%d]", i))
- }
- case reflect.Map:
- for _, n := range value.MapKeys() {
- v.validateAny(value.MapIndex(n), path+fmt.Sprintf("[%q]", n.String()))
- }
- }
-}
-
-func (v *validator) validateStruct(value reflect.Value, path string) {
- prefix := "."
- if path == "" {
- prefix = ""
- }
-
- for i := 0; i < value.Type().NumField(); i++ {
- f := value.Type().Field(i)
- if strings.ToLower(f.Name[0:1]) == f.Name[0:1] {
- continue
- }
- fvalue := value.FieldByName(f.Name)
-
- notset := false
- if f.Tag.Get("required") != "" {
- switch fvalue.Kind() {
- case reflect.Ptr, reflect.Slice:
- if fvalue.IsNil() {
- notset = true
- }
- default:
- if !fvalue.IsValid() {
- notset = true
- }
- }
- }
-
- if notset {
- msg := "missing required parameter: " + path + prefix + f.Name
- v.errors = append(v.errors, msg)
- } else {
- v.validateAny(fvalue, path+prefix+f.Name)
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator_test.go
deleted file mode 100644
index 08deca15a..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/param_validator_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package aws_test
-
-import (
- "testing"
-
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/stretchr/testify/assert"
-)
-
-var service = func() *aws.Service {
- s := &aws.Service{
- Config: &aws.Config{},
- ServiceName: "mock-service",
- APIVersion: "2015-01-01",
- }
- return s
-}()
-
-type StructShape struct {
- RequiredList []*ConditionalStructShape `required:"true"`
- RequiredMap *map[string]*ConditionalStructShape `required:"true"`
- RequiredBool *bool `required:"true"`
- OptionalStruct *ConditionalStructShape
-
- hiddenParameter *string
-
- metadataStructureShape
-}
-
-type metadataStructureShape struct {
- SDKShapeTraits bool
-}
-
-type ConditionalStructShape struct {
- Name *string `required:"true"`
- SDKShapeTraits bool
-}
-
-func TestNoErrors(t *testing.T) {
- input := &StructShape{
- RequiredList: []*ConditionalStructShape{},
- RequiredMap: &map[string]*ConditionalStructShape{
- "key1": &ConditionalStructShape{Name: aws.String("Name")},
- "key2": &ConditionalStructShape{Name: aws.String("Name")},
- },
- RequiredBool: aws.Boolean(true),
- OptionalStruct: &ConditionalStructShape{Name: aws.String("Name")},
- }
-
- req := aws.NewRequest(service, &aws.Operation{}, input, nil)
- aws.ValidateParameters(req)
- assert.NoError(t, req.Error)
-}
-
-func TestMissingRequiredParameters(t *testing.T) {
- input := &StructShape{}
- req := aws.NewRequest(service, &aws.Operation{}, input, nil)
- aws.ValidateParameters(req)
- err := aws.Error(req.Error)
-
- assert.Error(t, err)
- assert.Equal(t, "InvalidParameter", err.Code)
- assert.Equal(t, "3 validation errors:\n- missing required parameter: RequiredList\n- missing required parameter: RequiredMap\n- missing required parameter: RequiredBool", err.Message)
-}
-
-func TestNestedMissingRequiredParameters(t *testing.T) {
- input := &StructShape{
- RequiredList: []*ConditionalStructShape{&ConditionalStructShape{}},
- RequiredMap: &map[string]*ConditionalStructShape{
- "key1": &ConditionalStructShape{Name: aws.String("Name")},
- "key2": &ConditionalStructShape{},
- },
- RequiredBool: aws.Boolean(true),
- OptionalStruct: &ConditionalStructShape{},
- }
-
- req := aws.NewRequest(service, &aws.Operation{}, input, nil)
- aws.ValidateParameters(req)
- err := aws.Error(req.Error)
-
- assert.Error(t, err)
- assert.Equal(t, "InvalidParameter", err.Code)
- assert.Equal(t, "3 validation errors:\n- missing required parameter: RequiredList[0].Name\n- missing required parameter: RequiredMap[\"key2\"].Name\n- missing required parameter: OptionalStruct.Name", err.Message)
-
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request.go
deleted file mode 100644
index 1c442b1cd..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package aws
-
-import (
- "bytes"
- "io"
- "io/ioutil"
- "net/http"
- "net/url"
- "reflect"
- "time"
-)
-
-type Request struct {
- *Service
- Handlers Handlers
- Time time.Time
- ExpireTime time.Duration
- Operation *Operation
- HTTPRequest *http.Request
- HTTPResponse *http.Response
- Body io.ReadSeeker
- Params interface{}
- Error error
- Data interface{}
- RequestID string
- RetryCount uint
-
- built bool
-}
-
-type Operation struct {
- Name string
- HTTPMethod string
- HTTPPath string
-}
-
-func NewRequest(service *Service, operation *Operation, params interface{}, data interface{}) *Request {
- method := operation.HTTPMethod
- if method == "" {
- method = "POST"
- }
- p := operation.HTTPPath
- if p == "" {
- p = "/"
- }
-
- httpReq, _ := http.NewRequest(method, "", nil)
- httpReq.URL, _ = url.Parse(service.Endpoint + p)
-
- r := &Request{
- Service: service,
- Handlers: service.Handlers.copy(),
- Time: time.Now(),
- ExpireTime: 0,
- Operation: operation,
- HTTPRequest: httpReq,
- Body: nil,
- Params: params,
- Error: nil,
- Data: data,
- }
- r.SetBufferBody([]byte{})
-
- return r
-}
-
-func (r *Request) ParamsFilled() bool {
- return r.Params != nil && reflect.ValueOf(r.Params).Elem().IsValid()
-}
-
-func (r *Request) DataFilled() bool {
- return r.Data != nil && reflect.ValueOf(r.Data).Elem().IsValid()
-}
-
-func (r *Request) SetBufferBody(buf []byte) {
- r.SetReaderBody(bytes.NewReader(buf))
-}
-
-func (r *Request) SetReaderBody(reader io.ReadSeeker) {
- r.HTTPRequest.Body = ioutil.NopCloser(reader)
- r.Body = reader
-}
-
-func (r *Request) Presign(expireTime time.Duration) (string, error) {
- r.ExpireTime = expireTime
- r.Sign()
- if r.Error != nil {
- return "", r.Error
- } else {
- return r.HTTPRequest.URL.String(), nil
- }
-}
-
-func (r *Request) Build() error {
- if !r.built {
- r.Error = nil
- r.Handlers.Validate.Run(r)
- if r.Error != nil {
- return r.Error
- }
- r.Handlers.Build.Run(r)
- r.built = true
- }
-
- return r.Error
-}
-
-func (r *Request) Sign() error {
- r.Build()
- if r.Error != nil {
- return r.Error
- }
-
- r.Handlers.Sign.Run(r)
- return r.Error
-}
-
-func (r *Request) Send() error {
- r.Sign()
- if r.Error != nil {
- return r.Error
- }
-
- for {
- r.Handlers.Send.Run(r)
- if r.Error != nil {
- return r.Error
- }
-
- r.Handlers.UnmarshalMeta.Run(r)
- r.Handlers.ValidateResponse.Run(r)
- if r.Error != nil {
- r.Handlers.Retry.Run(r)
- r.Handlers.AfterRetry.Run(r)
- if r.Error != nil {
- r.Handlers.UnmarshalError.Run(r)
- return r.Error
- }
- continue
- }
-
- r.Handlers.Unmarshal.Run(r)
- if r.Error != nil {
- return r.Error
- }
-
- return nil
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request_test.go
deleted file mode 100644
index b27b55067..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/request_test.go
+++ /dev/null
@@ -1,118 +0,0 @@
-package aws
-
-import (
- "bytes"
- "encoding/json"
- "io"
- "io/ioutil"
- "net/http"
- "reflect"
- "testing"
- "time"
-
- "github.com/stretchr/testify/assert"
-)
-
-type testData struct {
- Data string
-}
-
-func body(str string) io.ReadCloser {
- return ioutil.NopCloser(bytes.NewReader([]byte(str)))
-}
-
-func unmarshal(req *Request) {
- defer req.HTTPResponse.Body.Close()
- if req.Data != nil {
- json.NewDecoder(req.HTTPResponse.Body).Decode(req.Data)
- }
- return
-}
-
-func unmarshalError(req *Request) {
- bodyBytes, err := ioutil.ReadAll(req.HTTPResponse.Body)
- if err != nil {
- req.Error = err
- return
- }
- if len(bodyBytes) == 0 {
- req.Error = APIError{
- StatusCode: req.HTTPResponse.StatusCode,
- Message: req.HTTPResponse.Status,
- }
- return
- }
- var jsonErr jsonErrorResponse
- if err := json.Unmarshal(bodyBytes, &jsonErr); err != nil {
- req.Error = err
- return
- }
- req.Error = APIError{
- StatusCode: req.HTTPResponse.StatusCode,
- Code: jsonErr.Code,
- Message: jsonErr.Message,
- }
-}
-
-type jsonErrorResponse struct {
- Code string `json:"__type"`
- Message string `json:"message"`
-}
-
-func TestRequestRecoverRetry(t *testing.T) {
- reqNum := 0
- reqs := []http.Response{
- http.Response{StatusCode: 500, Body: body(`{"__type":"UnknownError","message":"An error occurred."}`)},
- http.Response{StatusCode: 500, Body: body(`{"__type":"UnknownError","message":"An error occurred."}`)},
- http.Response{StatusCode: 200, Body: body(`{"data":"valid"}`)},
- }
-
- s := NewService(&Config{MaxRetries: -1})
- s.Handlers.Unmarshal.PushBack(unmarshal)
- s.Handlers.UnmarshalError.PushBack(unmarshalError)
- s.Handlers.Send.Init() // mock sending
- s.Handlers.Send.PushBack(func(r *Request) {
- r.HTTPResponse = &reqs[reqNum]
- reqNum++
- })
- out := &testData{}
- r := NewRequest(s, &Operation{Name: "Operation"}, nil, out)
- err := r.Send()
- assert.Nil(t, err)
- assert.Equal(t, 2, int(r.RetryCount))
- assert.Equal(t, "valid", out.Data)
-}
-
-func TestRequestExhaustRetries(t *testing.T) {
- delays := []time.Duration{}
- sleepDelay = func(delay time.Duration) {
- delays = append(delays, delay)
- }
-
- reqNum := 0
- reqs := []http.Response{
- http.Response{StatusCode: 500, Body: body(`{"__type":"UnknownError","message":"An error occurred."}`)},
- http.Response{StatusCode: 500, Body: body(`{"__type":"UnknownError","message":"An error occurred."}`)},
- http.Response{StatusCode: 500, Body: body(`{"__type":"UnknownError","message":"An error occurred."}`)},
- http.Response{StatusCode: 500, Body: body(`{"__type":"UnknownError","message":"An error occurred."}`)},
- }
-
- s := NewService(&Config{MaxRetries: -1})
- s.Handlers.Unmarshal.PushBack(unmarshal)
- s.Handlers.UnmarshalError.PushBack(unmarshalError)
- s.Handlers.Send.Init() // mock sending
- s.Handlers.Send.PushBack(func(r *Request) {
- r.HTTPResponse = &reqs[reqNum]
- reqNum++
- })
- r := NewRequest(s, &Operation{Name: "Operation"}, nil, nil)
- err := r.Send()
- apiErr := Error(err)
- assert.NotNil(t, err)
- assert.NotNil(t, apiErr)
- assert.Equal(t, 500, apiErr.StatusCode)
- assert.Equal(t, "UnknownError", apiErr.Code)
- assert.Equal(t, "An error occurred.", apiErr.Message)
- assert.Equal(t, 3, int(r.RetryCount))
- assert.True(t, reflect.DeepEqual([]time.Duration{30 * time.Millisecond, 60 * time.Millisecond, 120 * time.Millisecond}, delays))
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/service.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/service.go
deleted file mode 100644
index 95d590b91..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/service.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package aws
-
-import (
- "fmt"
- "math"
- "net/http"
- "net/http/httputil"
- "regexp"
- "time"
-
- "github.com/awslabs/aws-sdk-go/internal/endpoints"
-)
-
-type Service struct {
- Config *Config
- Handlers Handlers
- ManualSend bool
- ServiceName string
- APIVersion string
- Endpoint string
- JSONVersion string
- TargetPrefix string
- RetryRules func(*Request) time.Duration
- ShouldRetry func(*Request) bool
- DefaultMaxRetries uint
-}
-
-var schemeRE = regexp.MustCompile("^([^:]+)://")
-
-func NewService(config *Config) *Service {
- svc := &Service{Config: config}
- svc.Initialize()
- return svc
-}
-
-func (s *Service) Initialize() {
- if s.Config == nil {
- s.Config = &Config{}
- }
- if s.Config.HTTPClient == nil {
- s.Config.HTTPClient = http.DefaultClient
- }
-
- if s.RetryRules == nil {
- s.RetryRules = retryRules
- }
-
- if s.ShouldRetry == nil {
- s.ShouldRetry = shouldRetry
- }
-
- s.DefaultMaxRetries = 3
- s.Handlers.Build.PushBack(UserAgentHandler)
- s.Handlers.Sign.PushBack(BuildContentLength)
- s.Handlers.Send.PushBack(SendHandler)
- s.Handlers.AfterRetry.PushBack(AfterRetryHandler)
- s.Handlers.ValidateResponse.PushBack(ValidateResponseHandler)
- s.AddDebugHandlers()
- s.buildEndpoint()
-
- if !s.Config.DisableParamValidation {
- s.Handlers.Validate.PushBack(ValidateParameters)
- }
-}
-
-func (s *Service) buildEndpoint() {
- if s.Config.Endpoint != "" {
- s.Endpoint = s.Config.Endpoint
- } else {
- s.Endpoint = endpoints.EndpointForRegion(s.ServiceName, s.Config.Region)
- }
-
- if !schemeRE.MatchString(s.Endpoint) {
- scheme := "https"
- if s.Config.DisableSSL {
- scheme = "http"
- }
- s.Endpoint = scheme + "://" + s.Endpoint
- }
-}
-
-func (s *Service) AddDebugHandlers() {
- out := s.Config.Logger
- if s.Config.LogLevel == 0 {
- return
- }
-
- s.Handlers.Sign.PushBack(func(r *Request) {
- dumpedBody, _ := httputil.DumpRequest(r.HTTPRequest, true)
-
- fmt.Fprintf(out, "=> [%s] %s.%s(%+v)\n", r.Time,
- r.Service.ServiceName, r.Operation.Name, r.Params)
- fmt.Fprintf(out, "---[ REQUEST PRE-SIGN ]------------------------------\n")
- fmt.Fprintf(out, "%s\n", string(dumpedBody))
- fmt.Fprintf(out, "-----------------------------------------------------\n")
- })
- s.Handlers.Send.PushFront(func(r *Request) {
- dumpedBody, _ := httputil.DumpRequest(r.HTTPRequest, true)
-
- fmt.Fprintf(out, "---[ REQUEST POST-SIGN ]-----------------------------\n")
- fmt.Fprintf(out, "%s\n", string(dumpedBody))
- fmt.Fprintf(out, "-----------------------------------------------------\n")
- })
- s.Handlers.Send.PushBack(func(r *Request) {
- fmt.Fprintf(out, "---[ RESPONSE ]--------------------------------------\n")
- if r.HTTPResponse != nil {
- dumpedBody, _ := httputil.DumpResponse(r.HTTPResponse, true)
- fmt.Fprintf(out, "%s\n", string(dumpedBody))
- } else if r.Error != nil {
- fmt.Fprintf(out, "%s\n", r.Error)
- }
- fmt.Fprintf(out, "-----------------------------------------------------\n")
- })
-}
-
-func (s *Service) MaxRetries() uint {
- if s.Config.MaxRetries < 0 {
- return s.DefaultMaxRetries
- } else {
- return uint(s.Config.MaxRetries)
- }
-}
-
-func retryRules(r *Request) time.Duration {
- delay := time.Duration(math.Pow(2, float64(r.RetryCount))) * 30
- return delay * time.Millisecond
-}
-
-func shouldRetry(r *Request) bool {
- if err := Error(r.Error); err != nil {
- if err.StatusCode >= 500 {
- return true
- }
-
- switch err.Code {
- case "ExpiredTokenException":
- case "ProvisionedThroughputExceededException", "Throttling":
- return true
- }
- }
- return false
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/types.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/types.go
deleted file mode 100644
index 5da09114c..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/types.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package aws
-
-import (
- "io"
- "time"
-)
-
-// String converts a Go string into a string pointer.
-func String(v string) *string {
- return &v
-}
-
-// Boolean converts a Go bool into a boolean pointer.
-func Boolean(v bool) *bool {
- return &v
-}
-
-// Long converts a Go int64 into a long pointer.
-func Long(v int64) *int64 {
- return &v
-}
-
-// Double converts a Go float64 into a double pointer.
-func Double(v float64) *float64 {
- return &v
-}
-
-// Time converts a Go Time into a Time pointer
-func Time(t time.Time) *time.Time {
- return &t
-}
-
-func ReadSeekCloser(r io.Reader) ReaderSeekerCloser {
- return ReaderSeekerCloser{r}
-}
-
-type ReaderSeekerCloser struct {
- r io.Reader
-}
-
-func (r ReaderSeekerCloser) Read(p []byte) (int, error) {
- switch t := r.r.(type) {
- case io.Reader:
- return t.Read(p)
- }
- return 0, nil
-}
-
-func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error) {
- switch t := r.r.(type) {
- case io.Seeker:
- return t.Seek(offset, whence)
- }
- return int64(0), nil
-}
-
-func (r ReaderSeekerCloser) Close() error {
- switch t := r.r.(type) {
- case io.Closer:
- return t.Close()
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/version.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/version.go
deleted file mode 100644
index f673d470a..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws/version.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Package aws provides core functionality for making requests to AWS services.
-package aws
-
-const SDKName = "aws-sdk-go"
-const SDKVersion = "0.5.0"
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.go
deleted file mode 100644
index 12e4fb529..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package endpoints
-
-//go:generate go run ../model/cli/gen-endpoints/main.go endpoints.json endpoints_map.go
-
-import "strings"
-
-func EndpointForRegion(svcName, region string) string {
- derivedKeys := []string{
- region + "/" + svcName,
- region + "/*",
- "*/" + svcName,
- "*/*",
- }
-
- for _, key := range derivedKeys {
- if val, ok := endpointsMap.Endpoints[key]; ok {
- ep := val.Endpoint
- ep = strings.Replace(ep, "{region}", region, -1)
- ep = strings.Replace(ep, "{service}", svcName, -1)
- return ep
- }
- }
- return ""
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.json b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.json
deleted file mode 100644
index 6c35090c6..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.json
+++ /dev/null
@@ -1,67 +0,0 @@
-{
- "version": 2,
- "endpoints": {
- "*/*": {
- "endpoint": "{service}.{region}.amazonaws.com"
- },
- "cn-north-1/*": {
- "endpoint": "{service}.{region}.amazonaws.com.cn",
- "signatureVersion": "v4"
- },
- "us-gov-west-1/iam": {
- "endpoint": "iam.us-gov.amazonaws.com"
- },
- "us-gov-west-1/sts": {
- "endpoint": "sts.us-gov-west-1.amazonaws.com"
- },
- "us-gov-west-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "*/cloudfront": {
- "endpoint": "cloudfront.amazonaws.com"
- },
- "*/iam": {
- "endpoint": "iam.amazonaws.com"
- },
- "*/importexport": {
- "endpoint": "importexport.amazonaws.com"
- },
- "*/route53": {
- "endpoint": "route53.amazonaws.com"
- },
- "*/sts": {
- "endpoint": "sts.amazonaws.com"
- },
- "us-east-1/sdb": {
- "endpoint": "sdb.amazonaws.com"
- },
- "us-east-1/s3": {
- "endpoint": "s3.amazonaws.com"
- },
- "us-west-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "us-west-2/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "eu-west-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "ap-southeast-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "ap-southeast-2/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "ap-northeast-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "sa-east-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "eu-central-1/s3": {
- "endpoint": "{service}.{region}.amazonaws.com",
- "signatureVersion": "v4"
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_map.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_map.go
deleted file mode 100644
index 733d2bd28..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_map.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package endpoints
-
-// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
-
-type endpointStruct struct {
- Version int
- Endpoints map[string]endpointEntry
-}
-
-type endpointEntry struct {
- Endpoint string
-}
-
-var endpointsMap = endpointStruct{
- Version: 2,
- Endpoints: map[string]endpointEntry{
- "*/*": endpointEntry{
- Endpoint: "{service}.{region}.amazonaws.com",
- },
- "*/cloudfront": endpointEntry{
- Endpoint: "cloudfront.amazonaws.com",
- },
- "*/iam": endpointEntry{
- Endpoint: "iam.amazonaws.com",
- },
- "*/importexport": endpointEntry{
- Endpoint: "importexport.amazonaws.com",
- },
- "*/route53": endpointEntry{
- Endpoint: "route53.amazonaws.com",
- },
- "*/sts": endpointEntry{
- Endpoint: "sts.amazonaws.com",
- },
- "ap-northeast-1/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "ap-southeast-1/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "ap-southeast-2/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "cn-north-1/*": endpointEntry{
- Endpoint: "{service}.{region}.amazonaws.com.cn",
- },
- "eu-central-1/s3": endpointEntry{
- Endpoint: "{service}.{region}.amazonaws.com",
- },
- "eu-west-1/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "sa-east-1/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "us-east-1/s3": endpointEntry{
- Endpoint: "s3.amazonaws.com",
- },
- "us-east-1/sdb": endpointEntry{
- Endpoint: "sdb.amazonaws.com",
- },
- "us-gov-west-1/iam": endpointEntry{
- Endpoint: "iam.us-gov.amazonaws.com",
- },
- "us-gov-west-1/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "us-gov-west-1/sts": endpointEntry{
- Endpoint: "sts.us-gov-west-1.amazonaws.com",
- },
- "us-west-1/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "us-west-2/s3": endpointEntry{
- Endpoint: "s3-{region}.amazonaws.com",
- },
- },
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_test.go
deleted file mode 100644
index 84efb893e..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints_test.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package endpoints
-
-import "testing"
-
-func TestGlobalEndpoints(t *testing.T) {
- region := "mock-region-1"
- svcs := []string{"cloudfront", "iam", "importexport", "route53", "sts"}
-
- for _, name := range svcs {
- if EndpointForRegion(name, region) != name+".amazonaws.com" {
- t.Errorf("expected endpoint for %s to equal %s.amazonaws.com", name, name)
- }
- }
-}
-
-func TestServicesInCN(t *testing.T) {
- region := "cn-north-1"
- svcs := []string{"cloudfront", "iam", "importexport", "route53", "sts", "s3"}
-
- for _, name := range svcs {
- if EndpointForRegion(name, region) != name+"."+region+".amazonaws.com.cn" {
- t.Errorf("expected endpoint for %s to equal %s.%s.amazonaws.com.cn", name, name, region)
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build.go
deleted file mode 100644
index 74b721658..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package query
-
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/input/query.json build_test.go
-
-import (
- "net/url"
-
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/query/queryutil"
-)
-
-func Build(r *aws.Request) {
- body := url.Values{
- "Action": {r.Operation.Name},
- "Version": {r.Service.APIVersion},
- }
- if err := queryutil.Parse(body, r.Params, false); err != nil {
- r.Error = err
- return
- }
-
- if r.ExpireTime == 0 {
- r.HTTPRequest.Method = "POST"
- r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
- r.SetBufferBody([]byte(body.Encode()))
- } else { // This is a pre-signed request
- r.HTTPRequest.Method = "GET"
- r.HTTPRequest.URL.RawQuery = body.Encode()
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build_test.go
deleted file mode 100644
index bbba7b4cd..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/build_test.go
+++ /dev/null
@@ -1,1167 +0,0 @@
-package query_test
-
-import (
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/query"
- "github.com/awslabs/aws-sdk-go/internal/signer/v4"
-
- "bytes"
- "encoding/json"
- "encoding/xml"
- "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil"
- "github.com/awslabs/aws-sdk-go/internal/util"
- "github.com/stretchr/testify/assert"
- "io/ioutil"
- "net/http"
- "net/url"
- "testing"
- "time"
-)
-
-var _ bytes.Buffer // always import bytes
-var _ http.Request
-var _ json.Marshaler
-var _ time.Time
-var _ xmlutil.XMLNode
-var _ xml.Attr
-var _ = ioutil.Discard
-var _ = util.Trim("")
-var _ = url.Values{}
-
-// InputService1ProtocolTest is a client for InputService1ProtocolTest.
-type InputService1ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService1ProtocolTest client.
-func NewInputService1ProtocolTest(config *aws.Config) *InputService1ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice1protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService1ProtocolTest{service}
-}
-
-// InputService1TestCaseOperation1Request generates a request for the InputService1TestCaseOperation1 operation.
-func (c *InputService1ProtocolTest) InputService1TestCaseOperation1Request(input *InputService1TestShapeInputShape) (req *aws.Request, output *InputService1TestShapeInputService1TestCaseOperation1Output) {
- if opInputService1TestCaseOperation1 == nil {
- opInputService1TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService1TestCaseOperation1, input, output)
- output = &InputService1TestShapeInputService1TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService1ProtocolTest) InputService1TestCaseOperation1(input *InputService1TestShapeInputShape) (output *InputService1TestShapeInputService1TestCaseOperation1Output, err error) {
- req, out := c.InputService1TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService1TestCaseOperation1 *aws.Operation
-
-type InputService1TestShapeInputService1TestCaseOperation1Output struct {
- metadataInputService1TestShapeInputService1TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService1TestShapeInputService1TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService1TestShapeInputShape struct {
- Bar *string `type:"string"`
-
- Foo *string `type:"string"`
-
- metadataInputService1TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService1TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService2ProtocolTest is a client for InputService2ProtocolTest.
-type InputService2ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService2ProtocolTest client.
-func NewInputService2ProtocolTest(config *aws.Config) *InputService2ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice2protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService2ProtocolTest{service}
-}
-
-// InputService2TestCaseOperation1Request generates a request for the InputService2TestCaseOperation1 operation.
-func (c *InputService2ProtocolTest) InputService2TestCaseOperation1Request(input *InputService2TestShapeInputShape) (req *aws.Request, output *InputService2TestShapeInputService2TestCaseOperation1Output) {
- if opInputService2TestCaseOperation1 == nil {
- opInputService2TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService2TestCaseOperation1, input, output)
- output = &InputService2TestShapeInputService2TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService2ProtocolTest) InputService2TestCaseOperation1(input *InputService2TestShapeInputShape) (output *InputService2TestShapeInputService2TestCaseOperation1Output, err error) {
- req, out := c.InputService2TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService2TestCaseOperation1 *aws.Operation
-
-type InputService2TestShapeInputService2TestCaseOperation1Output struct {
- metadataInputService2TestShapeInputService2TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService2TestShapeInputService2TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService2TestShapeInputShape struct {
- StructArg *InputService2TestShapeStructType `type:"structure"`
-
- metadataInputService2TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService2TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService2TestShapeStructType struct {
- ScalarArg *string `type:"string"`
-
- metadataInputService2TestShapeStructType `json:"-", xml:"-"`
-}
-
-type metadataInputService2TestShapeStructType struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService3ProtocolTest is a client for InputService3ProtocolTest.
-type InputService3ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService3ProtocolTest client.
-func NewInputService3ProtocolTest(config *aws.Config) *InputService3ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice3protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService3ProtocolTest{service}
-}
-
-// InputService3TestCaseOperation1Request generates a request for the InputService3TestCaseOperation1 operation.
-func (c *InputService3ProtocolTest) InputService3TestCaseOperation1Request(input *InputService3TestShapeInputShape) (req *aws.Request, output *InputService3TestShapeInputService3TestCaseOperation1Output) {
- if opInputService3TestCaseOperation1 == nil {
- opInputService3TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService3TestCaseOperation1, input, output)
- output = &InputService3TestShapeInputService3TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService3ProtocolTest) InputService3TestCaseOperation1(input *InputService3TestShapeInputShape) (output *InputService3TestShapeInputService3TestCaseOperation1Output, err error) {
- req, out := c.InputService3TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService3TestCaseOperation1 *aws.Operation
-
-type InputService3TestShapeInputService3TestCaseOperation1Output struct {
- metadataInputService3TestShapeInputService3TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService3TestShapeInputService3TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService3TestShapeInputShape struct {
- ListArg []*string `type:"list"`
-
- metadataInputService3TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService3TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService4ProtocolTest is a client for InputService4ProtocolTest.
-type InputService4ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService4ProtocolTest client.
-func NewInputService4ProtocolTest(config *aws.Config) *InputService4ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice4protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService4ProtocolTest{service}
-}
-
-// InputService4TestCaseOperation1Request generates a request for the InputService4TestCaseOperation1 operation.
-func (c *InputService4ProtocolTest) InputService4TestCaseOperation1Request(input *InputService4TestShapeInputShape) (req *aws.Request, output *InputService4TestShapeInputService4TestCaseOperation1Output) {
- if opInputService4TestCaseOperation1 == nil {
- opInputService4TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService4TestCaseOperation1, input, output)
- output = &InputService4TestShapeInputService4TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService4ProtocolTest) InputService4TestCaseOperation1(input *InputService4TestShapeInputShape) (output *InputService4TestShapeInputService4TestCaseOperation1Output, err error) {
- req, out := c.InputService4TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService4TestCaseOperation1 *aws.Operation
-
-type InputService4TestShapeInputService4TestCaseOperation1Output struct {
- metadataInputService4TestShapeInputService4TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService4TestShapeInputService4TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService4TestShapeInputShape struct {
- ListArg []*string `type:"list" flattened:"true"`
-
- ScalarArg *string `type:"string"`
-
- metadataInputService4TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService4TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService5ProtocolTest is a client for InputService5ProtocolTest.
-type InputService5ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService5ProtocolTest client.
-func NewInputService5ProtocolTest(config *aws.Config) *InputService5ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice5protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService5ProtocolTest{service}
-}
-
-// InputService5TestCaseOperation1Request generates a request for the InputService5TestCaseOperation1 operation.
-func (c *InputService5ProtocolTest) InputService5TestCaseOperation1Request(input *InputService5TestShapeInputShape) (req *aws.Request, output *InputService5TestShapeInputService5TestCaseOperation1Output) {
- if opInputService5TestCaseOperation1 == nil {
- opInputService5TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService5TestCaseOperation1, input, output)
- output = &InputService5TestShapeInputService5TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService5ProtocolTest) InputService5TestCaseOperation1(input *InputService5TestShapeInputShape) (output *InputService5TestShapeInputService5TestCaseOperation1Output, err error) {
- req, out := c.InputService5TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService5TestCaseOperation1 *aws.Operation
-
-type InputService5TestShapeInputService5TestCaseOperation1Output struct {
- metadataInputService5TestShapeInputService5TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService5TestShapeInputService5TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService5TestShapeInputShape struct {
- MapArg *map[string]*string `type:"map"`
-
- metadataInputService5TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService5TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService6ProtocolTest is a client for InputService6ProtocolTest.
-type InputService6ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService6ProtocolTest client.
-func NewInputService6ProtocolTest(config *aws.Config) *InputService6ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice6protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService6ProtocolTest{service}
-}
-
-// InputService6TestCaseOperation1Request generates a request for the InputService6TestCaseOperation1 operation.
-func (c *InputService6ProtocolTest) InputService6TestCaseOperation1Request(input *InputService6TestShapeInputShape) (req *aws.Request, output *InputService6TestShapeInputService6TestCaseOperation1Output) {
- if opInputService6TestCaseOperation1 == nil {
- opInputService6TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService6TestCaseOperation1, input, output)
- output = &InputService6TestShapeInputService6TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService6ProtocolTest) InputService6TestCaseOperation1(input *InputService6TestShapeInputShape) (output *InputService6TestShapeInputService6TestCaseOperation1Output, err error) {
- req, out := c.InputService6TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService6TestCaseOperation1 *aws.Operation
-
-type InputService6TestShapeInputService6TestCaseOperation1Output struct {
- metadataInputService6TestShapeInputService6TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService6TestShapeInputService6TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService6TestShapeInputShape struct {
- BlobArg []byte `type:"blob"`
-
- metadataInputService6TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService6TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService7ProtocolTest is a client for InputService7ProtocolTest.
-type InputService7ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService7ProtocolTest client.
-func NewInputService7ProtocolTest(config *aws.Config) *InputService7ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice7protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService7ProtocolTest{service}
-}
-
-// InputService7TestCaseOperation1Request generates a request for the InputService7TestCaseOperation1 operation.
-func (c *InputService7ProtocolTest) InputService7TestCaseOperation1Request(input *InputService7TestShapeInputShape) (req *aws.Request, output *InputService7TestShapeInputService7TestCaseOperation1Output) {
- if opInputService7TestCaseOperation1 == nil {
- opInputService7TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService7TestCaseOperation1, input, output)
- output = &InputService7TestShapeInputService7TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService7ProtocolTest) InputService7TestCaseOperation1(input *InputService7TestShapeInputShape) (output *InputService7TestShapeInputService7TestCaseOperation1Output, err error) {
- req, out := c.InputService7TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService7TestCaseOperation1 *aws.Operation
-
-type InputService7TestShapeInputService7TestCaseOperation1Output struct {
- metadataInputService7TestShapeInputService7TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService7TestShapeInputService7TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService7TestShapeInputShape struct {
- TimeArg *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- metadataInputService7TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService7TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService8ProtocolTest is a client for InputService8ProtocolTest.
-type InputService8ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService8ProtocolTest client.
-func NewInputService8ProtocolTest(config *aws.Config) *InputService8ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice8protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &InputService8ProtocolTest{service}
-}
-
-// InputService8TestCaseOperation1Request generates a request for the InputService8TestCaseOperation1 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation1Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation1Output) {
- if opInputService8TestCaseOperation1 == nil {
- opInputService8TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation1, input, output)
- output = &InputService8TestShapeInputService8TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation1(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestCaseOperation1Output, err error) {
- req, out := c.InputService8TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation1 *aws.Operation
-
-// InputService8TestCaseOperation2Request generates a request for the InputService8TestCaseOperation2 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation2Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation2Output) {
- if opInputService8TestCaseOperation2 == nil {
- opInputService8TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation2, input, output)
- output = &InputService8TestShapeInputService8TestCaseOperation2Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation2(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestCaseOperation2Output, err error) {
- req, out := c.InputService8TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation2 *aws.Operation
-
-// InputService8TestCaseOperation3Request generates a request for the InputService8TestCaseOperation3 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation3Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation3Output) {
- if opInputService8TestCaseOperation3 == nil {
- opInputService8TestCaseOperation3 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation3, input, output)
- output = &InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation3Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation3(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation3Output, err error) {
- req, out := c.InputService8TestCaseOperation3Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation3 *aws.Operation
-
-// InputService8TestCaseOperation4Request generates a request for the InputService8TestCaseOperation4 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation4Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation4Output) {
- if opInputService8TestCaseOperation4 == nil {
- opInputService8TestCaseOperation4 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation4, input, output)
- output = &InputService8TestShapeInputService8TestCaseOperation4Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation4(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestCaseOperation4Output, err error) {
- req, out := c.InputService8TestCaseOperation4Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation4 *aws.Operation
-
-// InputService8TestCaseOperation5Request generates a request for the InputService8TestCaseOperation5 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation5Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation5Output) {
- if opInputService8TestCaseOperation5 == nil {
- opInputService8TestCaseOperation5 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation5, input, output)
- output = &InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation5Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation5(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation5Output, err error) {
- req, out := c.InputService8TestCaseOperation5Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation5 *aws.Operation
-
-// InputService8TestCaseOperation6Request generates a request for the InputService8TestCaseOperation6 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation6Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation6Output) {
- if opInputService8TestCaseOperation6 == nil {
- opInputService8TestCaseOperation6 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation6, input, output)
- output = &InputService8TestShapeInputService8TestCaseOperation6Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation6(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestCaseOperation6Output, err error) {
- req, out := c.InputService8TestCaseOperation6Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation6 *aws.Operation
-
-type InputService8TestShapeInputService8TestCaseOperation1Output struct {
- metadataInputService8TestShapeInputService8TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputService8TestCaseOperation2Output struct {
- metadataInputService8TestShapeInputService8TestCaseOperation2Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestCaseOperation2Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputService8TestCaseOperation4Output struct {
- metadataInputService8TestShapeInputService8TestCaseOperation4Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestCaseOperation4Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputService8TestCaseOperation6Output struct {
- metadataInputService8TestShapeInputService8TestCaseOperation6Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestCaseOperation6Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation3Output struct {
- metadataInputService8TestShapeInputService8TestShapeInputService8TestCaseOperation3Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestShapeInputService8TestCaseOperation3Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputService8TestShapeInputService8TestCaseOperation5Output struct {
- metadataInputService8TestShapeInputService8TestShapeInputService8TestCaseOperation5Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestShapeInputService8TestCaseOperation5Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputService8TestShapeRecursiveStructType struct {
- NoRecurse *string `type:"string"`
-
- RecursiveList []*InputService8TestShapeInputService8TestShapeRecursiveStructType `type:"list"`
-
- RecursiveMap *map[string]*InputService8TestShapeInputService8TestShapeRecursiveStructType `type:"map"`
-
- RecursiveStruct *InputService8TestShapeInputService8TestShapeRecursiveStructType `type:"structure"`
-
- metadataInputService8TestShapeInputService8TestShapeRecursiveStructType `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestShapeRecursiveStructType struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputShape struct {
- RecursiveStruct *InputService8TestShapeInputService8TestShapeRecursiveStructType `type:"structure"`
-
- metadataInputService8TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//
-// Tests begin here
-//
-
-func TestInputService1ProtocolTestScalarMembersCase1(t *testing.T) {
- svc := NewInputService1ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService1TestShapeInputShape{
- Bar: aws.String("val2"),
- Foo: aws.String("val1"),
- }
- req, _ := svc.InputService1TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&Bar=val2&Foo=val1&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService2ProtocolTestNestedStructureMembersCase1(t *testing.T) {
- svc := NewInputService2ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService2TestShapeInputShape{
- StructArg: &InputService2TestShapeStructType{
- ScalarArg: aws.String("foo"),
- },
- }
- req, _ := svc.InputService2TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&StructArg.ScalarArg=foo&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService3ProtocolTestListTypesCase1(t *testing.T) {
- svc := NewInputService3ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService3TestShapeInputShape{
- ListArg: []*string{
- aws.String("foo"),
- aws.String("bar"),
- aws.String("baz"),
- },
- }
- req, _ := svc.InputService3TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&ListArg.member.1=foo&ListArg.member.2=bar&ListArg.member.3=baz&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService4ProtocolTestFlattenedListCase1(t *testing.T) {
- svc := NewInputService4ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService4TestShapeInputShape{
- ListArg: []*string{
- aws.String("a"),
- aws.String("b"),
- aws.String("c"),
- },
- ScalarArg: aws.String("foo"),
- }
- req, _ := svc.InputService4TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&ListArg.1=a&ListArg.2=b&ListArg.3=c&ScalarArg=foo&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService5ProtocolTestSerializeMapTypeCase1(t *testing.T) {
- svc := NewInputService5ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService5TestShapeInputShape{
- MapArg: &map[string]*string{
- "key1": aws.String("val1"),
- "key2": aws.String("val2"),
- },
- }
- req, _ := svc.InputService5TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&MapArg.entry.1.key=key1&MapArg.entry.1.value=val1&MapArg.entry.2.key=key2&MapArg.entry.2.value=val2&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService6ProtocolTestBase64EncodedBlobsCase1(t *testing.T) {
- svc := NewInputService6ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService6TestShapeInputShape{
- BlobArg: []byte("foo"),
- }
- req, _ := svc.InputService6TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&BlobArg=Zm9v&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService7ProtocolTestTimestampValuesCase1(t *testing.T) {
- svc := NewInputService7ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService7TestShapeInputShape{
- TimeArg: aws.Time(time.Unix(1422172800, 0)),
- }
- req, _ := svc.InputService7TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&TimeArg=2015-01-25T08%3A00%3A00Z&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestRecursiveShapesCase1(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- }
- req, _ := svc.InputService8TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&RecursiveStruct.NoRecurse=foo&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestRecursiveShapesCase2(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- },
- }
- req, _ := svc.InputService8TestCaseOperation2Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&RecursiveStruct.RecursiveStruct.NoRecurse=foo&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestRecursiveShapesCase3(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- },
- },
- },
- }
- req, _ := svc.InputService8TestCaseOperation3Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&RecursiveStruct.RecursiveStruct.RecursiveStruct.RecursiveStruct.NoRecurse=foo&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestRecursiveShapesCase4(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveList: []*InputService8TestShapeInputService8TestShapeRecursiveStructType{
- &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("bar"),
- },
- },
- },
- }
- req, _ := svc.InputService8TestCaseOperation4Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&RecursiveStruct.RecursiveList.member.1.NoRecurse=foo&RecursiveStruct.RecursiveList.member.2.NoRecurse=bar&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestRecursiveShapesCase5(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveList: []*InputService8TestShapeInputService8TestShapeRecursiveStructType{
- &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("bar"),
- },
- },
- },
- },
- }
- req, _ := svc.InputService8TestCaseOperation5Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&RecursiveStruct.RecursiveList.member.1.NoRecurse=foo&RecursiveStruct.RecursiveList.member.2.RecursiveStruct.NoRecurse=bar&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestRecursiveShapesCase6(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- RecursiveStruct: &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- RecursiveMap: &map[string]*InputService8TestShapeInputService8TestShapeRecursiveStructType{
- "bar": &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("bar"),
- },
- "foo": &InputService8TestShapeInputService8TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- },
- },
- }
- req, _ := svc.InputService8TestCaseOperation6Request(input)
- r := req.HTTPRequest
-
- // build request
- query.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body, _ := ioutil.ReadAll(r.Body)
- assert.Equal(t, util.Trim(`Action=OperationName&RecursiveStruct.RecursiveMap.entry.1.key=bar&RecursiveStruct.RecursiveMap.entry.1.value.NoRecurse=bar&RecursiveStruct.RecursiveMap.entry.2.key=foo&RecursiveStruct.RecursiveMap.entry.2.value.NoRecurse=foo&Version=2014-01-01`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go
deleted file mode 100644
index fe8850902..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go
+++ /dev/null
@@ -1,198 +0,0 @@
-package queryutil
-
-import (
- "encoding/base64"
- "fmt"
- "net/url"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-func Parse(body url.Values, i interface{}, isEC2 bool) error {
- q := queryParser{isEC2: isEC2}
- return q.parseValue(body, reflect.ValueOf(i), "", "")
-}
-
-func elemOf(value reflect.Value) reflect.Value {
- for value.Kind() == reflect.Ptr {
- value = value.Elem()
- }
- return value
-}
-
-type queryParser struct {
- isEC2 bool
-}
-
-func (q *queryParser) parseValue(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
- value = elemOf(value)
-
- // no need to handle zero values
- if !value.IsValid() {
- return nil
- }
-
- t := tag.Get("type")
- if t == "" {
- switch value.Kind() {
- case reflect.Struct:
- t = "structure"
- case reflect.Slice:
- t = "list"
- case reflect.Map:
- t = "map"
- }
- }
-
- switch t {
- case "structure":
- return q.parseStruct(v, value, prefix)
- case "list":
- return q.parseList(v, value, prefix, tag)
- case "map":
- return q.parseMap(v, value, prefix, tag)
- default:
- return q.parseScalar(v, value, prefix, tag)
- }
-}
-
-func (q *queryParser) parseStruct(v url.Values, value reflect.Value, prefix string) error {
- if !value.IsValid() {
- return nil
- }
-
- t := value.Type()
- for i := 0; i < value.NumField(); i++ {
- if c := t.Field(i).Name[0:1]; strings.ToLower(c) == c {
- continue // ignore unexported fields
- }
-
- value := elemOf(value.Field(i))
- field := t.Field(i)
- var name string
-
- if q.isEC2 {
- name = field.Tag.Get("queryName")
- }
- if name == "" {
- if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
- name = field.Tag.Get("locationNameList")
- } else if locName := field.Tag.Get("locationName"); locName != "" {
- name = locName
- }
- if name != "" && q.isEC2 {
- name = strings.ToUpper(name[0:1]) + name[1:]
- }
- }
- if name == "" {
- name = field.Name
- }
-
- if prefix != "" {
- name = prefix + "." + name
- }
-
- if err := q.parseValue(v, value, name, field.Tag); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (q *queryParser) parseList(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
- // check for unflattened list member
- if !q.isEC2 && tag.Get("flattened") == "" {
- prefix += ".member"
- }
-
- for i := 0; i < value.Len(); i++ {
- slicePrefix := prefix
- if slicePrefix == "" {
- slicePrefix = strconv.Itoa(i + 1)
- } else {
- slicePrefix = slicePrefix + "." + strconv.Itoa(i+1)
- }
- if err := q.parseValue(v, value.Index(i), slicePrefix, ""); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (q *queryParser) parseMap(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
- // check for unflattened list member
- if !q.isEC2 && tag.Get("flattened") == "" {
- prefix += ".entry"
- }
-
- // sort keys for improved serialization consistency.
- // this is not strictly necessary for protocol support.
- mapKeyValues := value.MapKeys()
- mapKeys := map[string]reflect.Value{}
- mapKeyNames := make([]string, len(mapKeyValues))
- for i, mapKey := range mapKeyValues {
- name := mapKey.String()
- mapKeys[name] = mapKey
- mapKeyNames[i] = name
- }
- sort.Strings(mapKeyNames)
-
- for i, mapKeyName := range mapKeyNames {
- mapKey := mapKeys[mapKeyName]
- mapValue := value.MapIndex(mapKey)
-
- // serialize key
- var keyName string
- if prefix == "" {
- keyName = strconv.Itoa(i+1) + ".key"
- } else {
- keyName = prefix + "." + strconv.Itoa(i+1) + ".key"
- }
-
- if err := q.parseValue(v, mapKey, keyName, ""); err != nil {
- return err
- }
-
- // serialize value
- var valueName string
- if prefix == "" {
- valueName = strconv.Itoa(i+1) + ".value"
- } else {
- valueName = prefix + "." + strconv.Itoa(i+1) + ".value"
- }
-
- if err := q.parseValue(v, mapValue, valueName, ""); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (q *queryParser) parseScalar(v url.Values, r reflect.Value, name string, tag reflect.StructTag) error {
- switch value := r.Interface().(type) {
- case string:
- v.Set(name, value)
- case []byte:
- v.Set(name, base64.StdEncoding.EncodeToString(value))
- case bool:
- v.Set(name, strconv.FormatBool(value))
- case int64:
- v.Set(name, strconv.FormatInt(value, 10))
- case int:
- v.Set(name, strconv.Itoa(value))
- case float64:
- v.Set(name, strconv.FormatFloat(value, 'f', -1, 64))
- case float32:
- v.Set(name, strconv.FormatFloat(float64(value), 'f', -1, 32))
- case time.Time:
- const ISO8601UTC = "2006-01-02T15:04:05Z"
- v.Set(name, value.UTC().Format(ISO8601UTC))
- default:
- return fmt.Errorf("unsupported value for param %s: %v (%s)", name, r.Interface(), r.Type().Name())
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal.go
deleted file mode 100644
index 92a740dc4..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package query
-
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/output/query.json unmarshal_test.go
-
-import (
- "encoding/xml"
-
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil"
-)
-
-func Unmarshal(r *aws.Request) {
- defer r.HTTPResponse.Body.Close()
- if r.DataFilled() {
- decoder := xml.NewDecoder(r.HTTPResponse.Body)
- err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result")
- if err != nil {
- r.Error = err
- return
- }
- }
-}
-
-func UnmarshalMeta(r *aws.Request) {
- // TODO implement unmarshaling of request IDs
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_error.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_error.go
deleted file mode 100644
index cf82eef93..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_error.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package query
-
-import (
- "encoding/xml"
- "io"
-
- "github.com/awslabs/aws-sdk-go/aws"
-)
-
-type xmlErrorResponse struct {
- XMLName xml.Name `xml:"ErrorResponse"`
- Code string `xml:"Error>Code"`
- Message string `xml:"Error>Message"`
- RequestID string `xml:"RequestId"`
-}
-
-func UnmarshalError(r *aws.Request) {
- defer r.HTTPResponse.Body.Close()
-
- resp := &xmlErrorResponse{}
- err := xml.NewDecoder(r.HTTPResponse.Body).Decode(resp)
- if err != nil && err != io.EOF {
- r.Error = err
- } else {
- r.Error = aws.APIError{
- StatusCode: r.HTTPResponse.StatusCode,
- Code: resp.Code,
- Message: resp.Message,
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_test.go
deleted file mode 100644
index 8d67b2dac..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/query/unmarshal_test.go
+++ /dev/null
@@ -1,1361 +0,0 @@
-package query_test
-
-import (
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/query"
- "github.com/awslabs/aws-sdk-go/internal/signer/v4"
-
- "bytes"
- "encoding/json"
- "encoding/xml"
- "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil"
- "github.com/awslabs/aws-sdk-go/internal/util"
- "github.com/stretchr/testify/assert"
- "io/ioutil"
- "net/http"
- "net/url"
- "testing"
- "time"
-)
-
-var _ bytes.Buffer // always import bytes
-var _ http.Request
-var _ json.Marshaler
-var _ time.Time
-var _ xmlutil.XMLNode
-var _ xml.Attr
-var _ = ioutil.Discard
-var _ = util.Trim("")
-var _ = url.Values{}
-
-// OutputService1ProtocolTest is a client for OutputService1ProtocolTest.
-type OutputService1ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService1ProtocolTest client.
-func NewOutputService1ProtocolTest(config *aws.Config) *OutputService1ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice1protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService1ProtocolTest{service}
-}
-
-// OutputService1TestCaseOperation1Request generates a request for the OutputService1TestCaseOperation1 operation.
-func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1Request(input *OutputService1TestShapeOutputService1TestCaseOperation1Input) (req *aws.Request, output *OutputService1TestShapeOutputService1TestShapeOutputShape) {
- if opOutputService1TestCaseOperation1 == nil {
- opOutputService1TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService1TestCaseOperation1, input, output)
- output = &OutputService1TestShapeOutputService1TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1(input *OutputService1TestShapeOutputService1TestCaseOperation1Input) (output *OutputService1TestShapeOutputService1TestShapeOutputShape, err error) {
- req, out := c.OutputService1TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService1TestCaseOperation1 *aws.Operation
-
-type OutputService1TestShapeOutputService1TestCaseOperation1Input struct {
- metadataOutputService1TestShapeOutputService1TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService1TestShapeOutputService1TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService1TestShapeOutputService1TestShapeOutputShape struct {
- Char *string `type:"character"`
-
- Double *float64 `type:"double"`
-
- FalseBool *bool `type:"boolean"`
-
- Float *float64 `type:"float"`
-
- Long *int64 `type:"long"`
-
- Num *int64 `locationName:"FooNum" type:"integer"`
-
- Str *string `type:"string"`
-
- Timestamp *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- TrueBool *bool `type:"boolean"`
-
- metadataOutputService1TestShapeOutputService1TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService1TestShapeOutputService1TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService2ProtocolTest is a client for OutputService2ProtocolTest.
-type OutputService2ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService2ProtocolTest client.
-func NewOutputService2ProtocolTest(config *aws.Config) *OutputService2ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice2protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService2ProtocolTest{service}
-}
-
-// OutputService2TestCaseOperation1Request generates a request for the OutputService2TestCaseOperation1 operation.
-func (c *OutputService2ProtocolTest) OutputService2TestCaseOperation1Request(input *OutputService2TestShapeOutputService2TestCaseOperation1Input) (req *aws.Request, output *OutputService2TestShapeOutputShape) {
- if opOutputService2TestCaseOperation1 == nil {
- opOutputService2TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService2TestCaseOperation1, input, output)
- output = &OutputService2TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService2ProtocolTest) OutputService2TestCaseOperation1(input *OutputService2TestShapeOutputService2TestCaseOperation1Input) (output *OutputService2TestShapeOutputShape, err error) {
- req, out := c.OutputService2TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService2TestCaseOperation1 *aws.Operation
-
-type OutputService2TestShapeOutputService2TestCaseOperation1Input struct {
- metadataOutputService2TestShapeOutputService2TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService2TestShapeOutputService2TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService2TestShapeOutputShape struct {
- Num *int64 `type:"integer"`
-
- Str *string `type:"string"`
-
- metadataOutputService2TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService2TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService3ProtocolTest is a client for OutputService3ProtocolTest.
-type OutputService3ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService3ProtocolTest client.
-func NewOutputService3ProtocolTest(config *aws.Config) *OutputService3ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice3protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService3ProtocolTest{service}
-}
-
-// OutputService3TestCaseOperation1Request generates a request for the OutputService3TestCaseOperation1 operation.
-func (c *OutputService3ProtocolTest) OutputService3TestCaseOperation1Request(input *OutputService3TestShapeOutputService3TestCaseOperation1Input) (req *aws.Request, output *OutputService3TestShapeOutputShape) {
- if opOutputService3TestCaseOperation1 == nil {
- opOutputService3TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService3TestCaseOperation1, input, output)
- output = &OutputService3TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService3ProtocolTest) OutputService3TestCaseOperation1(input *OutputService3TestShapeOutputService3TestCaseOperation1Input) (output *OutputService3TestShapeOutputShape, err error) {
- req, out := c.OutputService3TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService3TestCaseOperation1 *aws.Operation
-
-type OutputService3TestShapeOutputService3TestCaseOperation1Input struct {
- metadataOutputService3TestShapeOutputService3TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService3TestShapeOutputService3TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService3TestShapeOutputShape struct {
- Blob []byte `type:"blob"`
-
- metadataOutputService3TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService3TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService4ProtocolTest is a client for OutputService4ProtocolTest.
-type OutputService4ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService4ProtocolTest client.
-func NewOutputService4ProtocolTest(config *aws.Config) *OutputService4ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice4protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService4ProtocolTest{service}
-}
-
-// OutputService4TestCaseOperation1Request generates a request for the OutputService4TestCaseOperation1 operation.
-func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation1Request(input *OutputService4TestShapeOutputService4TestCaseOperation1Input) (req *aws.Request, output *OutputService4TestShapeOutputShape) {
- if opOutputService4TestCaseOperation1 == nil {
- opOutputService4TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService4TestCaseOperation1, input, output)
- output = &OutputService4TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation1(input *OutputService4TestShapeOutputService4TestCaseOperation1Input) (output *OutputService4TestShapeOutputShape, err error) {
- req, out := c.OutputService4TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService4TestCaseOperation1 *aws.Operation
-
-type OutputService4TestShapeOutputService4TestCaseOperation1Input struct {
- metadataOutputService4TestShapeOutputService4TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService4TestShapeOutputService4TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService4TestShapeOutputShape struct {
- ListMember []*string `type:"list"`
-
- metadataOutputService4TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService4TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService5ProtocolTest is a client for OutputService5ProtocolTest.
-type OutputService5ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService5ProtocolTest client.
-func NewOutputService5ProtocolTest(config *aws.Config) *OutputService5ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice5protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService5ProtocolTest{service}
-}
-
-// OutputService5TestCaseOperation1Request generates a request for the OutputService5TestCaseOperation1 operation.
-func (c *OutputService5ProtocolTest) OutputService5TestCaseOperation1Request(input *OutputService5TestShapeOutputService5TestCaseOperation1Input) (req *aws.Request, output *OutputService5TestShapeOutputShape) {
- if opOutputService5TestCaseOperation1 == nil {
- opOutputService5TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService5TestCaseOperation1, input, output)
- output = &OutputService5TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService5ProtocolTest) OutputService5TestCaseOperation1(input *OutputService5TestShapeOutputService5TestCaseOperation1Input) (output *OutputService5TestShapeOutputShape, err error) {
- req, out := c.OutputService5TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService5TestCaseOperation1 *aws.Operation
-
-type OutputService5TestShapeOutputService5TestCaseOperation1Input struct {
- metadataOutputService5TestShapeOutputService5TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService5TestShapeOutputService5TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService5TestShapeOutputShape struct {
- ListMember []*string `locationNameList:"item" type:"list"`
-
- metadataOutputService5TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService5TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService6ProtocolTest is a client for OutputService6ProtocolTest.
-type OutputService6ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService6ProtocolTest client.
-func NewOutputService6ProtocolTest(config *aws.Config) *OutputService6ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice6protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService6ProtocolTest{service}
-}
-
-// OutputService6TestCaseOperation1Request generates a request for the OutputService6TestCaseOperation1 operation.
-func (c *OutputService6ProtocolTest) OutputService6TestCaseOperation1Request(input *OutputService6TestShapeOutputService6TestCaseOperation1Input) (req *aws.Request, output *OutputService6TestShapeOutputShape) {
- if opOutputService6TestCaseOperation1 == nil {
- opOutputService6TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService6TestCaseOperation1, input, output)
- output = &OutputService6TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService6ProtocolTest) OutputService6TestCaseOperation1(input *OutputService6TestShapeOutputService6TestCaseOperation1Input) (output *OutputService6TestShapeOutputShape, err error) {
- req, out := c.OutputService6TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService6TestCaseOperation1 *aws.Operation
-
-type OutputService6TestShapeOutputService6TestCaseOperation1Input struct {
- metadataOutputService6TestShapeOutputService6TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService6TestShapeOutputService6TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService6TestShapeOutputShape struct {
- ListMember []*string `type:"list" flattened:"true"`
-
- metadataOutputService6TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService6TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService7ProtocolTest is a client for OutputService7ProtocolTest.
-type OutputService7ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService7ProtocolTest client.
-func NewOutputService7ProtocolTest(config *aws.Config) *OutputService7ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice7protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService7ProtocolTest{service}
-}
-
-// OutputService7TestCaseOperation1Request generates a request for the OutputService7TestCaseOperation1 operation.
-func (c *OutputService7ProtocolTest) OutputService7TestCaseOperation1Request(input *OutputService7TestShapeOutputService7TestCaseOperation1Input) (req *aws.Request, output *OutputService7TestShapeOutputShape) {
- if opOutputService7TestCaseOperation1 == nil {
- opOutputService7TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService7TestCaseOperation1, input, output)
- output = &OutputService7TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService7ProtocolTest) OutputService7TestCaseOperation1(input *OutputService7TestShapeOutputService7TestCaseOperation1Input) (output *OutputService7TestShapeOutputShape, err error) {
- req, out := c.OutputService7TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService7TestCaseOperation1 *aws.Operation
-
-type OutputService7TestShapeOutputService7TestCaseOperation1Input struct {
- metadataOutputService7TestShapeOutputService7TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService7TestShapeOutputService7TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService7TestShapeOutputShape struct {
- ListMember []*string `type:"list" flattened:"true"`
-
- metadataOutputService7TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService7TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService8ProtocolTest is a client for OutputService8ProtocolTest.
-type OutputService8ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService8ProtocolTest client.
-func NewOutputService8ProtocolTest(config *aws.Config) *OutputService8ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice8protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService8ProtocolTest{service}
-}
-
-// OutputService8TestCaseOperation1Request generates a request for the OutputService8TestCaseOperation1 operation.
-func (c *OutputService8ProtocolTest) OutputService8TestCaseOperation1Request(input *OutputService8TestShapeOutputService8TestCaseOperation1Input) (req *aws.Request, output *OutputService8TestShapeOutputShape) {
- if opOutputService8TestCaseOperation1 == nil {
- opOutputService8TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService8TestCaseOperation1, input, output)
- output = &OutputService8TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService8ProtocolTest) OutputService8TestCaseOperation1(input *OutputService8TestShapeOutputService8TestCaseOperation1Input) (output *OutputService8TestShapeOutputShape, err error) {
- req, out := c.OutputService8TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService8TestCaseOperation1 *aws.Operation
-
-type OutputService8TestShapeOutputService8TestCaseOperation1Input struct {
- metadataOutputService8TestShapeOutputService8TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService8TestShapeOutputService8TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService8TestShapeOutputShape struct {
- List []*OutputService8TestShapeStructureShape `type:"list"`
-
- metadataOutputService8TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService8TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService8TestShapeStructureShape struct {
- Bar *string `type:"string"`
-
- Baz *string `type:"string"`
-
- Foo *string `type:"string"`
-
- metadataOutputService8TestShapeStructureShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService8TestShapeStructureShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService9ProtocolTest is a client for OutputService9ProtocolTest.
-type OutputService9ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService9ProtocolTest client.
-func NewOutputService9ProtocolTest(config *aws.Config) *OutputService9ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice9protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService9ProtocolTest{service}
-}
-
-// OutputService9TestCaseOperation1Request generates a request for the OutputService9TestCaseOperation1 operation.
-func (c *OutputService9ProtocolTest) OutputService9TestCaseOperation1Request(input *OutputService9TestShapeOutputService9TestCaseOperation1Input) (req *aws.Request, output *OutputService9TestShapeOutputShape) {
- if opOutputService9TestCaseOperation1 == nil {
- opOutputService9TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService9TestCaseOperation1, input, output)
- output = &OutputService9TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService9ProtocolTest) OutputService9TestCaseOperation1(input *OutputService9TestShapeOutputService9TestCaseOperation1Input) (output *OutputService9TestShapeOutputShape, err error) {
- req, out := c.OutputService9TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService9TestCaseOperation1 *aws.Operation
-
-type OutputService9TestShapeOutputService9TestCaseOperation1Input struct {
- metadataOutputService9TestShapeOutputService9TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService9TestShapeOutputService9TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService9TestShapeOutputShape struct {
- List []*OutputService9TestShapeStructureShape `type:"list" flattened:"true"`
-
- metadataOutputService9TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService9TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService9TestShapeStructureShape struct {
- Bar *string `type:"string"`
-
- Baz *string `type:"string"`
-
- Foo *string `type:"string"`
-
- metadataOutputService9TestShapeStructureShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService9TestShapeStructureShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService10ProtocolTest is a client for OutputService10ProtocolTest.
-type OutputService10ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService10ProtocolTest client.
-func NewOutputService10ProtocolTest(config *aws.Config) *OutputService10ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice10protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService10ProtocolTest{service}
-}
-
-// OutputService10TestCaseOperation1Request generates a request for the OutputService10TestCaseOperation1 operation.
-func (c *OutputService10ProtocolTest) OutputService10TestCaseOperation1Request(input *OutputService10TestShapeOutputService10TestCaseOperation1Input) (req *aws.Request, output *OutputService10TestShapeOutputShape) {
- if opOutputService10TestCaseOperation1 == nil {
- opOutputService10TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService10TestCaseOperation1, input, output)
- output = &OutputService10TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService10ProtocolTest) OutputService10TestCaseOperation1(input *OutputService10TestShapeOutputService10TestCaseOperation1Input) (output *OutputService10TestShapeOutputShape, err error) {
- req, out := c.OutputService10TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService10TestCaseOperation1 *aws.Operation
-
-type OutputService10TestShapeOutputService10TestCaseOperation1Input struct {
- metadataOutputService10TestShapeOutputService10TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService10TestShapeOutputService10TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService10TestShapeOutputShape struct {
- List []*string `locationNameList:"NamedList" type:"list" flattened:"true"`
-
- metadataOutputService10TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService10TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService11ProtocolTest is a client for OutputService11ProtocolTest.
-type OutputService11ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService11ProtocolTest client.
-func NewOutputService11ProtocolTest(config *aws.Config) *OutputService11ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice11protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService11ProtocolTest{service}
-}
-
-// OutputService11TestCaseOperation1Request generates a request for the OutputService11TestCaseOperation1 operation.
-func (c *OutputService11ProtocolTest) OutputService11TestCaseOperation1Request(input *OutputService11TestShapeOutputService11TestCaseOperation1Input) (req *aws.Request, output *OutputService11TestShapeOutputShape) {
- if opOutputService11TestCaseOperation1 == nil {
- opOutputService11TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService11TestCaseOperation1, input, output)
- output = &OutputService11TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService11ProtocolTest) OutputService11TestCaseOperation1(input *OutputService11TestShapeOutputService11TestCaseOperation1Input) (output *OutputService11TestShapeOutputShape, err error) {
- req, out := c.OutputService11TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService11TestCaseOperation1 *aws.Operation
-
-type OutputService11TestShapeOutputService11TestCaseOperation1Input struct {
- metadataOutputService11TestShapeOutputService11TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService11TestShapeOutputService11TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService11TestShapeOutputShape struct {
- Map *map[string]*OutputService11TestShapeStructType `type:"map"`
-
- metadataOutputService11TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService11TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService11TestShapeStructType struct {
- Foo *string `locationName:"foo" type:"string"`
-
- metadataOutputService11TestShapeStructType `json:"-", xml:"-"`
-}
-
-type metadataOutputService11TestShapeStructType struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService12ProtocolTest is a client for OutputService12ProtocolTest.
-type OutputService12ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService12ProtocolTest client.
-func NewOutputService12ProtocolTest(config *aws.Config) *OutputService12ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice12protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService12ProtocolTest{service}
-}
-
-// OutputService12TestCaseOperation1Request generates a request for the OutputService12TestCaseOperation1 operation.
-func (c *OutputService12ProtocolTest) OutputService12TestCaseOperation1Request(input *OutputService12TestShapeOutputService12TestCaseOperation1Input) (req *aws.Request, output *OutputService12TestShapeOutputShape) {
- if opOutputService12TestCaseOperation1 == nil {
- opOutputService12TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService12TestCaseOperation1, input, output)
- output = &OutputService12TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService12ProtocolTest) OutputService12TestCaseOperation1(input *OutputService12TestShapeOutputService12TestCaseOperation1Input) (output *OutputService12TestShapeOutputShape, err error) {
- req, out := c.OutputService12TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService12TestCaseOperation1 *aws.Operation
-
-type OutputService12TestShapeOutputService12TestCaseOperation1Input struct {
- metadataOutputService12TestShapeOutputService12TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService12TestShapeOutputService12TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService12TestShapeOutputShape struct {
- Map *map[string]*string `type:"map" flattened:"true"`
-
- metadataOutputService12TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService12TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService13ProtocolTest is a client for OutputService13ProtocolTest.
-type OutputService13ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService13ProtocolTest client.
-func NewOutputService13ProtocolTest(config *aws.Config) *OutputService13ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice13protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService13ProtocolTest{service}
-}
-
-// OutputService13TestCaseOperation1Request generates a request for the OutputService13TestCaseOperation1 operation.
-func (c *OutputService13ProtocolTest) OutputService13TestCaseOperation1Request(input *OutputService13TestShapeOutputService13TestCaseOperation1Input) (req *aws.Request, output *OutputService13TestShapeOutputShape) {
- if opOutputService13TestCaseOperation1 == nil {
- opOutputService13TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService13TestCaseOperation1, input, output)
- output = &OutputService13TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService13ProtocolTest) OutputService13TestCaseOperation1(input *OutputService13TestShapeOutputService13TestCaseOperation1Input) (output *OutputService13TestShapeOutputShape, err error) {
- req, out := c.OutputService13TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService13TestCaseOperation1 *aws.Operation
-
-type OutputService13TestShapeOutputService13TestCaseOperation1Input struct {
- metadataOutputService13TestShapeOutputService13TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService13TestShapeOutputService13TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService13TestShapeOutputShape struct {
- Map *map[string]*string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"`
-
- metadataOutputService13TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService13TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService14ProtocolTest is a client for OutputService14ProtocolTest.
-type OutputService14ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService14ProtocolTest client.
-func NewOutputService14ProtocolTest(config *aws.Config) *OutputService14ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice14protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(query.Build)
- service.Handlers.Unmarshal.PushBack(query.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
-
- return &OutputService14ProtocolTest{service}
-}
-
-// OutputService14TestCaseOperation1Request generates a request for the OutputService14TestCaseOperation1 operation.
-func (c *OutputService14ProtocolTest) OutputService14TestCaseOperation1Request(input *OutputService14TestShapeOutputService14TestCaseOperation1Input) (req *aws.Request, output *OutputService14TestShapeOutputShape) {
- if opOutputService14TestCaseOperation1 == nil {
- opOutputService14TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService14TestCaseOperation1, input, output)
- output = &OutputService14TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService14ProtocolTest) OutputService14TestCaseOperation1(input *OutputService14TestShapeOutputService14TestCaseOperation1Input) (output *OutputService14TestShapeOutputShape, err error) {
- req, out := c.OutputService14TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService14TestCaseOperation1 *aws.Operation
-
-type OutputService14TestShapeOutputService14TestCaseOperation1Input struct {
- metadataOutputService14TestShapeOutputService14TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService14TestShapeOutputService14TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService14TestShapeOutputShape struct {
- Map *map[string]*string `locationNameKey:"foo" locationNameValue:"bar" type:"map" flattened:"true"`
-
- metadataOutputService14TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService14TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//
-// Tests begin here
-//
-
-func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
- svc := NewOutputService1ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Str>myname</Str><FooNum>123</FooNum><FalseBool>false</FalseBool><TrueBool>true</TrueBool><Float>1.2</Float><Double>1.3</Double><Long>200</Long><Char>a</Char><Timestamp>2015-01-25T08:00:00Z</Timestamp></OperationNameResult><ResponseMetadata><RequestId>request-id</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService1TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "a", *out.Char)
- assert.Equal(t, 1.3, *out.Double)
- assert.Equal(t, false, *out.FalseBool)
- assert.Equal(t, 1.2, *out.Float)
- assert.Equal(t, 200, *out.Long)
- assert.Equal(t, 123, *out.Num)
- assert.Equal(t, "myname", *out.Str)
- assert.Equal(t, time.Unix(1.4221728e+09, 0).UTC().String(), out.Timestamp.String())
- assert.Equal(t, true, *out.TrueBool)
-
-}
-
-func TestOutputService2ProtocolTestNotAllMembersInResponseCase1(t *testing.T) {
- svc := NewOutputService2ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Str>myname</Str></OperationNameResult><ResponseMetadata><RequestId>request-id</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService2TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "myname", *out.Str)
-
-}
-
-func TestOutputService3ProtocolTestBlobCase1(t *testing.T) {
- svc := NewOutputService3ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Blob>dmFsdWU=</Blob></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService3TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "value", string(out.Blob))
-
-}
-
-func TestOutputService4ProtocolTestListsCase1(t *testing.T) {
- svc := NewOutputService4ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><ListMember><member>abc</member><member>123</member></ListMember></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService4TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
- assert.Equal(t, "123", *out.ListMember[1])
-
-}
-
-func TestOutputService5ProtocolTestListWithCustomMemberNameCase1(t *testing.T) {
- svc := NewOutputService5ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><ListMember><item>abc</item><item>123</item></ListMember></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService5TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
- assert.Equal(t, "123", *out.ListMember[1])
-
-}
-
-func TestOutputService6ProtocolTestFlattenedListCase1(t *testing.T) {
- svc := NewOutputService6ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><ListMember>abc</ListMember><ListMember>123</ListMember></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService6TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
- assert.Equal(t, "123", *out.ListMember[1])
-
-}
-
-func TestOutputService7ProtocolTestFlattenedSingleElementListCase1(t *testing.T) {
- svc := NewOutputService7ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><ListMember>abc</ListMember></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService7TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
-
-}
-
-func TestOutputService8ProtocolTestListOfStructuresCase1(t *testing.T) {
- svc := NewOutputService8ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08/\"><OperationNameResult><List><member><Foo>firstfoo</Foo><Bar>firstbar</Bar><Baz>firstbaz</Baz></member><member><Foo>secondfoo</Foo><Bar>secondbar</Bar><Baz>secondbaz</Baz></member></List></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService8TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "firstbar", *out.List[0].Bar)
- assert.Equal(t, "firstbaz", *out.List[0].Baz)
- assert.Equal(t, "firstfoo", *out.List[0].Foo)
- assert.Equal(t, "secondbar", *out.List[1].Bar)
- assert.Equal(t, "secondbaz", *out.List[1].Baz)
- assert.Equal(t, "secondfoo", *out.List[1].Foo)
-
-}
-
-func TestOutputService9ProtocolTestFlattenedListOfStructuresCase1(t *testing.T) {
- svc := NewOutputService9ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08/\"><OperationNameResult><List><Foo>firstfoo</Foo><Bar>firstbar</Bar><Baz>firstbaz</Baz></List><List><Foo>secondfoo</Foo><Bar>secondbar</Bar><Baz>secondbaz</Baz></List></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService9TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "firstbar", *out.List[0].Bar)
- assert.Equal(t, "firstbaz", *out.List[0].Baz)
- assert.Equal(t, "firstfoo", *out.List[0].Foo)
- assert.Equal(t, "secondbar", *out.List[1].Bar)
- assert.Equal(t, "secondbaz", *out.List[1].Baz)
- assert.Equal(t, "secondfoo", *out.List[1].Foo)
-
-}
-
-func TestOutputService10ProtocolTestFlattenedListWithLocationNameCase1(t *testing.T) {
- svc := NewOutputService10ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08/\"><OperationNameResult><NamedList>a</NamedList><NamedList>b</NamedList></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService10TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "a", *out.List[0])
- assert.Equal(t, "b", *out.List[1])
-
-}
-
-func TestOutputService11ProtocolTestNormalMapCase1(t *testing.T) {
- svc := NewOutputService11ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08\"><OperationNameResult><Map><entry><key>qux</key><value><foo>bar</foo></value></entry><entry><key>baz</key><value><foo>bam</foo></value></entry></Map></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService11TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bam", *(*out.Map)["baz"].Foo)
- assert.Equal(t, "bar", *(*out.Map)["qux"].Foo)
-
-}
-
-func TestOutputService12ProtocolTestFlattenedMapCase1(t *testing.T) {
- svc := NewOutputService12ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Map><key>qux</key><value>bar</value></Map><Map><key>baz</key><value>bam</value></Map></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService12TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bam", *(*out.Map)["baz"])
- assert.Equal(t, "bar", *(*out.Map)["qux"])
-
-}
-
-func TestOutputService13ProtocolTestFlattenedMapInShapeDefinitionCase1(t *testing.T) {
- svc := NewOutputService13ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Attribute><Name>qux</Name><Value>bar</Value></Attribute></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService13TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bar", *(*out.Map)["qux"])
-
-}
-
-func TestOutputService14ProtocolTestNamedMapCase1(t *testing.T) {
- svc := NewOutputService14ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Map><foo>qux</foo><bar>bar</bar></Map><Map><foo>baz</foo><bar>bam</bar></Map></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
- req, out := svc.OutputService14TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- query.UnmarshalMeta(req)
- query.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bam", *(*out.Map)["baz"])
- assert.Equal(t, "bar", *(*out.Map)["qux"])
-
-}
-
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/build.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/build.go
deleted file mode 100644
index 3ff667d94..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/build.go
+++ /dev/null
@@ -1,215 +0,0 @@
-package rest
-
-import (
- "bytes"
- "encoding/base64"
- "fmt"
- "io"
- "net/url"
- "path"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "github.com/awslabs/aws-sdk-go/aws"
-)
-
-// RFC822 returns an RFC822 formatted timestamp for AWS protocols
-const RFC822 = "Mon, 2 Jan 2006 15:04:05 GMT"
-
-func Build(r *aws.Request) {
- if r.ParamsFilled() {
- v := reflect.ValueOf(r.Params).Elem()
- buildLocationElements(r, v)
- buildBody(r, v)
- }
-}
-
-func buildLocationElements(r *aws.Request, v reflect.Value) {
- query := r.HTTPRequest.URL.Query()
-
- for i := 0; i < v.NumField(); i++ {
- m := v.Field(i)
- if n := v.Type().Field(i).Name; n[0:1] == strings.ToLower(n[0:1]) {
- continue
- }
-
- if m.IsValid() {
- field := v.Type().Field(i)
- name := field.Tag.Get("locationName")
- if name == "" {
- name = field.Name
- }
- if m.Kind() == reflect.Ptr {
- m = m.Elem()
- }
- if !m.IsValid() {
- continue
- }
-
- switch field.Tag.Get("location") {
- case "headers": // header maps
- buildHeaderMap(r, m, field.Tag.Get("locationName"))
- case "header":
- buildHeader(r, m, name)
- case "uri":
- buildURI(r, m, name)
- case "querystring":
- buildQueryString(r, m, name, query)
- }
- }
- if r.Error != nil {
- return
- }
- }
-
- r.HTTPRequest.URL.RawQuery = query.Encode()
- updatePath(r.HTTPRequest.URL, r.HTTPRequest.URL.Path)
-}
-
-func buildBody(r *aws.Request, v reflect.Value) {
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- pfield, _ := v.Type().FieldByName(payloadName)
- if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
- payload := reflect.Indirect(v.FieldByName(payloadName))
- if payload.IsValid() && payload.Interface() != nil {
- switch reader := payload.Interface().(type) {
- case io.ReadSeeker:
- r.SetReaderBody(reader)
- case []byte:
- r.SetBufferBody(reader)
- case string:
- r.SetBufferBody([]byte(reader))
- default:
- r.Error = fmt.Errorf("unknown payload type %s", payload.Type())
- }
- }
- }
- }
- }
-}
-
-func buildHeader(r *aws.Request, v reflect.Value, name string) {
- str, err := convertType(v)
- if err != nil {
- r.Error = err
- } else if str != nil {
- r.HTTPRequest.Header.Add(name, *str)
- }
-}
-
-func buildHeaderMap(r *aws.Request, v reflect.Value, prefix string) {
- for _, key := range v.MapKeys() {
- str, err := convertType(v.MapIndex(key))
-
- if err != nil {
- r.Error = err
- } else if str != nil {
- r.HTTPRequest.Header.Add(prefix+key.String(), *str)
- }
- }
-}
-
-func buildURI(r *aws.Request, v reflect.Value, name string) {
- value, err := convertType(v)
- if err != nil {
- r.Error = err
- } else if value != nil {
- uri := r.HTTPRequest.URL.Path
- uri = strings.Replace(uri, "{"+name+"}", escapePath(*value, true), -1)
- uri = strings.Replace(uri, "{"+name+"+}", escapePath(*value, false), -1)
- r.HTTPRequest.URL.Path = uri
- }
-}
-
-func buildQueryString(r *aws.Request, v reflect.Value, name string, query url.Values) {
- str, err := convertType(v)
- if err != nil {
- r.Error = err
- } else if str != nil {
- query.Set(name, *str)
- }
-}
-
-func updatePath(url *url.URL, urlPath string) {
- scheme, query := url.Scheme, url.RawQuery
-
- // clean up path
- urlPath = path.Clean(urlPath)
-
- // get formatted URL minus scheme so we can build this into Opaque
- url.Scheme, url.Path, url.RawQuery = "", "", ""
- s := url.String()
- url.Scheme = scheme
- url.RawQuery = query
-
- // build opaque URI
- url.Opaque = s + urlPath
-}
-
-// Whether the byte value can be sent without escaping in AWS URLs
-var noEscape [256]bool
-var noEscapeInitialized = false
-
-// initialise noEscape
-func initNoEscape() {
- for i := range noEscape {
- // Amazon expects every character except these escaped
- noEscape[i] = (i >= 'A' && i <= 'Z') ||
- (i >= 'a' && i <= 'z') ||
- (i >= '0' && i <= '9') ||
- i == '-' ||
- i == '.' ||
- i == '_' ||
- i == '~'
- }
-}
-
-// escapePath escapes part of a URL path in Amazon style
-func escapePath(path string, encodeSep bool) string {
- if !noEscapeInitialized {
- initNoEscape()
- noEscapeInitialized = true
- }
-
- var buf bytes.Buffer
- for i := 0; i < len(path); i++ {
- c := path[i]
- if noEscape[c] || (c == '/' && !encodeSep) {
- buf.WriteByte(c)
- } else {
- buf.WriteByte('%')
- buf.WriteString(strings.ToUpper(strconv.FormatUint(uint64(c), 16)))
- }
- }
- return buf.String()
-}
-
-func convertType(v reflect.Value) (*string, error) {
- v = reflect.Indirect(v)
- if !v.IsValid() {
- return nil, nil
- }
-
- var str string
- switch value := v.Interface().(type) {
- case string:
- str = value
- case []byte:
- str = base64.StdEncoding.EncodeToString(value)
- case bool:
- str = strconv.FormatBool(value)
- case int64:
- str = strconv.FormatInt(value, 10)
- case float64:
- str = strconv.FormatFloat(value, 'f', -1, 64)
- case time.Time:
- str = value.UTC().Format(RFC822)
- default:
- err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
- return nil, err
- }
- return &str, nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/payload.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/payload.go
deleted file mode 100644
index 1e15f66f7..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/payload.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package rest
-
-import "reflect"
-
-func PayloadMember(i interface{}) interface{} {
- if i == nil {
- return nil
- }
-
- v := reflect.ValueOf(i).Elem()
- if !v.IsValid() {
- return nil
- }
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- field, _ := v.Type().FieldByName(payloadName)
- if field.Tag.Get("type") != "structure" {
- return nil
- }
-
- payload := v.FieldByName(payloadName)
- if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) {
- return payload.Interface()
- }
- }
- }
- return nil
-}
-
-func PayloadType(i interface{}) string {
- v := reflect.Indirect(reflect.ValueOf(i))
- if !v.IsValid() {
- return ""
- }
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- if member, ok := v.Type().FieldByName(payloadName); ok {
- return member.Tag.Get("type")
- }
- }
- }
- return ""
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/unmarshal.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/unmarshal.go
deleted file mode 100644
index d0e216c1e..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/rest/unmarshal.go
+++ /dev/null
@@ -1,174 +0,0 @@
-package rest
-
-import (
- "encoding/base64"
- "fmt"
- "io/ioutil"
- "net/http"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "github.com/awslabs/aws-sdk-go/aws"
-)
-
-func Unmarshal(r *aws.Request) {
- if r.DataFilled() {
- v := reflect.Indirect(reflect.ValueOf(r.Data))
- unmarshalBody(r, v)
- unmarshalLocationElements(r, v)
- }
-}
-
-func unmarshalBody(r *aws.Request, v reflect.Value) {
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- pfield, _ := v.Type().FieldByName(payloadName)
- if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
- payload := reflect.Indirect(v.FieldByName(payloadName))
- if payload.IsValid() {
- switch payload.Interface().(type) {
- case []byte:
- b, err := ioutil.ReadAll(r.HTTPResponse.Body)
- if err != nil {
- r.Error = err
- } else {
- payload.Set(reflect.ValueOf(b))
- }
- case string:
- b, err := ioutil.ReadAll(r.HTTPResponse.Body)
- if err != nil {
- r.Error = err
- } else {
- payload.Set(reflect.ValueOf(string(b)))
- }
- default:
- switch payload.Type().String() {
- case "io.ReadSeeker":
- payload.Set(reflect.ValueOf(aws.ReadSeekCloser(r.HTTPResponse.Body)))
- case "aws.ReadSeekCloser", "io.ReadCloser":
- payload.Set(reflect.ValueOf(r.HTTPResponse.Body))
- default:
- r.Error = fmt.Errorf("unknown payload type %s", payload.Type())
- }
- }
- }
- }
- }
- }
-}
-
-func unmarshalLocationElements(r *aws.Request, v reflect.Value) {
- for i := 0; i < v.NumField(); i++ {
- m, field := v.Field(i), v.Type().Field(i)
- if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) {
- continue
- }
-
- if m.IsValid() {
- name := field.Tag.Get("locationName")
- if name == "" {
- name = field.Name
- }
-
- switch field.Tag.Get("location") {
- case "statusCode":
- unmarshalStatusCode(m, r.HTTPResponse.StatusCode)
- case "header":
- err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name))
- if err != nil {
- r.Error = err
- break
- }
- case "headers":
- prefix := field.Tag.Get("locationName")
- err := unmarshalHeaderMap(m, r.HTTPResponse.Header, prefix)
- if err != nil {
- r.Error = err
- break
- }
- }
- }
- if r.Error != nil {
- return
- }
- }
-}
-
-func unmarshalStatusCode(v reflect.Value, statusCode int) {
- if !v.IsValid() {
- return
- }
-
- switch v.Interface().(type) {
- case *int64:
- s := int64(statusCode)
- v.Set(reflect.ValueOf(&s))
- }
-}
-
-func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error {
- switch r.Interface().(type) {
- case *map[string]*string: // we only support string map value types
- out := map[string]*string{}
- for k, v := range headers {
- k = http.CanonicalHeaderKey(k)
- if strings.HasPrefix(strings.ToLower(k), strings.ToLower(prefix)) {
- out[k[len(prefix):]] = &v[0]
- }
- }
- r.Set(reflect.ValueOf(&out))
- }
- return nil
-}
-
-func unmarshalHeader(v reflect.Value, header string) error {
- if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) {
- return nil
- }
-
- switch v.Interface().(type) {
- case *string:
- v.Set(reflect.ValueOf(&header))
- case []byte:
- b, err := base64.StdEncoding.DecodeString(header)
- if err != nil {
- return err
- } else {
- v.Set(reflect.ValueOf(&b))
- }
- case *bool:
- b, err := strconv.ParseBool(header)
- if err != nil {
- return err
- } else {
- v.Set(reflect.ValueOf(&b))
- }
- case *int64:
- i, err := strconv.ParseInt(header, 10, 64)
- if err != nil {
- return err
- } else {
- v.Set(reflect.ValueOf(&i))
- }
- case *float64:
- f, err := strconv.ParseFloat(header, 64)
- if err != nil {
- return err
- } else {
- v.Set(reflect.ValueOf(&f))
- }
- case *time.Time:
- t, err := time.Parse(RFC822, header)
- if err != nil {
- return err
- } else {
- v.Set(reflect.ValueOf(&t))
- }
- default:
- err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
- return err
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/build_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/build_test.go
deleted file mode 100644
index 48d72ca53..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/build_test.go
+++ /dev/null
@@ -1,2571 +0,0 @@
-package restxml_test
-
-import (
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/restxml"
- "github.com/awslabs/aws-sdk-go/internal/signer/v4"
-
- "bytes"
- "encoding/json"
- "encoding/xml"
- "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil"
- "github.com/awslabs/aws-sdk-go/internal/util"
- "github.com/stretchr/testify/assert"
- "io/ioutil"
- "net/http"
- "net/url"
- "testing"
- "time"
-)
-
-var _ bytes.Buffer // always import bytes
-var _ http.Request
-var _ json.Marshaler
-var _ time.Time
-var _ xmlutil.XMLNode
-var _ xml.Attr
-var _ = ioutil.Discard
-var _ = util.Trim("")
-var _ = url.Values{}
-
-// InputService1ProtocolTest is a client for InputService1ProtocolTest.
-type InputService1ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService1ProtocolTest client.
-func NewInputService1ProtocolTest(config *aws.Config) *InputService1ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice1protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService1ProtocolTest{service}
-}
-
-// InputService1TestCaseOperation1Request generates a request for the InputService1TestCaseOperation1 operation.
-func (c *InputService1ProtocolTest) InputService1TestCaseOperation1Request(input *InputService1TestShapeInputShape) (req *aws.Request, output *InputService1TestShapeInputService1TestCaseOperation1Output) {
- if opInputService1TestCaseOperation1 == nil {
- opInputService1TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService1TestCaseOperation1, input, output)
- output = &InputService1TestShapeInputService1TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService1ProtocolTest) InputService1TestCaseOperation1(input *InputService1TestShapeInputShape) (output *InputService1TestShapeInputService1TestCaseOperation1Output, err error) {
- req, out := c.InputService1TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService1TestCaseOperation1 *aws.Operation
-
-// InputService1TestCaseOperation2Request generates a request for the InputService1TestCaseOperation2 operation.
-func (c *InputService1ProtocolTest) InputService1TestCaseOperation2Request(input *InputService1TestShapeInputShape) (req *aws.Request, output *InputService1TestShapeInputService1TestCaseOperation2Output) {
- if opInputService1TestCaseOperation2 == nil {
- opInputService1TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "PUT",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService1TestCaseOperation2, input, output)
- output = &InputService1TestShapeInputService1TestCaseOperation2Output{}
- req.Data = output
- return
-}
-
-func (c *InputService1ProtocolTest) InputService1TestCaseOperation2(input *InputService1TestShapeInputShape) (output *InputService1TestShapeInputService1TestCaseOperation2Output, err error) {
- req, out := c.InputService1TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService1TestCaseOperation2 *aws.Operation
-
-type InputService1TestShapeInputService1TestCaseOperation1Output struct {
- metadataInputService1TestShapeInputService1TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService1TestShapeInputService1TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService1TestShapeInputService1TestCaseOperation2Output struct {
- metadataInputService1TestShapeInputService1TestCaseOperation2Output `json:"-", xml:"-"`
-}
-
-type metadataInputService1TestShapeInputService1TestCaseOperation2Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService1TestShapeInputShape struct {
- Description *string `type:"string"`
-
- Name *string `type:"string"`
-
- metadataInputService1TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService1TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService2ProtocolTest is a client for InputService2ProtocolTest.
-type InputService2ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService2ProtocolTest client.
-func NewInputService2ProtocolTest(config *aws.Config) *InputService2ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice2protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService2ProtocolTest{service}
-}
-
-// InputService2TestCaseOperation1Request generates a request for the InputService2TestCaseOperation1 operation.
-func (c *InputService2ProtocolTest) InputService2TestCaseOperation1Request(input *InputService2TestShapeInputShape) (req *aws.Request, output *InputService2TestShapeInputService2TestCaseOperation1Output) {
- if opInputService2TestCaseOperation1 == nil {
- opInputService2TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService2TestCaseOperation1, input, output)
- output = &InputService2TestShapeInputService2TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService2ProtocolTest) InputService2TestCaseOperation1(input *InputService2TestShapeInputShape) (output *InputService2TestShapeInputService2TestCaseOperation1Output, err error) {
- req, out := c.InputService2TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService2TestCaseOperation1 *aws.Operation
-
-type InputService2TestShapeInputService2TestCaseOperation1Output struct {
- metadataInputService2TestShapeInputService2TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService2TestShapeInputService2TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService2TestShapeInputShape struct {
- First *bool `type:"boolean"`
-
- Fourth *int64 `type:"integer"`
-
- Second *bool `type:"boolean"`
-
- Third *float64 `type:"float"`
-
- metadataInputService2TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService2TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService3ProtocolTest is a client for InputService3ProtocolTest.
-type InputService3ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService3ProtocolTest client.
-func NewInputService3ProtocolTest(config *aws.Config) *InputService3ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice3protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService3ProtocolTest{service}
-}
-
-// InputService3TestCaseOperation1Request generates a request for the InputService3TestCaseOperation1 operation.
-func (c *InputService3ProtocolTest) InputService3TestCaseOperation1Request(input *InputService3TestShapeInputShape) (req *aws.Request, output *InputService3TestShapeInputService3TestCaseOperation1Output) {
- if opInputService3TestCaseOperation1 == nil {
- opInputService3TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService3TestCaseOperation1, input, output)
- output = &InputService3TestShapeInputService3TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService3ProtocolTest) InputService3TestCaseOperation1(input *InputService3TestShapeInputShape) (output *InputService3TestShapeInputService3TestCaseOperation1Output, err error) {
- req, out := c.InputService3TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService3TestCaseOperation1 *aws.Operation
-
-type InputService3TestShapeInputService3TestCaseOperation1Output struct {
- metadataInputService3TestShapeInputService3TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService3TestShapeInputService3TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService3TestShapeInputShape struct {
- Description *string `type:"string"`
-
- SubStructure *InputService3TestShapeSubStructure `type:"structure"`
-
- metadataInputService3TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService3TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-type InputService3TestShapeSubStructure struct {
- Bar *string `type:"string"`
-
- Foo *string `type:"string"`
-
- metadataInputService3TestShapeSubStructure `json:"-", xml:"-"`
-}
-
-type metadataInputService3TestShapeSubStructure struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService4ProtocolTest is a client for InputService4ProtocolTest.
-type InputService4ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService4ProtocolTest client.
-func NewInputService4ProtocolTest(config *aws.Config) *InputService4ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice4protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService4ProtocolTest{service}
-}
-
-// InputService4TestCaseOperation1Request generates a request for the InputService4TestCaseOperation1 operation.
-func (c *InputService4ProtocolTest) InputService4TestCaseOperation1Request(input *InputService4TestShapeInputShape) (req *aws.Request, output *InputService4TestShapeInputService4TestCaseOperation1Output) {
- if opInputService4TestCaseOperation1 == nil {
- opInputService4TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService4TestCaseOperation1, input, output)
- output = &InputService4TestShapeInputService4TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService4ProtocolTest) InputService4TestCaseOperation1(input *InputService4TestShapeInputShape) (output *InputService4TestShapeInputService4TestCaseOperation1Output, err error) {
- req, out := c.InputService4TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService4TestCaseOperation1 *aws.Operation
-
-type InputService4TestShapeInputService4TestCaseOperation1Output struct {
- metadataInputService4TestShapeInputService4TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService4TestShapeInputService4TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService4TestShapeInputShape struct {
- Description *string `type:"string"`
-
- SubStructure *InputService4TestShapeSubStructure `type:"structure"`
-
- metadataInputService4TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService4TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-type InputService4TestShapeSubStructure struct {
- Bar *string `type:"string"`
-
- Foo *string `type:"string"`
-
- metadataInputService4TestShapeSubStructure `json:"-", xml:"-"`
-}
-
-type metadataInputService4TestShapeSubStructure struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService5ProtocolTest is a client for InputService5ProtocolTest.
-type InputService5ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService5ProtocolTest client.
-func NewInputService5ProtocolTest(config *aws.Config) *InputService5ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice5protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService5ProtocolTest{service}
-}
-
-// InputService5TestCaseOperation1Request generates a request for the InputService5TestCaseOperation1 operation.
-func (c *InputService5ProtocolTest) InputService5TestCaseOperation1Request(input *InputService5TestShapeInputShape) (req *aws.Request, output *InputService5TestShapeInputService5TestCaseOperation1Output) {
- if opInputService5TestCaseOperation1 == nil {
- opInputService5TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService5TestCaseOperation1, input, output)
- output = &InputService5TestShapeInputService5TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService5ProtocolTest) InputService5TestCaseOperation1(input *InputService5TestShapeInputShape) (output *InputService5TestShapeInputService5TestCaseOperation1Output, err error) {
- req, out := c.InputService5TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService5TestCaseOperation1 *aws.Operation
-
-type InputService5TestShapeInputService5TestCaseOperation1Output struct {
- metadataInputService5TestShapeInputService5TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService5TestShapeInputService5TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService5TestShapeInputShape struct {
- ListParam []*string `type:"list"`
-
- metadataInputService5TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService5TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService6ProtocolTest is a client for InputService6ProtocolTest.
-type InputService6ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService6ProtocolTest client.
-func NewInputService6ProtocolTest(config *aws.Config) *InputService6ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice6protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService6ProtocolTest{service}
-}
-
-// InputService6TestCaseOperation1Request generates a request for the InputService6TestCaseOperation1 operation.
-func (c *InputService6ProtocolTest) InputService6TestCaseOperation1Request(input *InputService6TestShapeInputShape) (req *aws.Request, output *InputService6TestShapeInputService6TestCaseOperation1Output) {
- if opInputService6TestCaseOperation1 == nil {
- opInputService6TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService6TestCaseOperation1, input, output)
- output = &InputService6TestShapeInputService6TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService6ProtocolTest) InputService6TestCaseOperation1(input *InputService6TestShapeInputShape) (output *InputService6TestShapeInputService6TestCaseOperation1Output, err error) {
- req, out := c.InputService6TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService6TestCaseOperation1 *aws.Operation
-
-type InputService6TestShapeInputService6TestCaseOperation1Output struct {
- metadataInputService6TestShapeInputService6TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService6TestShapeInputService6TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService6TestShapeInputShape struct {
- ListParam []*string `locationName:"AlternateName" locationNameList:"NotMember" type:"list"`
-
- metadataInputService6TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService6TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService7ProtocolTest is a client for InputService7ProtocolTest.
-type InputService7ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService7ProtocolTest client.
-func NewInputService7ProtocolTest(config *aws.Config) *InputService7ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice7protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService7ProtocolTest{service}
-}
-
-// InputService7TestCaseOperation1Request generates a request for the InputService7TestCaseOperation1 operation.
-func (c *InputService7ProtocolTest) InputService7TestCaseOperation1Request(input *InputService7TestShapeInputShape) (req *aws.Request, output *InputService7TestShapeInputService7TestCaseOperation1Output) {
- if opInputService7TestCaseOperation1 == nil {
- opInputService7TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService7TestCaseOperation1, input, output)
- output = &InputService7TestShapeInputService7TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService7ProtocolTest) InputService7TestCaseOperation1(input *InputService7TestShapeInputShape) (output *InputService7TestShapeInputService7TestCaseOperation1Output, err error) {
- req, out := c.InputService7TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService7TestCaseOperation1 *aws.Operation
-
-type InputService7TestShapeInputService7TestCaseOperation1Output struct {
- metadataInputService7TestShapeInputService7TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService7TestShapeInputService7TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService7TestShapeInputShape struct {
- ListParam []*string `type:"list" flattened:"true"`
-
- metadataInputService7TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService7TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService8ProtocolTest is a client for InputService8ProtocolTest.
-type InputService8ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService8ProtocolTest client.
-func NewInputService8ProtocolTest(config *aws.Config) *InputService8ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice8protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService8ProtocolTest{service}
-}
-
-// InputService8TestCaseOperation1Request generates a request for the InputService8TestCaseOperation1 operation.
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation1Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation1Output) {
- if opInputService8TestCaseOperation1 == nil {
- opInputService8TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService8TestCaseOperation1, input, output)
- output = &InputService8TestShapeInputService8TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService8ProtocolTest) InputService8TestCaseOperation1(input *InputService8TestShapeInputShape) (output *InputService8TestShapeInputService8TestCaseOperation1Output, err error) {
- req, out := c.InputService8TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService8TestCaseOperation1 *aws.Operation
-
-type InputService8TestShapeInputService8TestCaseOperation1Output struct {
- metadataInputService8TestShapeInputService8TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputService8TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService8TestShapeInputShape struct {
- ListParam []*string `locationName:"item" type:"list" flattened:"true"`
-
- metadataInputService8TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService8TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService9ProtocolTest is a client for InputService9ProtocolTest.
-type InputService9ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService9ProtocolTest client.
-func NewInputService9ProtocolTest(config *aws.Config) *InputService9ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice9protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService9ProtocolTest{service}
-}
-
-// InputService9TestCaseOperation1Request generates a request for the InputService9TestCaseOperation1 operation.
-func (c *InputService9ProtocolTest) InputService9TestCaseOperation1Request(input *InputService9TestShapeInputShape) (req *aws.Request, output *InputService9TestShapeInputService9TestCaseOperation1Output) {
- if opInputService9TestCaseOperation1 == nil {
- opInputService9TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService9TestCaseOperation1, input, output)
- output = &InputService9TestShapeInputService9TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService9ProtocolTest) InputService9TestCaseOperation1(input *InputService9TestShapeInputShape) (output *InputService9TestShapeInputService9TestCaseOperation1Output, err error) {
- req, out := c.InputService9TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService9TestCaseOperation1 *aws.Operation
-
-type InputService9TestShapeInputService9TestCaseOperation1Output struct {
- metadataInputService9TestShapeInputService9TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService9TestShapeInputService9TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService9TestShapeInputShape struct {
- ListParam []*InputService9TestShapeSingleFieldStruct `locationName:"item" type:"list" flattened:"true"`
-
- metadataInputService9TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService9TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-type InputService9TestShapeSingleFieldStruct struct {
- Element *string `locationName:"value" type:"string"`
-
- metadataInputService9TestShapeSingleFieldStruct `json:"-", xml:"-"`
-}
-
-type metadataInputService9TestShapeSingleFieldStruct struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService10ProtocolTest is a client for InputService10ProtocolTest.
-type InputService10ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService10ProtocolTest client.
-func NewInputService10ProtocolTest(config *aws.Config) *InputService10ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice10protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService10ProtocolTest{service}
-}
-
-// InputService10TestCaseOperation1Request generates a request for the InputService10TestCaseOperation1 operation.
-func (c *InputService10ProtocolTest) InputService10TestCaseOperation1Request(input *InputService10TestShapeInputShape) (req *aws.Request, output *InputService10TestShapeInputService10TestCaseOperation1Output) {
- if opInputService10TestCaseOperation1 == nil {
- opInputService10TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/2014-01-01/hostedzone",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService10TestCaseOperation1, input, output)
- output = &InputService10TestShapeInputService10TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService10ProtocolTest) InputService10TestCaseOperation1(input *InputService10TestShapeInputShape) (output *InputService10TestShapeInputService10TestCaseOperation1Output, err error) {
- req, out := c.InputService10TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService10TestCaseOperation1 *aws.Operation
-
-type InputService10TestShapeInputService10TestCaseOperation1Output struct {
- metadataInputService10TestShapeInputService10TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService10TestShapeInputService10TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService10TestShapeInputShape struct {
- StructureParam *InputService10TestShapeStructureShape `type:"structure"`
-
- metadataInputService10TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService10TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-type InputService10TestShapeStructureShape struct {
- B []byte `locationName:"b" type:"blob"`
-
- T *time.Time `locationName:"t" type:"timestamp" timestampFormat:"iso8601"`
-
- metadataInputService10TestShapeStructureShape `json:"-", xml:"-"`
-}
-
-type metadataInputService10TestShapeStructureShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService11ProtocolTest is a client for InputService11ProtocolTest.
-type InputService11ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService11ProtocolTest client.
-func NewInputService11ProtocolTest(config *aws.Config) *InputService11ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice11protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService11ProtocolTest{service}
-}
-
-// InputService11TestCaseOperation1Request generates a request for the InputService11TestCaseOperation1 operation.
-func (c *InputService11ProtocolTest) InputService11TestCaseOperation1Request(input *InputService11TestShapeInputShape) (req *aws.Request, output *InputService11TestShapeInputService11TestCaseOperation1Output) {
- if opInputService11TestCaseOperation1 == nil {
- opInputService11TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService11TestCaseOperation1, input, output)
- output = &InputService11TestShapeInputService11TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService11ProtocolTest) InputService11TestCaseOperation1(input *InputService11TestShapeInputShape) (output *InputService11TestShapeInputService11TestCaseOperation1Output, err error) {
- req, out := c.InputService11TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService11TestCaseOperation1 *aws.Operation
-
-type InputService11TestShapeInputService11TestCaseOperation1Output struct {
- metadataInputService11TestShapeInputService11TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService11TestShapeInputService11TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService11TestShapeInputShape struct {
- Foo *map[string]*string `location:"headers" locationName:"x-foo-" type:"map"`
-
- metadataInputService11TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService11TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-// InputService12ProtocolTest is a client for InputService12ProtocolTest.
-type InputService12ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService12ProtocolTest client.
-func NewInputService12ProtocolTest(config *aws.Config) *InputService12ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice12protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService12ProtocolTest{service}
-}
-
-// InputService12TestCaseOperation1Request generates a request for the InputService12TestCaseOperation1 operation.
-func (c *InputService12ProtocolTest) InputService12TestCaseOperation1Request(input *InputService12TestShapeInputShape) (req *aws.Request, output *InputService12TestShapeInputService12TestCaseOperation1Output) {
- if opInputService12TestCaseOperation1 == nil {
- opInputService12TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService12TestCaseOperation1, input, output)
- output = &InputService12TestShapeInputService12TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService12ProtocolTest) InputService12TestCaseOperation1(input *InputService12TestShapeInputShape) (output *InputService12TestShapeInputService12TestCaseOperation1Output, err error) {
- req, out := c.InputService12TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService12TestCaseOperation1 *aws.Operation
-
-type InputService12TestShapeInputService12TestCaseOperation1Output struct {
- metadataInputService12TestShapeInputService12TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService12TestShapeInputService12TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService12TestShapeInputShape struct {
- Foo *string `locationName:"foo" type:"string"`
-
- metadataInputService12TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService12TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure" payload:"Foo"`
-}
-
-// InputService13ProtocolTest is a client for InputService13ProtocolTest.
-type InputService13ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService13ProtocolTest client.
-func NewInputService13ProtocolTest(config *aws.Config) *InputService13ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice13protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService13ProtocolTest{service}
-}
-
-// InputService13TestCaseOperation1Request generates a request for the InputService13TestCaseOperation1 operation.
-func (c *InputService13ProtocolTest) InputService13TestCaseOperation1Request(input *InputService13TestShapeInputShape) (req *aws.Request, output *InputService13TestShapeInputService13TestCaseOperation1Output) {
- if opInputService13TestCaseOperation1 == nil {
- opInputService13TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService13TestCaseOperation1, input, output)
- output = &InputService13TestShapeInputService13TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService13ProtocolTest) InputService13TestCaseOperation1(input *InputService13TestShapeInputShape) (output *InputService13TestShapeInputService13TestCaseOperation1Output, err error) {
- req, out := c.InputService13TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService13TestCaseOperation1 *aws.Operation
-
-// InputService13TestCaseOperation2Request generates a request for the InputService13TestCaseOperation2 operation.
-func (c *InputService13ProtocolTest) InputService13TestCaseOperation2Request(input *InputService13TestShapeInputShape) (req *aws.Request, output *InputService13TestShapeInputService13TestCaseOperation2Output) {
- if opInputService13TestCaseOperation2 == nil {
- opInputService13TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService13TestCaseOperation2, input, output)
- output = &InputService13TestShapeInputService13TestCaseOperation2Output{}
- req.Data = output
- return
-}
-
-func (c *InputService13ProtocolTest) InputService13TestCaseOperation2(input *InputService13TestShapeInputShape) (output *InputService13TestShapeInputService13TestCaseOperation2Output, err error) {
- req, out := c.InputService13TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService13TestCaseOperation2 *aws.Operation
-
-type InputService13TestShapeInputService13TestCaseOperation1Output struct {
- metadataInputService13TestShapeInputService13TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService13TestShapeInputService13TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService13TestShapeInputService13TestCaseOperation2Output struct {
- metadataInputService13TestShapeInputService13TestCaseOperation2Output `json:"-", xml:"-"`
-}
-
-type metadataInputService13TestShapeInputService13TestCaseOperation2Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService13TestShapeInputShape struct {
- Foo []byte `locationName:"foo" type:"blob"`
-
- metadataInputService13TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService13TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure" payload:"Foo"`
-}
-
-// InputService14ProtocolTest is a client for InputService14ProtocolTest.
-type InputService14ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService14ProtocolTest client.
-func NewInputService14ProtocolTest(config *aws.Config) *InputService14ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice14protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService14ProtocolTest{service}
-}
-
-// InputService14TestCaseOperation1Request generates a request for the InputService14TestCaseOperation1 operation.
-func (c *InputService14ProtocolTest) InputService14TestCaseOperation1Request(input *InputService14TestShapeInputShape) (req *aws.Request, output *InputService14TestShapeInputService14TestCaseOperation1Output) {
- if opInputService14TestCaseOperation1 == nil {
- opInputService14TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService14TestCaseOperation1, input, output)
- output = &InputService14TestShapeInputService14TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService14ProtocolTest) InputService14TestCaseOperation1(input *InputService14TestShapeInputShape) (output *InputService14TestShapeInputService14TestCaseOperation1Output, err error) {
- req, out := c.InputService14TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService14TestCaseOperation1 *aws.Operation
-
-// InputService14TestCaseOperation2Request generates a request for the InputService14TestCaseOperation2 operation.
-func (c *InputService14ProtocolTest) InputService14TestCaseOperation2Request(input *InputService14TestShapeInputShape) (req *aws.Request, output *InputService14TestShapeInputService14TestCaseOperation2Output) {
- if opInputService14TestCaseOperation2 == nil {
- opInputService14TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService14TestCaseOperation2, input, output)
- output = &InputService14TestShapeInputService14TestCaseOperation2Output{}
- req.Data = output
- return
-}
-
-func (c *InputService14ProtocolTest) InputService14TestCaseOperation2(input *InputService14TestShapeInputShape) (output *InputService14TestShapeInputService14TestCaseOperation2Output, err error) {
- req, out := c.InputService14TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService14TestCaseOperation2 *aws.Operation
-
-type InputService14TestShapeFooShape struct {
- Baz *string `locationName:"baz" type:"string"`
-
- metadataInputService14TestShapeFooShape `json:"-", xml:"-"`
-}
-
-type metadataInputService14TestShapeFooShape struct {
- SDKShapeTraits bool `locationName:"foo" type:"structure"`
-}
-
-type InputService14TestShapeInputService14TestCaseOperation1Output struct {
- metadataInputService14TestShapeInputService14TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService14TestShapeInputService14TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService14TestShapeInputService14TestCaseOperation2Output struct {
- metadataInputService14TestShapeInputService14TestCaseOperation2Output `json:"-", xml:"-"`
-}
-
-type metadataInputService14TestShapeInputService14TestCaseOperation2Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService14TestShapeInputShape struct {
- Foo *InputService14TestShapeFooShape `locationName:"foo" type:"structure"`
-
- metadataInputService14TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService14TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure" payload:"Foo"`
-}
-
-// InputService15ProtocolTest is a client for InputService15ProtocolTest.
-type InputService15ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService15ProtocolTest client.
-func NewInputService15ProtocolTest(config *aws.Config) *InputService15ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice15protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService15ProtocolTest{service}
-}
-
-// InputService15TestCaseOperation1Request generates a request for the InputService15TestCaseOperation1 operation.
-func (c *InputService15ProtocolTest) InputService15TestCaseOperation1Request(input *InputService15TestShapeInputShape) (req *aws.Request, output *InputService15TestShapeInputService15TestCaseOperation1Output) {
- if opInputService15TestCaseOperation1 == nil {
- opInputService15TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService15TestCaseOperation1, input, output)
- output = &InputService15TestShapeInputService15TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService15ProtocolTest) InputService15TestCaseOperation1(input *InputService15TestShapeInputShape) (output *InputService15TestShapeInputService15TestCaseOperation1Output, err error) {
- req, out := c.InputService15TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService15TestCaseOperation1 *aws.Operation
-
-type InputService15TestShapeGrant struct {
- Grantee *InputService15TestShapeGrantee `type:"structure"`
-
- metadataInputService15TestShapeGrant `json:"-", xml:"-"`
-}
-
-type metadataInputService15TestShapeGrant struct {
- SDKShapeTraits bool `locationName:"Grant" type:"structure"`
-}
-
-type InputService15TestShapeGrantee struct {
- EmailAddress *string `type:"string"`
-
- Type *string `locationName:"xsi:type" type:"string" xmlAttribute:"true"`
-
- metadataInputService15TestShapeGrantee `json:"-", xml:"-"`
-}
-
-type metadataInputService15TestShapeGrantee struct {
- SDKShapeTraits bool `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"`
-}
-
-type InputService15TestShapeInputService15TestCaseOperation1Output struct {
- metadataInputService15TestShapeInputService15TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService15TestShapeInputService15TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService15TestShapeInputShape struct {
- Grant *InputService15TestShapeGrant `locationName:"Grant" type:"structure"`
-
- metadataInputService15TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService15TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure" payload:"Grant"`
-}
-
-// InputService16ProtocolTest is a client for InputService16ProtocolTest.
-type InputService16ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService16ProtocolTest client.
-func NewInputService16ProtocolTest(config *aws.Config) *InputService16ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice16protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService16ProtocolTest{service}
-}
-
-// InputService16TestCaseOperation1Request generates a request for the InputService16TestCaseOperation1 operation.
-func (c *InputService16ProtocolTest) InputService16TestCaseOperation1Request(input *InputService16TestShapeInputShape) (req *aws.Request, output *InputService16TestShapeInputService16TestCaseOperation1Output) {
- if opInputService16TestCaseOperation1 == nil {
- opInputService16TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService16TestCaseOperation1, input, output)
- output = &InputService16TestShapeInputService16TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService16ProtocolTest) InputService16TestCaseOperation1(input *InputService16TestShapeInputShape) (output *InputService16TestShapeInputService16TestCaseOperation1Output, err error) {
- req, out := c.InputService16TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService16TestCaseOperation1 *aws.Operation
-
-type InputService16TestShapeInputService16TestCaseOperation1Output struct {
- metadataInputService16TestShapeInputService16TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService16TestShapeInputService16TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService16TestShapeInputShape struct {
- Bucket *string `location:"uri" type:"string"`
-
- Key *string `location:"uri" type:"string"`
-
- metadataInputService16TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService16TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService17ProtocolTest is a client for InputService17ProtocolTest.
-type InputService17ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService17ProtocolTest client.
-func NewInputService17ProtocolTest(config *aws.Config) *InputService17ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice17protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService17ProtocolTest{service}
-}
-
-// InputService17TestCaseOperation1Request generates a request for the InputService17TestCaseOperation1 operation.
-func (c *InputService17ProtocolTest) InputService17TestCaseOperation1Request(input *InputService17TestShapeInputShape) (req *aws.Request, output *InputService17TestShapeInputService17TestCaseOperation1Output) {
- if opInputService17TestCaseOperation1 == nil {
- opInputService17TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService17TestCaseOperation1, input, output)
- output = &InputService17TestShapeInputService17TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService17ProtocolTest) InputService17TestCaseOperation1(input *InputService17TestShapeInputShape) (output *InputService17TestShapeInputService17TestCaseOperation1Output, err error) {
- req, out := c.InputService17TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService17TestCaseOperation1 *aws.Operation
-
-// InputService17TestCaseOperation2Request generates a request for the InputService17TestCaseOperation2 operation.
-func (c *InputService17ProtocolTest) InputService17TestCaseOperation2Request(input *InputService17TestShapeInputShape) (req *aws.Request, output *InputService17TestShapeInputService17TestCaseOperation2Output) {
- if opInputService17TestCaseOperation2 == nil {
- opInputService17TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path?abc=mno",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService17TestCaseOperation2, input, output)
- output = &InputService17TestShapeInputService17TestCaseOperation2Output{}
- req.Data = output
- return
-}
-
-func (c *InputService17ProtocolTest) InputService17TestCaseOperation2(input *InputService17TestShapeInputShape) (output *InputService17TestShapeInputService17TestCaseOperation2Output, err error) {
- req, out := c.InputService17TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService17TestCaseOperation2 *aws.Operation
-
-type InputService17TestShapeInputService17TestCaseOperation1Output struct {
- metadataInputService17TestShapeInputService17TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService17TestShapeInputService17TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService17TestShapeInputService17TestCaseOperation2Output struct {
- metadataInputService17TestShapeInputService17TestCaseOperation2Output `json:"-", xml:"-"`
-}
-
-type metadataInputService17TestShapeInputService17TestCaseOperation2Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService17TestShapeInputShape struct {
- Foo *string `location:"querystring" locationName:"param-name" type:"string"`
-
- metadataInputService17TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService17TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService18ProtocolTest is a client for InputService18ProtocolTest.
-type InputService18ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService18ProtocolTest client.
-func NewInputService18ProtocolTest(config *aws.Config) *InputService18ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice18protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService18ProtocolTest{service}
-}
-
-// InputService18TestCaseOperation1Request generates a request for the InputService18TestCaseOperation1 operation.
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation1Request(input *InputService18TestShapeInputShape) (req *aws.Request, output *InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation1Output) {
- if opInputService18TestCaseOperation1 == nil {
- opInputService18TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService18TestCaseOperation1, input, output)
- output = &InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation1(input *InputService18TestShapeInputShape) (output *InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation1Output, err error) {
- req, out := c.InputService18TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService18TestCaseOperation1 *aws.Operation
-
-// InputService18TestCaseOperation2Request generates a request for the InputService18TestCaseOperation2 operation.
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation2Request(input *InputService18TestShapeInputShape) (req *aws.Request, output *InputService18TestShapeInputService18TestCaseOperation2Output) {
- if opInputService18TestCaseOperation2 == nil {
- opInputService18TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService18TestCaseOperation2, input, output)
- output = &InputService18TestShapeInputService18TestCaseOperation2Output{}
- req.Data = output
- return
-}
-
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation2(input *InputService18TestShapeInputShape) (output *InputService18TestShapeInputService18TestCaseOperation2Output, err error) {
- req, out := c.InputService18TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService18TestCaseOperation2 *aws.Operation
-
-// InputService18TestCaseOperation3Request generates a request for the InputService18TestCaseOperation3 operation.
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation3Request(input *InputService18TestShapeInputShape) (req *aws.Request, output *InputService18TestShapeInputService18TestCaseOperation3Output) {
- if opInputService18TestCaseOperation3 == nil {
- opInputService18TestCaseOperation3 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService18TestCaseOperation3, input, output)
- output = &InputService18TestShapeInputService18TestCaseOperation3Output{}
- req.Data = output
- return
-}
-
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation3(input *InputService18TestShapeInputShape) (output *InputService18TestShapeInputService18TestCaseOperation3Output, err error) {
- req, out := c.InputService18TestCaseOperation3Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService18TestCaseOperation3 *aws.Operation
-
-// InputService18TestCaseOperation4Request generates a request for the InputService18TestCaseOperation4 operation.
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation4Request(input *InputService18TestShapeInputShape) (req *aws.Request, output *InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation4Output) {
- if opInputService18TestCaseOperation4 == nil {
- opInputService18TestCaseOperation4 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService18TestCaseOperation4, input, output)
- output = &InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation4Output{}
- req.Data = output
- return
-}
-
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation4(input *InputService18TestShapeInputShape) (output *InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation4Output, err error) {
- req, out := c.InputService18TestCaseOperation4Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService18TestCaseOperation4 *aws.Operation
-
-// InputService18TestCaseOperation5Request generates a request for the InputService18TestCaseOperation5 operation.
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation5Request(input *InputService18TestShapeInputShape) (req *aws.Request, output *InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation5Output) {
- if opInputService18TestCaseOperation5 == nil {
- opInputService18TestCaseOperation5 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService18TestCaseOperation5, input, output)
- output = &InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation5Output{}
- req.Data = output
- return
-}
-
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation5(input *InputService18TestShapeInputShape) (output *InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation5Output, err error) {
- req, out := c.InputService18TestCaseOperation5Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService18TestCaseOperation5 *aws.Operation
-
-// InputService18TestCaseOperation6Request generates a request for the InputService18TestCaseOperation6 operation.
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation6Request(input *InputService18TestShapeInputShape) (req *aws.Request, output *InputService18TestShapeInputService18TestCaseOperation6Output) {
- if opInputService18TestCaseOperation6 == nil {
- opInputService18TestCaseOperation6 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService18TestCaseOperation6, input, output)
- output = &InputService18TestShapeInputService18TestCaseOperation6Output{}
- req.Data = output
- return
-}
-
-func (c *InputService18ProtocolTest) InputService18TestCaseOperation6(input *InputService18TestShapeInputShape) (output *InputService18TestShapeInputService18TestCaseOperation6Output, err error) {
- req, out := c.InputService18TestCaseOperation6Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService18TestCaseOperation6 *aws.Operation
-
-type InputService18TestShapeInputService18TestCaseOperation2Output struct {
- metadataInputService18TestShapeInputService18TestCaseOperation2Output `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputService18TestCaseOperation2Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService18TestShapeInputService18TestCaseOperation3Output struct {
- metadataInputService18TestShapeInputService18TestCaseOperation3Output `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputService18TestCaseOperation3Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService18TestShapeInputService18TestCaseOperation6Output struct {
- metadataInputService18TestShapeInputService18TestCaseOperation6Output `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputService18TestCaseOperation6Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation1Output struct {
- metadataInputService18TestShapeInputService18TestShapeInputService18TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputService18TestShapeInputService18TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation4Output struct {
- metadataInputService18TestShapeInputService18TestShapeInputService18TestCaseOperation4Output `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputService18TestShapeInputService18TestCaseOperation4Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService18TestShapeInputService18TestShapeInputService18TestCaseOperation5Output struct {
- metadataInputService18TestShapeInputService18TestShapeInputService18TestCaseOperation5Output `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputService18TestShapeInputService18TestCaseOperation5Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService18TestShapeInputShape struct {
- RecursiveStruct *InputService18TestShapeRecursiveStructType `type:"structure"`
-
- metadataInputService18TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeInputShape struct {
- SDKShapeTraits bool `locationName:"OperationRequest" type:"structure" xmlURI:"https://foo/"`
-}
-
-type InputService18TestShapeRecursiveStructType struct {
- NoRecurse *string `type:"string"`
-
- RecursiveList []*InputService18TestShapeRecursiveStructType `type:"list"`
-
- RecursiveMap *map[string]*InputService18TestShapeRecursiveStructType `type:"map"`
-
- RecursiveStruct *InputService18TestShapeRecursiveStructType `type:"structure"`
-
- metadataInputService18TestShapeRecursiveStructType `json:"-", xml:"-"`
-}
-
-type metadataInputService18TestShapeRecursiveStructType struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// InputService19ProtocolTest is a client for InputService19ProtocolTest.
-type InputService19ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new InputService19ProtocolTest client.
-func NewInputService19ProtocolTest(config *aws.Config) *InputService19ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "inputservice19protocoltest",
- APIVersion: "2014-01-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &InputService19ProtocolTest{service}
-}
-
-// InputService19TestCaseOperation1Request generates a request for the InputService19TestCaseOperation1 operation.
-func (c *InputService19ProtocolTest) InputService19TestCaseOperation1Request(input *InputService19TestShapeInputShape) (req *aws.Request, output *InputService19TestShapeInputService19TestCaseOperation1Output) {
- if opInputService19TestCaseOperation1 == nil {
- opInputService19TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- HTTPMethod: "POST",
- HTTPPath: "/path",
- }
- }
-
- req = aws.NewRequest(c.Service, opInputService19TestCaseOperation1, input, output)
- output = &InputService19TestShapeInputService19TestCaseOperation1Output{}
- req.Data = output
- return
-}
-
-func (c *InputService19ProtocolTest) InputService19TestCaseOperation1(input *InputService19TestShapeInputShape) (output *InputService19TestShapeInputService19TestCaseOperation1Output, err error) {
- req, out := c.InputService19TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opInputService19TestCaseOperation1 *aws.Operation
-
-type InputService19TestShapeInputService19TestCaseOperation1Output struct {
- metadataInputService19TestShapeInputService19TestCaseOperation1Output `json:"-", xml:"-"`
-}
-
-type metadataInputService19TestShapeInputService19TestCaseOperation1Output struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type InputService19TestShapeInputShape struct {
- TimeArgInHeader *time.Time `location:"header" locationName:"x-amz-timearg" type:"timestamp" timestampFormat:"rfc822"`
-
- metadataInputService19TestShapeInputShape `json:"-", xml:"-"`
-}
-
-type metadataInputService19TestShapeInputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//
-// Tests begin here
-//
-
-func TestInputService1ProtocolTestBasicXMLSerializationCase1(t *testing.T) {
- svc := NewInputService1ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService1TestShapeInputShape{
- Description: aws.String("bar"),
- Name: aws.String("foo"),
- }
- req, _ := svc.InputService1TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><Description xmlns="https://foo/">bar</Description><Name xmlns="https://foo/">foo</Name></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService1ProtocolTestBasicXMLSerializationCase2(t *testing.T) {
- svc := NewInputService1ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService1TestShapeInputShape{
- Description: aws.String("bar"),
- Name: aws.String("foo"),
- }
- req, _ := svc.InputService1TestCaseOperation2Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><Description xmlns="https://foo/">bar</Description><Name xmlns="https://foo/">foo</Name></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService2ProtocolTestSerializeOtherScalarTypesCase1(t *testing.T) {
- svc := NewInputService2ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService2TestShapeInputShape{
- First: aws.Boolean(true),
- Fourth: aws.Long(3),
- Second: aws.Boolean(false),
- Third: aws.Double(1.2),
- }
- req, _ := svc.InputService2TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><First xmlns="https://foo/">true</First><Fourth xmlns="https://foo/">3</Fourth><Second xmlns="https://foo/">false</Second><Third xmlns="https://foo/">1.2</Third></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService3ProtocolTestNestedStructuresCase1(t *testing.T) {
- svc := NewInputService3ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService3TestShapeInputShape{
- Description: aws.String("baz"),
- SubStructure: &InputService3TestShapeSubStructure{
- Bar: aws.String("b"),
- Foo: aws.String("a"),
- },
- }
- req, _ := svc.InputService3TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><Description xmlns="https://foo/">baz</Description><SubStructure xmlns="https://foo/"><Bar xmlns="https://foo/">b</Bar><Foo xmlns="https://foo/">a</Foo></SubStructure></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService4ProtocolTestNestedStructuresCase1(t *testing.T) {
- svc := NewInputService4ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService4TestShapeInputShape{
- Description: aws.String("baz"),
- SubStructure: &InputService4TestShapeSubStructure{},
- }
- req, _ := svc.InputService4TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><Description xmlns="https://foo/">baz</Description><SubStructure xmlns="https://foo/"></SubStructure></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService5ProtocolTestNonFlattenedListsCase1(t *testing.T) {
- svc := NewInputService5ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService5TestShapeInputShape{
- ListParam: []*string{
- aws.String("one"),
- aws.String("two"),
- aws.String("three"),
- },
- }
- req, _ := svc.InputService5TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><ListParam xmlns="https://foo/"><member xmlns="https://foo/">one</member><member xmlns="https://foo/">two</member><member xmlns="https://foo/">three</member></ListParam></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService6ProtocolTestNonFlattenedListsWithLocationNameCase1(t *testing.T) {
- svc := NewInputService6ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService6TestShapeInputShape{
- ListParam: []*string{
- aws.String("one"),
- aws.String("two"),
- aws.String("three"),
- },
- }
- req, _ := svc.InputService6TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><AlternateName xmlns="https://foo/"><NotMember xmlns="https://foo/">one</NotMember><NotMember xmlns="https://foo/">two</NotMember><NotMember xmlns="https://foo/">three</NotMember></AlternateName></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService7ProtocolTestFlattenedListsCase1(t *testing.T) {
- svc := NewInputService7ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService7TestShapeInputShape{
- ListParam: []*string{
- aws.String("one"),
- aws.String("two"),
- aws.String("three"),
- },
- }
- req, _ := svc.InputService7TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><ListParam xmlns="https://foo/">one</ListParam><ListParam xmlns="https://foo/">two</ListParam><ListParam xmlns="https://foo/">three</ListParam></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService8ProtocolTestFlattenedListsWithLocationNameCase1(t *testing.T) {
- svc := NewInputService8ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService8TestShapeInputShape{
- ListParam: []*string{
- aws.String("one"),
- aws.String("two"),
- aws.String("three"),
- },
- }
- req, _ := svc.InputService8TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><item xmlns="https://foo/">one</item><item xmlns="https://foo/">two</item><item xmlns="https://foo/">three</item></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService9ProtocolTestListOfStructuresCase1(t *testing.T) {
- svc := NewInputService9ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService9TestShapeInputShape{
- ListParam: []*InputService9TestShapeSingleFieldStruct{
- &InputService9TestShapeSingleFieldStruct{
- Element: aws.String("one"),
- },
- &InputService9TestShapeSingleFieldStruct{
- Element: aws.String("two"),
- },
- &InputService9TestShapeSingleFieldStruct{
- Element: aws.String("three"),
- },
- },
- }
- req, _ := svc.InputService9TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><item xmlns="https://foo/"><value xmlns="https://foo/">one</value></item><item xmlns="https://foo/"><value xmlns="https://foo/">two</value></item><item xmlns="https://foo/"><value xmlns="https://foo/">three</value></item></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService10ProtocolTestBlobAndTimestampShapesCase1(t *testing.T) {
- svc := NewInputService10ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService10TestShapeInputShape{
- StructureParam: &InputService10TestShapeStructureShape{
- B: []byte("foo"),
- T: aws.Time(time.Unix(1422172800, 0)),
- },
- }
- req, _ := svc.InputService10TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><StructureParam xmlns="https://foo/"><b xmlns="https://foo/">Zm9v</b><t xmlns="https://foo/">2015-01-25T08:00:00Z</t></StructureParam></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/2014-01-01/hostedzone", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService11ProtocolTestHeaderMapsCase1(t *testing.T) {
- svc := NewInputService11ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService11TestShapeInputShape{
- Foo: &map[string]*string{
- "a": aws.String("b"),
- "c": aws.String("d"),
- },
- }
- req, _ := svc.InputService11TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
- assert.Equal(t, "b", r.Header.Get("x-foo-a"))
- assert.Equal(t, "d", r.Header.Get("x-foo-c"))
-
-}
-
-func TestInputService12ProtocolTestStringPayloadCase1(t *testing.T) {
- svc := NewInputService12ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService12TestShapeInputShape{
- Foo: aws.String("bar"),
- }
- req, _ := svc.InputService12TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`bar`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService13ProtocolTestBlobPayloadCase1(t *testing.T) {
- svc := NewInputService13ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService13TestShapeInputShape{
- Foo: []byte("bar"),
- }
- req, _ := svc.InputService13TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`bar`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService13ProtocolTestBlobPayloadCase2(t *testing.T) {
- svc := NewInputService13ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService13TestShapeInputShape{}
- req, _ := svc.InputService13TestCaseOperation2Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService14ProtocolTestStructurePayloadCase1(t *testing.T) {
- svc := NewInputService14ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService14TestShapeInputShape{
- Foo: &InputService14TestShapeFooShape{
- Baz: aws.String("bar"),
- },
- }
- req, _ := svc.InputService14TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<foo><baz>bar</baz></foo>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService14ProtocolTestStructurePayloadCase2(t *testing.T) {
- svc := NewInputService14ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService14TestShapeInputShape{}
- req, _ := svc.InputService14TestCaseOperation2Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService15ProtocolTestXMLAttributeCase1(t *testing.T) {
- svc := NewInputService15ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService15TestShapeInputShape{
- Grant: &InputService15TestShapeGrant{
- Grantee: &InputService15TestShapeGrantee{
- EmailAddress: aws.String("foo@example.com"),
- Type: aws.String("CanonicalUser"),
- },
- },
- }
- req, _ := svc.InputService15TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<Grant xmlns:_xmlns="xmlns" _xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="CanonicalUser"><Grantee><EmailAddress>foo@example.com</EmailAddress></Grantee></Grant>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService16ProtocolTestGreedyKeysCase1(t *testing.T) {
- svc := NewInputService16ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService16TestShapeInputShape{
- Bucket: aws.String("my/bucket"),
- Key: aws.String("testing /123"),
- }
- req, _ := svc.InputService16TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/my%2Fbucket/testing%20/123", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService17ProtocolTestOmitsNullQueryParamsButSerializesEmptyStringsCase1(t *testing.T) {
- svc := NewInputService17ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService17TestShapeInputShape{}
- req, _ := svc.InputService17TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService17ProtocolTestOmitsNullQueryParamsButSerializesEmptyStringsCase2(t *testing.T) {
- svc := NewInputService17ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService17TestShapeInputShape{
- Foo: aws.String(""),
- }
- req, _ := svc.InputService17TestCaseOperation2Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/path?abc=mno&param-name=", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService18ProtocolTestRecursiveShapesCase1(t *testing.T) {
- svc := NewInputService18ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService18TestShapeInputShape{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- }
- req, _ := svc.InputService18TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></RecursiveStruct></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService18ProtocolTestRecursiveShapesCase2(t *testing.T) {
- svc := NewInputService18ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService18TestShapeInputShape{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- },
- }
- req, _ := svc.InputService18TestCaseOperation2Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></RecursiveStruct></RecursiveStruct></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService18ProtocolTestRecursiveShapesCase3(t *testing.T) {
- svc := NewInputService18ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService18TestShapeInputShape{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- },
- },
- },
- }
- req, _ := svc.InputService18TestCaseOperation3Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></RecursiveStruct></RecursiveStruct></RecursiveStruct></RecursiveStruct></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService18ProtocolTestRecursiveShapesCase4(t *testing.T) {
- svc := NewInputService18ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService18TestShapeInputShape{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveList: []*InputService18TestShapeRecursiveStructType{
- &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("bar"),
- },
- },
- },
- }
- req, _ := svc.InputService18TestCaseOperation4Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveList xmlns="https://foo/"><member xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></member><member xmlns="https://foo/"><NoRecurse xmlns="https://foo/">bar</NoRecurse></member></RecursiveList></RecursiveStruct></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService18ProtocolTestRecursiveShapesCase5(t *testing.T) {
- svc := NewInputService18ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService18TestShapeInputShape{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveList: []*InputService18TestShapeRecursiveStructType{
- &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- &InputService18TestShapeRecursiveStructType{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("bar"),
- },
- },
- },
- },
- }
- req, _ := svc.InputService18TestCaseOperation5Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveList xmlns="https://foo/"><member xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></member><member xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><NoRecurse xmlns="https://foo/">bar</NoRecurse></RecursiveStruct></member></RecursiveList></RecursiveStruct></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService18ProtocolTestRecursiveShapesCase6(t *testing.T) {
- svc := NewInputService18ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService18TestShapeInputShape{
- RecursiveStruct: &InputService18TestShapeRecursiveStructType{
- RecursiveMap: &map[string]*InputService18TestShapeRecursiveStructType{
- "bar": &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("bar"),
- },
- "foo": &InputService18TestShapeRecursiveStructType{
- NoRecurse: aws.String("foo"),
- },
- },
- },
- }
- req, _ := svc.InputService18TestCaseOperation6Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert body
- assert.NotNil(t, r.Body)
- body := util.SortXML(r.Body)
- assert.Equal(t, util.Trim(`<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveMap xmlns="https://foo/"><entry xmlns="https://foo/"><key xmlns="https://foo/">bar</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">bar</NoRecurse></value></entry><entry xmlns="https://foo/"><key xmlns="https://foo/">foo</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></value></entry></RecursiveMap></RecursiveStruct></OperationRequest>`), util.Trim(string(body)))
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
-
-}
-
-func TestInputService19ProtocolTestTimestampInHeaderCase1(t *testing.T) {
- svc := NewInputService19ProtocolTest(nil)
- svc.Endpoint = "https://test"
-
- input := &InputService19TestShapeInputShape{
- TimeArgInHeader: aws.Time(time.Unix(1422172800, 0)),
- }
- req, _ := svc.InputService19TestCaseOperation1Request(input)
- r := req.HTTPRequest
-
- // build request
- restxml.Build(req)
- assert.NoError(t, req.Error)
-
- // assert URL
- assert.Equal(t, "https://test/path", r.URL.String())
-
- // assert headers
- assert.Equal(t, "Sun, 25 Jan 2015 08:00:00 GMT", r.Header.Get("x-amz-timearg"))
-
-}
-
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/restxml.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/restxml.go
deleted file mode 100644
index 9a952ee19..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/restxml.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package restxml
-
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/input/rest-xml.json build_test.go
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/output/rest-xml.json unmarshal_test.go
-
-import (
- "bytes"
- "encoding/xml"
-
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/query"
- "github.com/awslabs/aws-sdk-go/internal/protocol/rest"
- "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil"
-)
-
-func Build(r *aws.Request) {
- rest.Build(r)
-
- if t := rest.PayloadType(r.Params); t == "structure" || t == "" {
- var buf bytes.Buffer
- err := xmlutil.BuildXML(r.Params, xml.NewEncoder(&buf))
- if err != nil {
- r.Error = err
- return
- }
- r.SetBufferBody(buf.Bytes())
- }
-}
-
-func Unmarshal(r *aws.Request) {
- if t := rest.PayloadType(r.Data); t == "structure" || t == "" {
- defer r.HTTPResponse.Body.Close()
- decoder := xml.NewDecoder(r.HTTPResponse.Body)
- err := xmlutil.UnmarshalXML(r.Data, decoder, "")
- if err != nil {
- r.Error = err
- return
- }
- }
-}
-
-func UnmarshalMeta(r *aws.Request) {
- rest.Unmarshal(r)
-}
-
-func UnmarshalError(r *aws.Request) {
- query.UnmarshalError(r)
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/unmarshal_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/unmarshal_test.go
deleted file mode 100644
index 33e261628..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/restxml/unmarshal_test.go
+++ /dev/null
@@ -1,1171 +0,0 @@
-package restxml_test
-
-import (
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/restxml"
- "github.com/awslabs/aws-sdk-go/internal/signer/v4"
-
- "bytes"
- "encoding/json"
- "encoding/xml"
- "github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil"
- "github.com/awslabs/aws-sdk-go/internal/util"
- "github.com/stretchr/testify/assert"
- "io/ioutil"
- "net/http"
- "net/url"
- "testing"
- "time"
-)
-
-var _ bytes.Buffer // always import bytes
-var _ http.Request
-var _ json.Marshaler
-var _ time.Time
-var _ xmlutil.XMLNode
-var _ xml.Attr
-var _ = ioutil.Discard
-var _ = util.Trim("")
-var _ = url.Values{}
-
-// OutputService1ProtocolTest is a client for OutputService1ProtocolTest.
-type OutputService1ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService1ProtocolTest client.
-func NewOutputService1ProtocolTest(config *aws.Config) *OutputService1ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice1protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService1ProtocolTest{service}
-}
-
-// OutputService1TestCaseOperation1Request generates a request for the OutputService1TestCaseOperation1 operation.
-func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1Request(input *OutputService1TestShapeOutputService1TestCaseOperation1Input) (req *aws.Request, output *OutputService1TestShapeOutputShape) {
- if opOutputService1TestCaseOperation1 == nil {
- opOutputService1TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService1TestCaseOperation1, input, output)
- output = &OutputService1TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1(input *OutputService1TestShapeOutputService1TestCaseOperation1Input) (output *OutputService1TestShapeOutputShape, err error) {
- req, out := c.OutputService1TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService1TestCaseOperation1 *aws.Operation
-
-// OutputService1TestCaseOperation2Request generates a request for the OutputService1TestCaseOperation2 operation.
-func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation2Request(input *OutputService1TestShapeOutputService1TestCaseOperation2Input) (req *aws.Request, output *OutputService1TestShapeOutputShape) {
- if opOutputService1TestCaseOperation2 == nil {
- opOutputService1TestCaseOperation2 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService1TestCaseOperation2, input, output)
- output = &OutputService1TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation2(input *OutputService1TestShapeOutputService1TestCaseOperation2Input) (output *OutputService1TestShapeOutputShape, err error) {
- req, out := c.OutputService1TestCaseOperation2Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService1TestCaseOperation2 *aws.Operation
-
-type OutputService1TestShapeOutputService1TestCaseOperation1Input struct {
- metadataOutputService1TestShapeOutputService1TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService1TestShapeOutputService1TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService1TestShapeOutputService1TestCaseOperation2Input struct {
- metadataOutputService1TestShapeOutputService1TestCaseOperation2Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService1TestShapeOutputService1TestCaseOperation2Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService1TestShapeOutputShape struct {
- Char *string `type:"character"`
-
- Double *float64 `type:"double"`
-
- FalseBool *bool `type:"boolean"`
-
- Float *float64 `type:"float"`
-
- ImaHeader *string `location:"header" type:"string"`
-
- ImaHeaderLocation *string `location:"header" locationName:"X-Foo" type:"string"`
-
- Long *int64 `type:"long"`
-
- Num *int64 `locationName:"FooNum" type:"integer"`
-
- Str *string `type:"string"`
-
- Timestamp *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- TrueBool *bool `type:"boolean"`
-
- metadataOutputService1TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService1TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService2ProtocolTest is a client for OutputService2ProtocolTest.
-type OutputService2ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService2ProtocolTest client.
-func NewOutputService2ProtocolTest(config *aws.Config) *OutputService2ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice2protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService2ProtocolTest{service}
-}
-
-// OutputService2TestCaseOperation1Request generates a request for the OutputService2TestCaseOperation1 operation.
-func (c *OutputService2ProtocolTest) OutputService2TestCaseOperation1Request(input *OutputService2TestShapeOutputService2TestCaseOperation1Input) (req *aws.Request, output *OutputService2TestShapeOutputShape) {
- if opOutputService2TestCaseOperation1 == nil {
- opOutputService2TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService2TestCaseOperation1, input, output)
- output = &OutputService2TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService2ProtocolTest) OutputService2TestCaseOperation1(input *OutputService2TestShapeOutputService2TestCaseOperation1Input) (output *OutputService2TestShapeOutputShape, err error) {
- req, out := c.OutputService2TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService2TestCaseOperation1 *aws.Operation
-
-type OutputService2TestShapeOutputService2TestCaseOperation1Input struct {
- metadataOutputService2TestShapeOutputService2TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService2TestShapeOutputService2TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService2TestShapeOutputShape struct {
- Blob []byte `type:"blob"`
-
- metadataOutputService2TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService2TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService3ProtocolTest is a client for OutputService3ProtocolTest.
-type OutputService3ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService3ProtocolTest client.
-func NewOutputService3ProtocolTest(config *aws.Config) *OutputService3ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice3protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService3ProtocolTest{service}
-}
-
-// OutputService3TestCaseOperation1Request generates a request for the OutputService3TestCaseOperation1 operation.
-func (c *OutputService3ProtocolTest) OutputService3TestCaseOperation1Request(input *OutputService3TestShapeOutputService3TestCaseOperation1Input) (req *aws.Request, output *OutputService3TestShapeOutputShape) {
- if opOutputService3TestCaseOperation1 == nil {
- opOutputService3TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService3TestCaseOperation1, input, output)
- output = &OutputService3TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService3ProtocolTest) OutputService3TestCaseOperation1(input *OutputService3TestShapeOutputService3TestCaseOperation1Input) (output *OutputService3TestShapeOutputShape, err error) {
- req, out := c.OutputService3TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService3TestCaseOperation1 *aws.Operation
-
-type OutputService3TestShapeOutputService3TestCaseOperation1Input struct {
- metadataOutputService3TestShapeOutputService3TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService3TestShapeOutputService3TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService3TestShapeOutputShape struct {
- ListMember []*string `type:"list"`
-
- metadataOutputService3TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService3TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService4ProtocolTest is a client for OutputService4ProtocolTest.
-type OutputService4ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService4ProtocolTest client.
-func NewOutputService4ProtocolTest(config *aws.Config) *OutputService4ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice4protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService4ProtocolTest{service}
-}
-
-// OutputService4TestCaseOperation1Request generates a request for the OutputService4TestCaseOperation1 operation.
-func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation1Request(input *OutputService4TestShapeOutputService4TestCaseOperation1Input) (req *aws.Request, output *OutputService4TestShapeOutputShape) {
- if opOutputService4TestCaseOperation1 == nil {
- opOutputService4TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService4TestCaseOperation1, input, output)
- output = &OutputService4TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation1(input *OutputService4TestShapeOutputService4TestCaseOperation1Input) (output *OutputService4TestShapeOutputShape, err error) {
- req, out := c.OutputService4TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService4TestCaseOperation1 *aws.Operation
-
-type OutputService4TestShapeOutputService4TestCaseOperation1Input struct {
- metadataOutputService4TestShapeOutputService4TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService4TestShapeOutputService4TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService4TestShapeOutputShape struct {
- ListMember []*string `locationNameList:"item" type:"list"`
-
- metadataOutputService4TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService4TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService5ProtocolTest is a client for OutputService5ProtocolTest.
-type OutputService5ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService5ProtocolTest client.
-func NewOutputService5ProtocolTest(config *aws.Config) *OutputService5ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice5protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService5ProtocolTest{service}
-}
-
-// OutputService5TestCaseOperation1Request generates a request for the OutputService5TestCaseOperation1 operation.
-func (c *OutputService5ProtocolTest) OutputService5TestCaseOperation1Request(input *OutputService5TestShapeOutputService5TestCaseOperation1Input) (req *aws.Request, output *OutputService5TestShapeOutputShape) {
- if opOutputService5TestCaseOperation1 == nil {
- opOutputService5TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService5TestCaseOperation1, input, output)
- output = &OutputService5TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService5ProtocolTest) OutputService5TestCaseOperation1(input *OutputService5TestShapeOutputService5TestCaseOperation1Input) (output *OutputService5TestShapeOutputShape, err error) {
- req, out := c.OutputService5TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService5TestCaseOperation1 *aws.Operation
-
-type OutputService5TestShapeOutputService5TestCaseOperation1Input struct {
- metadataOutputService5TestShapeOutputService5TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService5TestShapeOutputService5TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService5TestShapeOutputShape struct {
- ListMember []*string `type:"list" flattened:"true"`
-
- metadataOutputService5TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService5TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService6ProtocolTest is a client for OutputService6ProtocolTest.
-type OutputService6ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService6ProtocolTest client.
-func NewOutputService6ProtocolTest(config *aws.Config) *OutputService6ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice6protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService6ProtocolTest{service}
-}
-
-// OutputService6TestCaseOperation1Request generates a request for the OutputService6TestCaseOperation1 operation.
-func (c *OutputService6ProtocolTest) OutputService6TestCaseOperation1Request(input *OutputService6TestShapeOutputService6TestCaseOperation1Input) (req *aws.Request, output *OutputService6TestShapeOutputShape) {
- if opOutputService6TestCaseOperation1 == nil {
- opOutputService6TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService6TestCaseOperation1, input, output)
- output = &OutputService6TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService6ProtocolTest) OutputService6TestCaseOperation1(input *OutputService6TestShapeOutputService6TestCaseOperation1Input) (output *OutputService6TestShapeOutputShape, err error) {
- req, out := c.OutputService6TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService6TestCaseOperation1 *aws.Operation
-
-type OutputService6TestShapeOutputService6TestCaseOperation1Input struct {
- metadataOutputService6TestShapeOutputService6TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService6TestShapeOutputService6TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService6TestShapeOutputShape struct {
- Map *map[string]*OutputService6TestShapeSingleStructure `type:"map"`
-
- metadataOutputService6TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService6TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService6TestShapeSingleStructure struct {
- Foo *string `locationName:"foo" type:"string"`
-
- metadataOutputService6TestShapeSingleStructure `json:"-", xml:"-"`
-}
-
-type metadataOutputService6TestShapeSingleStructure struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService7ProtocolTest is a client for OutputService7ProtocolTest.
-type OutputService7ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService7ProtocolTest client.
-func NewOutputService7ProtocolTest(config *aws.Config) *OutputService7ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice7protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService7ProtocolTest{service}
-}
-
-// OutputService7TestCaseOperation1Request generates a request for the OutputService7TestCaseOperation1 operation.
-func (c *OutputService7ProtocolTest) OutputService7TestCaseOperation1Request(input *OutputService7TestShapeOutputService7TestCaseOperation1Input) (req *aws.Request, output *OutputService7TestShapeOutputShape) {
- if opOutputService7TestCaseOperation1 == nil {
- opOutputService7TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService7TestCaseOperation1, input, output)
- output = &OutputService7TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService7ProtocolTest) OutputService7TestCaseOperation1(input *OutputService7TestShapeOutputService7TestCaseOperation1Input) (output *OutputService7TestShapeOutputShape, err error) {
- req, out := c.OutputService7TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService7TestCaseOperation1 *aws.Operation
-
-type OutputService7TestShapeOutputService7TestCaseOperation1Input struct {
- metadataOutputService7TestShapeOutputService7TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService7TestShapeOutputService7TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService7TestShapeOutputShape struct {
- Map *map[string]*string `type:"map" flattened:"true"`
-
- metadataOutputService7TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService7TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService8ProtocolTest is a client for OutputService8ProtocolTest.
-type OutputService8ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService8ProtocolTest client.
-func NewOutputService8ProtocolTest(config *aws.Config) *OutputService8ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice8protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService8ProtocolTest{service}
-}
-
-// OutputService8TestCaseOperation1Request generates a request for the OutputService8TestCaseOperation1 operation.
-func (c *OutputService8ProtocolTest) OutputService8TestCaseOperation1Request(input *OutputService8TestShapeOutputService8TestCaseOperation1Input) (req *aws.Request, output *OutputService8TestShapeOutputShape) {
- if opOutputService8TestCaseOperation1 == nil {
- opOutputService8TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService8TestCaseOperation1, input, output)
- output = &OutputService8TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService8ProtocolTest) OutputService8TestCaseOperation1(input *OutputService8TestShapeOutputService8TestCaseOperation1Input) (output *OutputService8TestShapeOutputShape, err error) {
- req, out := c.OutputService8TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService8TestCaseOperation1 *aws.Operation
-
-type OutputService8TestShapeOutputService8TestCaseOperation1Input struct {
- metadataOutputService8TestShapeOutputService8TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService8TestShapeOutputService8TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService8TestShapeOutputShape struct {
- Map *map[string]*string `locationNameKey:"foo" locationNameValue:"bar" type:"map"`
-
- metadataOutputService8TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService8TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService9ProtocolTest is a client for OutputService9ProtocolTest.
-type OutputService9ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService9ProtocolTest client.
-func NewOutputService9ProtocolTest(config *aws.Config) *OutputService9ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice9protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService9ProtocolTest{service}
-}
-
-// OutputService9TestCaseOperation1Request generates a request for the OutputService9TestCaseOperation1 operation.
-func (c *OutputService9ProtocolTest) OutputService9TestCaseOperation1Request(input *OutputService9TestShapeOutputService9TestCaseOperation1Input) (req *aws.Request, output *OutputService9TestShapeOutputShape) {
- if opOutputService9TestCaseOperation1 == nil {
- opOutputService9TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService9TestCaseOperation1, input, output)
- output = &OutputService9TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService9ProtocolTest) OutputService9TestCaseOperation1(input *OutputService9TestShapeOutputService9TestCaseOperation1Input) (output *OutputService9TestShapeOutputShape, err error) {
- req, out := c.OutputService9TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService9TestCaseOperation1 *aws.Operation
-
-type OutputService9TestShapeOutputService9TestCaseOperation1Input struct {
- metadataOutputService9TestShapeOutputService9TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService9TestShapeOutputService9TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService9TestShapeOutputShape struct {
- Data *OutputService9TestShapeSingleStructure `type:"structure"`
-
- Header *string `location:"header" locationName:"X-Foo" type:"string"`
-
- metadataOutputService9TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService9TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure" payload:"Data"`
-}
-
-type OutputService9TestShapeSingleStructure struct {
- Foo *string `type:"string"`
-
- metadataOutputService9TestShapeSingleStructure `json:"-", xml:"-"`
-}
-
-type metadataOutputService9TestShapeSingleStructure struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// OutputService10ProtocolTest is a client for OutputService10ProtocolTest.
-type OutputService10ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService10ProtocolTest client.
-func NewOutputService10ProtocolTest(config *aws.Config) *OutputService10ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice10protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService10ProtocolTest{service}
-}
-
-// OutputService10TestCaseOperation1Request generates a request for the OutputService10TestCaseOperation1 operation.
-func (c *OutputService10ProtocolTest) OutputService10TestCaseOperation1Request(input *OutputService10TestShapeOutputService10TestCaseOperation1Input) (req *aws.Request, output *OutputService10TestShapeOutputShape) {
- if opOutputService10TestCaseOperation1 == nil {
- opOutputService10TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService10TestCaseOperation1, input, output)
- output = &OutputService10TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService10ProtocolTest) OutputService10TestCaseOperation1(input *OutputService10TestShapeOutputService10TestCaseOperation1Input) (output *OutputService10TestShapeOutputShape, err error) {
- req, out := c.OutputService10TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService10TestCaseOperation1 *aws.Operation
-
-type OutputService10TestShapeOutputService10TestCaseOperation1Input struct {
- metadataOutputService10TestShapeOutputService10TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService10TestShapeOutputService10TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService10TestShapeOutputShape struct {
- Stream []byte `type:"blob"`
-
- metadataOutputService10TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService10TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure" payload:"Stream"`
-}
-
-// OutputService11ProtocolTest is a client for OutputService11ProtocolTest.
-type OutputService11ProtocolTest struct {
- *aws.Service
-}
-
-// New returns a new OutputService11ProtocolTest client.
-func NewOutputService11ProtocolTest(config *aws.Config) *OutputService11ProtocolTest {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "outputservice11protocoltest",
- APIVersion: "",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- return &OutputService11ProtocolTest{service}
-}
-
-// OutputService11TestCaseOperation1Request generates a request for the OutputService11TestCaseOperation1 operation.
-func (c *OutputService11ProtocolTest) OutputService11TestCaseOperation1Request(input *OutputService11TestShapeOutputService11TestCaseOperation1Input) (req *aws.Request, output *OutputService11TestShapeOutputShape) {
- if opOutputService11TestCaseOperation1 == nil {
- opOutputService11TestCaseOperation1 = &aws.Operation{
- Name: "OperationName",
- }
- }
-
- req = aws.NewRequest(c.Service, opOutputService11TestCaseOperation1, input, output)
- output = &OutputService11TestShapeOutputShape{}
- req.Data = output
- return
-}
-
-func (c *OutputService11ProtocolTest) OutputService11TestCaseOperation1(input *OutputService11TestShapeOutputService11TestCaseOperation1Input) (output *OutputService11TestShapeOutputShape, err error) {
- req, out := c.OutputService11TestCaseOperation1Request(input)
- output = out
- err = req.Send()
- return
-}
-
-var opOutputService11TestCaseOperation1 *aws.Operation
-
-type OutputService11TestShapeOutputService11TestCaseOperation1Input struct {
- metadataOutputService11TestShapeOutputService11TestCaseOperation1Input `json:"-", xml:"-"`
-}
-
-type metadataOutputService11TestShapeOutputService11TestCaseOperation1Input struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type OutputService11TestShapeOutputShape struct {
- Char *string `location:"header" locationName:"x-char" type:"character"`
-
- Double *float64 `location:"header" locationName:"x-double" type:"double"`
-
- FalseBool *bool `location:"header" locationName:"x-false-bool" type:"boolean"`
-
- Float *float64 `location:"header" locationName:"x-float" type:"float"`
-
- Integer *int64 `location:"header" locationName:"x-int" type:"integer"`
-
- Long *int64 `location:"header" locationName:"x-long" type:"long"`
-
- Str *string `location:"header" locationName:"x-str" type:"string"`
-
- Timestamp *time.Time `location:"header" locationName:"x-timestamp" type:"timestamp" timestampFormat:"iso8601"`
-
- TrueBool *bool `location:"header" locationName:"x-true-bool" type:"boolean"`
-
- metadataOutputService11TestShapeOutputShape `json:"-", xml:"-"`
-}
-
-type metadataOutputService11TestShapeOutputShape struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//
-// Tests begin here
-//
-
-func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
- svc := NewOutputService1ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><Str>myname</Str><FooNum>123</FooNum><FalseBool>false</FalseBool><TrueBool>true</TrueBool><Float>1.2</Float><Double>1.3</Double><Long>200</Long><Char>a</Char><Timestamp>2015-01-25T08:00:00Z</Timestamp></OperationNameResponse>"))
- req, out := svc.OutputService1TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
- req.HTTPResponse.Header.Set("ImaHeader", "test")
- req.HTTPResponse.Header.Set("X-Foo", "abc")
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "a", *out.Char)
- assert.Equal(t, 1.3, *out.Double)
- assert.Equal(t, false, *out.FalseBool)
- assert.Equal(t, 1.2, *out.Float)
- assert.Equal(t, "test", *out.ImaHeader)
- assert.Equal(t, "abc", *out.ImaHeaderLocation)
- assert.Equal(t, 200, *out.Long)
- assert.Equal(t, 123, *out.Num)
- assert.Equal(t, "myname", *out.Str)
- assert.Equal(t, time.Unix(1.4221728e+09, 0).UTC().String(), out.Timestamp.String())
- assert.Equal(t, true, *out.TrueBool)
-
-}
-
-func TestOutputService1ProtocolTestScalarMembersCase2(t *testing.T) {
- svc := NewOutputService1ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><Str></Str><FooNum>123</FooNum><FalseBool>false</FalseBool><TrueBool>true</TrueBool><Float>1.2</Float><Double>1.3</Double><Long>200</Long><Char>a</Char><Timestamp>2015-01-25T08:00:00Z</Timestamp></OperationNameResponse>"))
- req, out := svc.OutputService1TestCaseOperation2Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
- req.HTTPResponse.Header.Set("ImaHeader", "test")
- req.HTTPResponse.Header.Set("X-Foo", "abc")
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "a", *out.Char)
- assert.Equal(t, 1.3, *out.Double)
- assert.Equal(t, false, *out.FalseBool)
- assert.Equal(t, 1.2, *out.Float)
- assert.Equal(t, "test", *out.ImaHeader)
- assert.Equal(t, "abc", *out.ImaHeaderLocation)
- assert.Equal(t, 200, *out.Long)
- assert.Equal(t, 123, *out.Num)
- assert.Equal(t, "", *out.Str)
- assert.Equal(t, time.Unix(1.4221728e+09, 0).UTC().String(), out.Timestamp.String())
- assert.Equal(t, true, *out.TrueBool)
-
-}
-
-func TestOutputService2ProtocolTestBlobCase1(t *testing.T) {
- svc := NewOutputService2ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><Blob>dmFsdWU=</Blob></OperationNameResult>"))
- req, out := svc.OutputService2TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "value", string(out.Blob))
-
-}
-
-func TestOutputService3ProtocolTestListsCase1(t *testing.T) {
- svc := NewOutputService3ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><ListMember><member>abc</member><member>123</member></ListMember></OperationNameResult>"))
- req, out := svc.OutputService3TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
- assert.Equal(t, "123", *out.ListMember[1])
-
-}
-
-func TestOutputService4ProtocolTestListWithCustomMemberNameCase1(t *testing.T) {
- svc := NewOutputService4ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><ListMember><item>abc</item><item>123</item></ListMember></OperationNameResult>"))
- req, out := svc.OutputService4TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
- assert.Equal(t, "123", *out.ListMember[1])
-
-}
-
-func TestOutputService5ProtocolTestFlattenedListCase1(t *testing.T) {
- svc := NewOutputService5ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><ListMember>abc</ListMember><ListMember>123</ListMember></OperationNameResult>"))
- req, out := svc.OutputService5TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.ListMember[0])
- assert.Equal(t, "123", *out.ListMember[1])
-
-}
-
-func TestOutputService6ProtocolTestNormalMapCase1(t *testing.T) {
- svc := NewOutputService6ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><Map><entry><key>qux</key><value><foo>bar</foo></value></entry><entry><key>baz</key><value><foo>bam</foo></value></entry></Map></OperationNameResult>"))
- req, out := svc.OutputService6TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bam", *(*out.Map)["baz"].Foo)
- assert.Equal(t, "bar", *(*out.Map)["qux"].Foo)
-
-}
-
-func TestOutputService7ProtocolTestFlattenedMapCase1(t *testing.T) {
- svc := NewOutputService7ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><Map><key>qux</key><value>bar</value></Map><Map><key>baz</key><value>bam</value></Map></OperationNameResult>"))
- req, out := svc.OutputService7TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bam", *(*out.Map)["baz"])
- assert.Equal(t, "bar", *(*out.Map)["qux"])
-
-}
-
-func TestOutputService8ProtocolTestNamedMapCase1(t *testing.T) {
- svc := NewOutputService8ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResult><Map><entry><foo>qux</foo><bar>bar</bar></entry><entry><foo>baz</foo><bar>bam</bar></entry></Map></OperationNameResult>"))
- req, out := svc.OutputService8TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "bam", *(*out.Map)["baz"])
- assert.Equal(t, "bar", *(*out.Map)["qux"])
-
-}
-
-func TestOutputService9ProtocolTestXMLPayloadCase1(t *testing.T) {
- svc := NewOutputService9ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("<OperationNameResponse><Foo>abc</Foo></OperationNameResponse>"))
- req, out := svc.OutputService9TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
- req.HTTPResponse.Header.Set("X-Foo", "baz")
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", *out.Data.Foo)
- assert.Equal(t, "baz", *out.Header)
-
-}
-
-func TestOutputService10ProtocolTestStreamingPayloadCase1(t *testing.T) {
- svc := NewOutputService10ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte("abc"))
- req, out := svc.OutputService10TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "abc", string(out.Stream))
-
-}
-
-func TestOutputService11ProtocolTestScalarMembersInHeadersCase1(t *testing.T) {
- svc := NewOutputService11ProtocolTest(nil)
-
- buf := bytes.NewReader([]byte(""))
- req, out := svc.OutputService11TestCaseOperation1Request(nil)
- req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
-
- // set headers
- req.HTTPResponse.Header.Set("x-char", "a")
- req.HTTPResponse.Header.Set("x-double", "1.5")
- req.HTTPResponse.Header.Set("x-false-bool", "false")
- req.HTTPResponse.Header.Set("x-float", "1.5")
- req.HTTPResponse.Header.Set("x-int", "1")
- req.HTTPResponse.Header.Set("x-long", "100")
- req.HTTPResponse.Header.Set("x-str", "string")
- req.HTTPResponse.Header.Set("x-timestamp", "Sun, 25 Jan 2015 08:00:00 GMT")
- req.HTTPResponse.Header.Set("x-true-bool", "true")
-
- // unmarshal response
- restxml.UnmarshalMeta(req)
- restxml.Unmarshal(req)
- assert.NoError(t, req.Error)
-
- // assert response
- assert.NotNil(t, out) // ensure out variable is used
- assert.Equal(t, "a", *out.Char)
- assert.Equal(t, 1.5, *out.Double)
- assert.Equal(t, false, *out.FalseBool)
- assert.Equal(t, 1.5, *out.Float)
- assert.Equal(t, 1, *out.Integer)
- assert.Equal(t, 100, *out.Long)
- assert.Equal(t, "string", *out.Str)
- assert.Equal(t, time.Unix(1.4221728e+09, 0).UTC().String(), out.Timestamp.String())
- assert.Equal(t, true, *out.TrueBool)
-
-}
-
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/build.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/build.go
deleted file mode 100644
index af2ce630b..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/build.go
+++ /dev/null
@@ -1,262 +0,0 @@
-package xmlutil
-
-import (
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-func BuildXML(params interface{}, e *xml.Encoder) error {
- b := xmlBuilder{encoder: e, namespaces: map[string]string{}}
- root := NewXMLElement(xml.Name{})
- if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil {
- return err
- }
- for _, c := range root.Children {
- for _, v := range c {
- return StructToXML(e, v, false)
- }
- }
- return nil
-}
-
-func elemOf(value reflect.Value) reflect.Value {
- for value.Kind() == reflect.Ptr {
- value = value.Elem()
- }
- return value
-}
-
-type xmlBuilder struct {
- encoder *xml.Encoder
- namespaces map[string]string
-}
-
-func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- value = elemOf(value)
- if !value.IsValid() { // no need to handle zero values
- return nil
- } else if tag.Get("location") != "" { // don't handle non-body location values
- return nil
- }
-
- t := tag.Get("type")
- if t == "" {
- switch value.Kind() {
- case reflect.Struct:
- t = "structure"
- case reflect.Slice:
- t = "list"
- case reflect.Map:
- t = "map"
- }
- }
-
- switch t {
- case "structure":
- if field, ok := value.Type().FieldByName("SDKShapeTraits"); ok {
- tag = tag + reflect.StructTag(" ") + field.Tag
- }
- return b.buildStruct(value, current, tag)
- case "list":
- return b.buildList(value, current, tag)
- case "map":
- return b.buildMap(value, current, tag)
- default:
- return b.buildScalar(value, current, tag)
- }
-}
-
-func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- if !value.IsValid() {
- return nil
- }
-
- fieldAdded := false
-
- // unwrap payloads
- if payload := tag.Get("payload"); payload != "" {
- field, _ := value.Type().FieldByName(payload)
- tag = field.Tag
- value = elemOf(value.FieldByName(payload))
-
- if !value.IsValid() {
- return nil
- }
- }
-
- child := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
-
- // there is an xmlNamespace associated with this struct
- if prefix, uri := tag.Get("xmlPrefix"), tag.Get("xmlURI"); uri != "" {
- ns := xml.Attr{
- Name: xml.Name{Local: "xmlns"},
- Value: uri,
- }
- if prefix != "" {
- b.namespaces[prefix] = uri // register the namespace
- ns.Name.Local = "xmlns:" + prefix
- }
-
- child.Attr = append(child.Attr, ns)
- }
-
- t := value.Type()
- for i := 0; i < value.NumField(); i++ {
- if c := t.Field(i).Name[0:1]; strings.ToLower(c) == c {
- continue // ignore unexported fields
- }
-
- member := elemOf(value.Field(i))
- field := t.Field(i)
- mTag := field.Tag
-
- if mTag.Get("location") != "" { // skip non-body members
- continue
- }
-
- memberName := mTag.Get("locationName")
- if memberName == "" {
- memberName = field.Name
- mTag = reflect.StructTag(string(mTag) + ` locationName:"` + memberName + `"`)
- }
- if err := b.buildValue(member, child, mTag); err != nil {
- return err
- }
-
- fieldAdded = true
- }
-
- if fieldAdded { // only append this child if we have one ore more valid members
- current.AddChild(child)
- }
-
- return nil
-}
-
-func (b *xmlBuilder) buildList(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- if value.IsNil() { // don't build omitted lists
- return nil
- }
-
- // check for unflattened list member
- flattened := tag.Get("flattened") != ""
-
- xname := xml.Name{Local: tag.Get("locationName")}
- if flattened {
- for i := 0; i < value.Len(); i++ {
- child := NewXMLElement(xname)
- current.AddChild(child)
- if err := b.buildValue(value.Index(i), child, ""); err != nil {
- return err
- }
- }
- } else {
- list := NewXMLElement(xname)
- current.AddChild(list)
-
- for i := 0; i < value.Len(); i++ {
- iname := tag.Get("locationNameList")
- if iname == "" {
- iname = "member"
- }
-
- child := NewXMLElement(xml.Name{Local: iname})
- list.AddChild(child)
- if err := b.buildValue(value.Index(i), child, ""); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-func (b *xmlBuilder) buildMap(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- if value.IsNil() { // don't build omitted maps
- return nil
- }
-
- maproot := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
- current.AddChild(maproot)
- current = maproot
-
- kname, vname := "key", "value"
- if n := tag.Get("locationNameKey"); n != "" {
- kname = n
- }
- if n := tag.Get("locationNameValue"); n != "" {
- vname = n
- }
-
- // sorting is not required for compliance, but it makes testing easier
- keys := make([]string, value.Len())
- for i, k := range value.MapKeys() {
- keys[i] = k.String()
- }
- sort.Strings(keys)
-
- for _, k := range keys {
- v := value.MapIndex(reflect.ValueOf(k))
- fmt.Println(k, v.Interface())
-
- mapcur := current
- if tag.Get("flattened") == "" { // add "entry" tag to non-flat maps
- child := NewXMLElement(xml.Name{Local: "entry"})
- mapcur.AddChild(child)
- mapcur = child
- }
-
- kchild := NewXMLElement(xml.Name{Local: kname})
- kchild.Text = k
- vchild := NewXMLElement(xml.Name{Local: vname})
- mapcur.AddChild(kchild)
- mapcur.AddChild(vchild)
-
- if err := b.buildValue(v, vchild, ""); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- var str string
- switch converted := value.Interface().(type) {
- case string:
- str = converted
- case []byte:
- str = base64.StdEncoding.EncodeToString(converted)
- case bool:
- str = strconv.FormatBool(converted)
- case int64:
- str = strconv.FormatInt(converted, 10)
- case int:
- str = strconv.Itoa(converted)
- case float64:
- str = strconv.FormatFloat(converted, 'f', -1, 64)
- case float32:
- str = strconv.FormatFloat(float64(converted), 'f', -1, 32)
- case time.Time:
- const ISO8601UTC = "2006-01-02T15:04:05Z"
- str = converted.UTC().Format(ISO8601UTC)
- default:
- return fmt.Errorf("unsupported value for param %s: %v (%s)",
- tag.Get("locationName"), value.Interface(), value.Type().Name())
- }
-
- xname := xml.Name{Local: tag.Get("locationName")}
- if tag.Get("xmlAttribute") != "" { // put into current node's attribute list
- attr := xml.Attr{Name: xname, Value: str}
- current.Attr = append(current.Attr, attr)
- } else { // regular text node
- current.AddChild(&XMLNode{Name: xname, Text: str})
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go
deleted file mode 100644
index d5b7d71be..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go
+++ /dev/null
@@ -1,251 +0,0 @@
-package xmlutil
-
-import (
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "io"
- "reflect"
- "strconv"
- "strings"
- "time"
-)
-
-func UnmarshalXML(v interface{}, d *xml.Decoder, wrapper string) error {
- n, _ := XMLToStruct(d, nil)
- if n.Children != nil {
- for _, root := range n.Children {
- for _, c := range root {
- if wrappedChild, ok := c.Children[wrapper]; ok {
- c = wrappedChild[0] // pull out wrapped element
- }
-
- err := parse(reflect.ValueOf(v), c, "")
- if err != nil {
- if err == io.EOF {
- return nil
- }
- return err
- }
- }
- }
- return nil
- }
- return nil
-}
-
-func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- rtype := r.Type()
- if rtype.Kind() == reflect.Ptr {
- rtype = rtype.Elem() // check kind of actual element type
- }
-
- t := tag.Get("type")
- if t == "" {
- switch rtype.Kind() {
- case reflect.Struct:
- t = "structure"
- case reflect.Slice:
- t = "list"
- case reflect.Map:
- t = "map"
- }
- }
-
- switch t {
- case "structure":
- if field, ok := rtype.FieldByName("SDKShapeTraits"); ok {
- tag = field.Tag
- }
- return parseStruct(r, node, tag)
- case "list":
- return parseList(r, node, tag)
- case "map":
- return parseMap(r, node, tag)
- default:
- return parseScalar(r, node, tag)
- }
-}
-
-func parseStruct(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- t := r.Type()
- if r.Kind() == reflect.Ptr {
- if r.IsNil() { // create the structure if it's nil
- s := reflect.New(r.Type().Elem())
- r.Set(s)
- r = s
- }
-
- r = r.Elem()
- t = t.Elem()
- }
-
- // unwrap any payloads
- if payload := tag.Get("payload"); payload != "" {
- field, _ := t.FieldByName(payload)
- return parseStruct(r.FieldByName(payload), node, field.Tag)
- }
-
- for i := 0; i < t.NumField(); i++ {
- field := t.Field(i)
- if c := field.Name[0:1]; strings.ToLower(c) == c {
- continue // ignore unexported fields
- }
-
- // figure out what this field is called
- name := field.Name
- if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
- name = field.Tag.Get("locationNameList")
- } else if locName := field.Tag.Get("locationName"); locName != "" {
- name = locName
- }
-
- // try to find the field by name in elements
- elems := node.Children[name]
-
- if elems == nil { // try to find the field in attributes
- for _, a := range node.Attr {
- if name == a.Name.Local {
- // turn this into a text node for de-serializing
- elems = []*XMLNode{&XMLNode{Text: a.Value}}
- }
- }
- }
-
- member := r.FieldByName(field.Name)
- for _, elem := range elems {
- err := parse(member, elem, field.Tag)
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-func parseList(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- t := r.Type()
-
- if tag.Get("flattened") == "" { // look at all item entries
- mname := "member"
- if name := tag.Get("locationNameList"); name != "" {
- mname = name
- }
-
- if Children, ok := node.Children[mname]; ok {
- if r.IsNil() {
- r.Set(reflect.MakeSlice(t, len(Children), len(Children)))
- }
-
- for i, c := range Children {
- err := parse(r.Index(i), c, "")
- if err != nil {
- return err
- }
- }
- }
- } else { // flattened list means this is a single element
- if r.IsNil() {
- r.Set(reflect.MakeSlice(t, 0, 0))
- }
-
- childR := reflect.Zero(t.Elem())
- r.Set(reflect.Append(r, childR))
- err := parse(r.Index(r.Len()-1), node, "")
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- t := r.Type()
- if r.Kind() == reflect.Ptr {
- t = t.Elem()
- if r.IsNil() {
- r.Set(reflect.New(t))
- r.Elem().Set(reflect.MakeMap(t))
- }
-
- r = r.Elem()
- }
-
- if tag.Get("flattened") == "" { // look at all child entries
- for _, entry := range node.Children["entry"] {
- parseMapEntry(r, entry, tag)
- }
- } else { // this element is itself an entry
- parseMapEntry(r, node, tag)
- }
-
- return nil
-}
-
-func parseMapEntry(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- kname, vname := "key", "value"
- if n := tag.Get("locationNameKey"); n != "" {
- kname = n
- }
- if n := tag.Get("locationNameValue"); n != "" {
- vname = n
- }
-
- keys, ok := node.Children[kname]
- values := node.Children[vname]
- if ok {
- for i, key := range keys {
- keyR := reflect.ValueOf(key.Text)
- value := values[i]
- valueR := reflect.New(r.Type().Elem()).Elem()
-
- parse(valueR, value, "")
- r.SetMapIndex(keyR, valueR)
- }
- }
- return nil
-}
-
-func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- switch r.Interface().(type) {
- case *string:
- r.Set(reflect.ValueOf(&node.Text))
- return nil
- case []byte:
- b, err := base64.StdEncoding.DecodeString(node.Text)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(b))
- case *bool:
- v, err := strconv.ParseBool(node.Text)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(&v))
- case *int64:
- v, err := strconv.ParseInt(node.Text, 10, 64)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(&v))
- case *float64:
- v, err := strconv.ParseFloat(node.Text, 64)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(&v))
- case *time.Time:
- const ISO8601UTC = "2006-01-02T15:04:05Z"
- t, err := time.Parse(ISO8601UTC, node.Text)
- if err != nil {
- return err
- } else {
- r.Set(reflect.ValueOf(&t))
- }
- default:
- return fmt.Errorf("unsupported value: %v (%s)", r.Interface(), r.Type())
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go
deleted file mode 100644
index b6a1cfadd..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package xmlutil
-
-import (
- "encoding/xml"
- "io"
- "sort"
-)
-
-type XMLNode struct {
- Name xml.Name `json:",omitempty"`
- Children map[string][]*XMLNode `json:",omitempty"`
- Text string `json:",omitempty"`
- Attr []xml.Attr `json:",omitempty"`
-}
-
-func NewXMLElement(name xml.Name) *XMLNode {
- return &XMLNode{
- Name: name,
- Children: map[string][]*XMLNode{},
- Attr: []xml.Attr{},
- }
-}
-
-func (n *XMLNode) AddChild(child *XMLNode) {
- if _, ok := n.Children[child.Name.Local]; !ok {
- n.Children[child.Name.Local] = []*XMLNode{}
- }
- n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child)
-}
-
-func XMLToStruct(d *xml.Decoder, s *xml.StartElement) (*XMLNode, error) {
- out := &XMLNode{}
- for {
- tok, err := d.Token()
- if tok == nil || err == io.EOF {
- break
- }
- if err != nil {
- return out, err
- }
-
- switch typed := tok.(type) {
- case xml.CharData:
- out.Text = string(typed.Copy())
- case xml.StartElement:
- el := typed.Copy()
- out.Attr = el.Attr
- if out.Children == nil {
- out.Children = map[string][]*XMLNode{}
- }
-
- name := typed.Name.Local
- slice := out.Children[name]
- if slice == nil {
- slice = []*XMLNode{}
- }
- node, e := XMLToStruct(d, &el)
- if e != nil {
- return out, e
- }
- node.Name = typed.Name
- slice = append(slice, node)
- out.Children[name] = slice
- case xml.EndElement:
- if s != nil && s.Name.Local == typed.Name.Local { // matching end token
- return out, nil
- }
- }
- }
- return out, nil
-}
-
-func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error {
- e.EncodeToken(xml.StartElement{Name: node.Name, Attr: node.Attr})
-
- if node.Text != "" {
- e.EncodeToken(xml.CharData([]byte(node.Text)))
- } else if sorted {
- sortedNames := []string{}
- for k, _ := range node.Children {
- sortedNames = append(sortedNames, k)
- }
- sort.Strings(sortedNames)
-
- for _, k := range sortedNames {
- for _, v := range node.Children[k] {
- StructToXML(e, v, sorted)
- }
- }
- } else {
- for _, c := range node.Children {
- for _, v := range c {
- StructToXML(e, v, sorted)
- }
- }
- }
-
- e.EncodeToken(xml.EndElement{Name: node.Name})
- return e.Flush()
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4.go
deleted file mode 100644
index d331475f4..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4.go
+++ /dev/null
@@ -1,296 +0,0 @@
-package v4
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/hex"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "github.com/awslabs/aws-sdk-go/aws"
-)
-
-const (
- authHeaderPrefix = "AWS4-HMAC-SHA256"
- timeFormat = "20060102T150405Z"
- shortTimeFormat = "20060102"
-)
-
-var ignoredHeaders = map[string]bool{
- "Authorization": true,
- "Content-Type": true,
- "Content-Length": true,
- "User-Agent": true,
-}
-
-type signer struct {
- Request *http.Request
- Time time.Time
- ExpireTime time.Duration
- ServiceName string
- Region string
- AccessKeyID string
- SecretAccessKey string
- SessionToken string
- Query url.Values
- Body io.ReadSeeker
- Debug uint
- Logger io.Writer
-
- isPresign bool
- formattedTime string
- formattedShortTime string
-
- signedHeaders string
- canonicalHeaders string
- canonicalString string
- credentialString string
- stringToSign string
- signature string
- authorization string
-}
-
-// Sign requests with signature version 4.
-func Sign(req *aws.Request) {
- creds, err := req.Service.Config.Credentials.Credentials()
- if err != nil {
- req.Error = err
- return
- }
-
- s := signer{
- Request: req.HTTPRequest,
- Time: req.Time,
- ExpireTime: req.ExpireTime,
- Query: req.HTTPRequest.URL.Query(),
- Body: req.Body,
- ServiceName: req.Service.ServiceName,
- Region: req.Service.Config.Region,
- AccessKeyID: creds.AccessKeyID,
- SecretAccessKey: creds.SecretAccessKey,
- SessionToken: creds.SessionToken,
- Debug: req.Service.Config.LogLevel,
- Logger: req.Service.Config.Logger,
- }
- s.sign()
- return
-}
-
-func (v4 *signer) sign() {
- if v4.ExpireTime != 0 {
- v4.isPresign = true
- }
-
- if v4.isPresign {
- v4.Query.Set("X-Amz-Algorithm", authHeaderPrefix)
- if v4.SessionToken != "" {
- v4.Query.Set("X-Amz-Security-Token", v4.SessionToken)
- } else {
- v4.Query.Del("X-Amz-Security-Token")
- }
- } else if v4.SessionToken != "" {
- v4.Request.Header.Set("X-Amz-Security-Token", v4.SessionToken)
- }
-
- v4.build()
-
- if v4.Debug > 0 {
- out := v4.Logger
- fmt.Fprintf(out, "---[ CANONICAL STRING ]-----------------------------\n")
- fmt.Fprintln(out, v4.canonicalString)
- fmt.Fprintf(out, "---[ STRING TO SIGN ]--------------------------------\n")
- fmt.Fprintln(out, v4.stringToSign)
- fmt.Fprintf(out, "---[ SIGNED URL ]--------------------------------\n")
- fmt.Fprintln(out, v4.Request.URL)
- fmt.Fprintf(out, "-----------------------------------------------------\n")
- }
-}
-
-func (v4 *signer) build() {
- v4.buildTime() // no depends
- v4.buildCredentialString() // no depends
- if v4.isPresign {
- v4.buildQuery() // no depends
- }
- v4.buildCanonicalHeaders() // depends on cred string
- v4.buildCanonicalString() // depends on canon headers / signed headers
- v4.buildStringToSign() // depends on canon string
- v4.buildSignature() // depends on string to sign
-
- if v4.isPresign {
- v4.Request.URL.RawQuery += "&X-Amz-Signature=" + v4.signature
- } else {
- parts := []string{
- authHeaderPrefix + " Credential=" + v4.AccessKeyID + "/" + v4.credentialString,
- "SignedHeaders=" + v4.signedHeaders,
- "Signature=" + v4.signature,
- }
- v4.Request.Header.Set("Authorization", strings.Join(parts, ", "))
- }
-}
-
-func (v4 *signer) buildTime() {
- v4.formattedTime = v4.Time.UTC().Format(timeFormat)
- v4.formattedShortTime = v4.Time.UTC().Format(shortTimeFormat)
-
- if v4.isPresign {
- duration := int64(v4.ExpireTime / time.Second)
- v4.Query.Set("X-Amz-Date", v4.formattedTime)
- v4.Query.Set("X-Amz-Expires", strconv.FormatInt(duration, 10))
- } else {
- v4.Request.Header.Set("X-Amz-Date", v4.formattedTime)
- }
-}
-
-func (v4 *signer) buildCredentialString() {
- v4.credentialString = strings.Join([]string{
- v4.formattedShortTime,
- v4.Region,
- v4.ServiceName,
- "aws4_request",
- }, "/")
-
- if v4.isPresign {
- v4.Query.Set("X-Amz-Credential", v4.AccessKeyID+"/"+v4.credentialString)
- }
-}
-
-func (v4 *signer) buildQuery() {
- for k, h := range v4.Request.Header {
- if strings.HasPrefix(http.CanonicalHeaderKey(k), "X-Amz-") {
- continue // never hoist x-amz-* headers, they must be signed
- }
- if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
- continue // never hoist ignored headers
- }
-
- v4.Request.Header.Del(k)
- v4.Query.Del(k)
- for _, v := range h {
- v4.Query.Add(k, v)
- }
- }
-}
-
-func (v4 *signer) buildCanonicalHeaders() {
- headers := make([]string, 0)
- headers = append(headers, "host")
- for k, _ := range v4.Request.Header {
- if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
- continue // ignored header
- }
- headers = append(headers, strings.ToLower(k))
- }
- sort.Strings(headers)
-
- v4.signedHeaders = strings.Join(headers, ";")
-
- if v4.isPresign {
- v4.Query.Set("X-Amz-SignedHeaders", v4.signedHeaders)
- }
-
- headerValues := make([]string, len(headers))
- for i, k := range headers {
- if k == "host" {
- headerValues[i] = "host:" + v4.Request.URL.Host
- } else {
- headerValues[i] = k + ":" +
- strings.Join(v4.Request.Header[http.CanonicalHeaderKey(k)], ",")
- }
- }
-
- v4.canonicalHeaders = strings.Join(headerValues, "\n")
-}
-
-func (v4 *signer) buildCanonicalString() {
- v4.Request.URL.RawQuery = v4.Query.Encode()
- uri := v4.Request.URL.Opaque
- if uri != "" {
- uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/")
- } else {
- uri = v4.Request.URL.Path
- }
- if uri == "" {
- uri = "/"
- }
-
- v4.canonicalString = strings.Join([]string{
- v4.Request.Method,
- uri,
- v4.Request.URL.RawQuery,
- v4.canonicalHeaders + "\n",
- v4.signedHeaders,
- v4.bodyDigest(),
- }, "\n")
-}
-
-func (v4 *signer) buildStringToSign() {
- v4.stringToSign = strings.Join([]string{
- authHeaderPrefix,
- v4.formattedTime,
- v4.credentialString,
- hex.EncodeToString(makeSha256([]byte(v4.canonicalString))),
- }, "\n")
-}
-
-func (v4 *signer) buildSignature() {
- secret := v4.SecretAccessKey
- date := makeHmac([]byte("AWS4"+secret), []byte(v4.formattedShortTime))
- region := makeHmac(date, []byte(v4.Region))
- service := makeHmac(region, []byte(v4.ServiceName))
- credentials := makeHmac(service, []byte("aws4_request"))
- signature := makeHmac(credentials, []byte(v4.stringToSign))
- v4.signature = hex.EncodeToString(signature)
-}
-
-func (v4 *signer) bodyDigest() string {
- hash := v4.Request.Header.Get("X-Amz-Content-Sha256")
- if hash == "" {
- if v4.isPresign && v4.ServiceName == "s3" {
- hash = "UNSIGNED-PAYLOAD"
- } else if v4.Body == nil {
- hash = hex.EncodeToString(makeSha256([]byte{}))
- } else {
- hash = hex.EncodeToString(makeSha256Reader(v4.Body))
- }
- v4.Request.Header.Add("X-Amz-Content-Sha256", hash)
- }
- return hash
-}
-
-func makeHmac(key []byte, data []byte) []byte {
- hash := hmac.New(sha256.New, key)
- hash.Write(data)
- return hash.Sum(nil)
-}
-
-func makeSha256(data []byte) []byte {
- hash := sha256.New()
- hash.Write(data)
- return hash.Sum(nil)
-}
-
-func makeSha256Reader(reader io.ReadSeeker) []byte {
- packet := make([]byte, 4096)
- hash := sha256.New()
-
- reader.Seek(0, 0)
- for {
- n, err := reader.Read(packet)
- if n > 0 {
- hash.Write(packet[0:n])
- }
- if err == io.EOF || n == 0 {
- break
- }
- }
- reader.Seek(0, 0)
-
- return hash.Sum(nil)
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4_test.go
deleted file mode 100644
index fb15c3949..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/signer/v4/v4_test.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package v4
-
-import (
- "net/http"
- "strings"
- "testing"
- "time"
-
- "github.com/stretchr/testify/assert"
-)
-
-func buildSigner(serviceName string, region string, signTime time.Time, expireTime time.Duration, body string) signer {
- endpoint := "https://" + serviceName + "." + region + ".amazonaws.com"
- reader := strings.NewReader(body)
- req, _ := http.NewRequest("POST", endpoint, reader)
- req.URL.Opaque = "//example.org/bucket/key-._~,!@#$%^&*()"
- req.Header.Add("X-Amz-Target", "prefix.Operation")
- req.Header.Add("Content-Type", "application/x-amz-json-1.0")
- req.Header.Add("Content-Length", string(len(body)))
- req.Header.Add("X-Amz-Meta-Other-Header", "some-value=!@#$%^&* ()")
-
- return signer{
- Request: req,
- Time: signTime,
- ExpireTime: expireTime,
- Query: req.URL.Query(),
- Body: reader,
- ServiceName: serviceName,
- Region: region,
- AccessKeyID: "AKID",
- SecretAccessKey: "SECRET",
- SessionToken: "SESSION",
- }
-}
-
-func removeWS(text string) string {
- text = strings.Replace(text, " ", "", -1)
- text = strings.Replace(text, "\n", "", -1)
- text = strings.Replace(text, "\t", "", -1)
- return text
-}
-
-func assertEqual(t *testing.T, expected, given string) {
- if removeWS(expected) != removeWS(given) {
- t.Errorf("\nExpected: %s\nGiven: %s", expected, given)
- }
-}
-
-func TestPresignRequest(t *testing.T) {
- signer := buildSigner("dynamodb", "us-east-1", time.Unix(0, 0), 300*time.Second, "{}")
- signer.sign()
-
- expectedDate := "19700101T000000Z"
- expectedHeaders := "host;x-amz-meta-other-header;x-amz-target"
- expectedSig := "41c18d68f9191079dfeead4e3f034328f89d86c79f8e9d51dd48bb70eaf623fc"
- expectedCred := "AKID/19700101/us-east-1/dynamodb/aws4_request"
-
- q := signer.Request.URL.Query()
- assert.Equal(t, expectedSig, q.Get("X-Amz-Signature"))
- assert.Equal(t, expectedCred, q.Get("X-Amz-Credential"))
- assert.Equal(t, expectedHeaders, q.Get("X-Amz-SignedHeaders"))
- assert.Equal(t, expectedDate, q.Get("X-Amz-Date"))
-}
-
-func TestSignRequest(t *testing.T) {
- signer := buildSigner("dynamodb", "us-east-1", time.Unix(0, 0), 0, "{}")
- signer.sign()
-
- expectedDate := "19700101T000000Z"
- expectedSig := "AWS4-HMAC-SHA256 Credential=AKID/19700101/us-east-1/dynamodb/aws4_request, SignedHeaders=host;x-amz-date;x-amz-meta-other-header;x-amz-security-token;x-amz-target, Signature=0196959cabd964bd10c05217b40ed151882dd394190438bab0c658dafdbff7a1"
-
- q := signer.Request.Header
- assert.Equal(t, expectedSig, q.Get("Authorization"))
- assert.Equal(t, expectedDate, q.Get("X-Amz-Date"))
-}
-
-func BenchmarkPresignRequest(b *testing.B) {
- signer := buildSigner("dynamodb", "us-east-1", time.Now(), 300*time.Second, "{}")
- for i := 0; i < b.N; i++ {
- signer.sign()
- }
-}
-
-func BenchmarkSignRequest(b *testing.B) {
- signer := buildSigner("dynamodb", "us-east-1", time.Now(), 0, "{}")
- for i := 0; i < b.N; i++ {
- signer.sign()
- }
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/api.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/api.go
deleted file mode 100644
index 8aea62dc6..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/api.go
+++ /dev/null
@@ -1,2738 +0,0 @@
-// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
-
-// Package route53 provides a client for Amazon Route 53.
-package route53
-
-import (
- "time"
-
- "github.com/awslabs/aws-sdk-go/aws"
-)
-
-// AssociateVPCWithHostedZoneRequest generates a request for the AssociateVPCWithHostedZone operation.
-func (c *Route53) AssociateVPCWithHostedZoneRequest(input *AssociateVPCWithHostedZoneInput) (req *aws.Request, output *AssociateVPCWithHostedZoneOutput) {
- if opAssociateVPCWithHostedZone == nil {
- opAssociateVPCWithHostedZone = &aws.Operation{
- Name: "AssociateVPCWithHostedZone",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/hostedzone/{Id}/associatevpc",
- }
- }
-
- req = c.newRequest(opAssociateVPCWithHostedZone, input, output)
- output = &AssociateVPCWithHostedZoneOutput{}
- req.Data = output
- return
-}
-
-// This action associates a VPC with an hosted zone.
-//
-// To associate a VPC with an hosted zone, send a POST request to the 2013-04-01/hostedzone/hosted
-// zone ID/associatevpc resource. The request body must include an XML document
-// with a AssociateVPCWithHostedZoneRequest element. The response returns the
-// AssociateVPCWithHostedZoneResponse element that contains ChangeInfo for you
-// to track the progress of the AssociateVPCWithHostedZoneRequest you made.
-// See GetChange operation for how to track the progress of your change.
-func (c *Route53) AssociateVPCWithHostedZone(input *AssociateVPCWithHostedZoneInput) (output *AssociateVPCWithHostedZoneOutput, err error) {
- req, out := c.AssociateVPCWithHostedZoneRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opAssociateVPCWithHostedZone *aws.Operation
-
-// ChangeResourceRecordSetsRequest generates a request for the ChangeResourceRecordSets operation.
-func (c *Route53) ChangeResourceRecordSetsRequest(input *ChangeResourceRecordSetsInput) (req *aws.Request, output *ChangeResourceRecordSetsOutput) {
- if opChangeResourceRecordSets == nil {
- opChangeResourceRecordSets = &aws.Operation{
- Name: "ChangeResourceRecordSets",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/hostedzone/{Id}/rrset/",
- }
- }
-
- req = c.newRequest(opChangeResourceRecordSets, input, output)
- output = &ChangeResourceRecordSetsOutput{}
- req.Data = output
- return
-}
-
-// Use this action to create or change your authoritative DNS information. To
-// use this action, send a POST request to the 2013-04-01/hostedzone/hosted
-// Zone ID/rrset resource. The request body must include an XML document with
-// a ChangeResourceRecordSetsRequest element.
-//
-// Changes are a list of change items and are considered transactional. For
-// more information on transactional changes, also known as change batches,
-// see Creating, Changing, and Deleting Resource Record Sets Using the Route
-// 53 API (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RRSchanges.html#RRSchanges_API)
-// in the Amazon Route 53 Developer Guide.
-//
-// Due to the nature of transactional changes, you cannot delete the same resource
-// record set more than once in a single change batch. If you attempt to delete
-// the same change batch more than once, Route 53 returns an InvalidChangeBatch
-// error. In response to a ChangeResourceRecordSets request, your DNS data is
-// changed on all Route 53 DNS servers. Initially, the status of a change is
-// PENDING. This means the change has not yet propagated to all the authoritative
-// Route 53 DNS servers. When the change is propagated to all hosts, the change
-// returns a status of INSYNC.
-//
-// Note the following limitations on a ChangeResourceRecordSets request:
-//
-// - A request cannot contain more than 100 Change elements.
-//
-// - A request cannot contain more than 1000 ResourceRecord elements.
-//
-// The sum of the number of characters (including spaces) in all Value elements
-// in a request cannot exceed 32,000 characters.
-func (c *Route53) ChangeResourceRecordSets(input *ChangeResourceRecordSetsInput) (output *ChangeResourceRecordSetsOutput, err error) {
- req, out := c.ChangeResourceRecordSetsRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opChangeResourceRecordSets *aws.Operation
-
-// ChangeTagsForResourceRequest generates a request for the ChangeTagsForResource operation.
-func (c *Route53) ChangeTagsForResourceRequest(input *ChangeTagsForResourceInput) (req *aws.Request, output *ChangeTagsForResourceOutput) {
- if opChangeTagsForResource == nil {
- opChangeTagsForResource = &aws.Operation{
- Name: "ChangeTagsForResource",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/tags/{ResourceType}/{ResourceId}",
- }
- }
-
- req = c.newRequest(opChangeTagsForResource, input, output)
- output = &ChangeTagsForResourceOutput{}
- req.Data = output
- return
-}
-
-func (c *Route53) ChangeTagsForResource(input *ChangeTagsForResourceInput) (output *ChangeTagsForResourceOutput, err error) {
- req, out := c.ChangeTagsForResourceRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opChangeTagsForResource *aws.Operation
-
-// CreateHealthCheckRequest generates a request for the CreateHealthCheck operation.
-func (c *Route53) CreateHealthCheckRequest(input *CreateHealthCheckInput) (req *aws.Request, output *CreateHealthCheckOutput) {
- if opCreateHealthCheck == nil {
- opCreateHealthCheck = &aws.Operation{
- Name: "CreateHealthCheck",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/healthcheck",
- }
- }
-
- req = c.newRequest(opCreateHealthCheck, input, output)
- output = &CreateHealthCheckOutput{}
- req.Data = output
- return
-}
-
-// This action creates a new health check.
-//
-// To create a new health check, send a POST request to the 2013-04-01/healthcheck
-// resource. The request body must include an XML document with a CreateHealthCheckRequest
-// element. The response returns the CreateHealthCheckResponse element that
-// contains metadata about the health check.
-func (c *Route53) CreateHealthCheck(input *CreateHealthCheckInput) (output *CreateHealthCheckOutput, err error) {
- req, out := c.CreateHealthCheckRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opCreateHealthCheck *aws.Operation
-
-// CreateHostedZoneRequest generates a request for the CreateHostedZone operation.
-func (c *Route53) CreateHostedZoneRequest(input *CreateHostedZoneInput) (req *aws.Request, output *CreateHostedZoneOutput) {
- if opCreateHostedZone == nil {
- opCreateHostedZone = &aws.Operation{
- Name: "CreateHostedZone",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/hostedzone",
- }
- }
-
- req = c.newRequest(opCreateHostedZone, input, output)
- output = &CreateHostedZoneOutput{}
- req.Data = output
- return
-}
-
-// This action creates a new hosted zone.
-//
-// To create a new hosted zone, send a POST request to the 2013-04-01/hostedzone
-// resource. The request body must include an XML document with a CreateHostedZoneRequest
-// element. The response returns the CreateHostedZoneResponse element that contains
-// metadata about the hosted zone.
-//
-// Route 53 automatically creates a default SOA record and four NS records
-// for the zone. The NS records in the hosted zone are the name servers you
-// give your registrar to delegate your domain to. For more information about
-// SOA and NS records, see NS and SOA Records that Route 53 Creates for a Hosted
-// Zone (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/SOA-NSrecords.html)
-// in the Amazon Route 53 Developer Guide.
-//
-// When you create a zone, its initial status is PENDING. This means that it
-// is not yet available on all DNS servers. The status of the zone changes to
-// INSYNC when the NS and SOA records are available on all Route 53 DNS servers.
-//
-// When trying to create a hosted zone using a reusable delegation set, you
-// could specify an optional DelegationSetId, and Route53 would assign those
-// 4 NS records for the zone, instead of alloting a new one.
-func (c *Route53) CreateHostedZone(input *CreateHostedZoneInput) (output *CreateHostedZoneOutput, err error) {
- req, out := c.CreateHostedZoneRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opCreateHostedZone *aws.Operation
-
-// CreateReusableDelegationSetRequest generates a request for the CreateReusableDelegationSet operation.
-func (c *Route53) CreateReusableDelegationSetRequest(input *CreateReusableDelegationSetInput) (req *aws.Request, output *CreateReusableDelegationSetOutput) {
- if opCreateReusableDelegationSet == nil {
- opCreateReusableDelegationSet = &aws.Operation{
- Name: "CreateReusableDelegationSet",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/delegationset",
- }
- }
-
- req = c.newRequest(opCreateReusableDelegationSet, input, output)
- output = &CreateReusableDelegationSetOutput{}
- req.Data = output
- return
-}
-
-// This action creates a reusable delegationSet.
-//
-// To create a new reusable delegationSet, send a POST request to the 2013-04-01/delegationset
-// resource. The request body must include an XML document with a CreateReusableDelegationSetRequest
-// element. The response returns the CreateReusableDelegationSetResponse element
-// that contains metadata about the delegationSet.
-//
-// If the optional parameter HostedZoneId is specified, it marks the delegationSet
-// associated with that particular hosted zone as reusable.
-func (c *Route53) CreateReusableDelegationSet(input *CreateReusableDelegationSetInput) (output *CreateReusableDelegationSetOutput, err error) {
- req, out := c.CreateReusableDelegationSetRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opCreateReusableDelegationSet *aws.Operation
-
-// DeleteHealthCheckRequest generates a request for the DeleteHealthCheck operation.
-func (c *Route53) DeleteHealthCheckRequest(input *DeleteHealthCheckInput) (req *aws.Request, output *DeleteHealthCheckOutput) {
- if opDeleteHealthCheck == nil {
- opDeleteHealthCheck = &aws.Operation{
- Name: "DeleteHealthCheck",
- HTTPMethod: "DELETE",
- HTTPPath: "/2013-04-01/healthcheck/{HealthCheckId}",
- }
- }
-
- req = c.newRequest(opDeleteHealthCheck, input, output)
- output = &DeleteHealthCheckOutput{}
- req.Data = output
- return
-}
-
-// This action deletes a health check. To delete a health check, send a DELETE
-// request to the 2013-04-01/healthcheck/health check ID resource.
-//
-// You can delete a health check only if there are no resource record sets
-// associated with this health check. If resource record sets are associated
-// with this health check, you must disassociate them before you can delete
-// your health check. If you try to delete a health check that is associated
-// with resource record sets, Route 53 will deny your request with a HealthCheckInUse
-// error. For information about disassociating the records from your health
-// check, see ChangeResourceRecordSets.
-func (c *Route53) DeleteHealthCheck(input *DeleteHealthCheckInput) (output *DeleteHealthCheckOutput, err error) {
- req, out := c.DeleteHealthCheckRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opDeleteHealthCheck *aws.Operation
-
-// DeleteHostedZoneRequest generates a request for the DeleteHostedZone operation.
-func (c *Route53) DeleteHostedZoneRequest(input *DeleteHostedZoneInput) (req *aws.Request, output *DeleteHostedZoneOutput) {
- if opDeleteHostedZone == nil {
- opDeleteHostedZone = &aws.Operation{
- Name: "DeleteHostedZone",
- HTTPMethod: "DELETE",
- HTTPPath: "/2013-04-01/hostedzone/{Id}",
- }
- }
-
- req = c.newRequest(opDeleteHostedZone, input, output)
- output = &DeleteHostedZoneOutput{}
- req.Data = output
- return
-}
-
-// This action deletes a hosted zone. To delete a hosted zone, send a DELETE
-// request to the 2013-04-01/hostedzone/hosted zone ID resource.
-//
-// For more information about deleting a hosted zone, see Deleting a Hosted
-// Zone (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DeleteHostedZone.html)
-// in the Amazon Route 53 Developer Guide.
-//
-// You can delete a hosted zone only if there are no resource record sets
-// other than the default SOA record and NS resource record sets. If your hosted
-// zone contains other resource record sets, you must delete them before you
-// can delete your hosted zone. If you try to delete a hosted zone that contains
-// other resource record sets, Route 53 will deny your request with a HostedZoneNotEmpty
-// error. For information about deleting records from your hosted zone, see
-// ChangeResourceRecordSets.
-func (c *Route53) DeleteHostedZone(input *DeleteHostedZoneInput) (output *DeleteHostedZoneOutput, err error) {
- req, out := c.DeleteHostedZoneRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opDeleteHostedZone *aws.Operation
-
-// DeleteReusableDelegationSetRequest generates a request for the DeleteReusableDelegationSet operation.
-func (c *Route53) DeleteReusableDelegationSetRequest(input *DeleteReusableDelegationSetInput) (req *aws.Request, output *DeleteReusableDelegationSetOutput) {
- if opDeleteReusableDelegationSet == nil {
- opDeleteReusableDelegationSet = &aws.Operation{
- Name: "DeleteReusableDelegationSet",
- HTTPMethod: "DELETE",
- HTTPPath: "/2013-04-01/delegationset/{Id}",
- }
- }
-
- req = c.newRequest(opDeleteReusableDelegationSet, input, output)
- output = &DeleteReusableDelegationSetOutput{}
- req.Data = output
- return
-}
-
-// This action deletes a reusable delegation set. To delete a reusable delegation
-// set, send a DELETE request to the 2013-04-01/delegationset/delegation set
-// ID resource.
-//
-// You can delete a reusable delegation set only if there are no associated
-// hosted zones. If your reusable delegation set contains associated hosted
-// zones, you must delete them before you can delete your reusable delegation
-// set. If you try to delete a reusable delegation set that contains associated
-// hosted zones, Route 53 will deny your request with a DelegationSetInUse error.
-func (c *Route53) DeleteReusableDelegationSet(input *DeleteReusableDelegationSetInput) (output *DeleteReusableDelegationSetOutput, err error) {
- req, out := c.DeleteReusableDelegationSetRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opDeleteReusableDelegationSet *aws.Operation
-
-// DisassociateVPCFromHostedZoneRequest generates a request for the DisassociateVPCFromHostedZone operation.
-func (c *Route53) DisassociateVPCFromHostedZoneRequest(input *DisassociateVPCFromHostedZoneInput) (req *aws.Request, output *DisassociateVPCFromHostedZoneOutput) {
- if opDisassociateVPCFromHostedZone == nil {
- opDisassociateVPCFromHostedZone = &aws.Operation{
- Name: "DisassociateVPCFromHostedZone",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/hostedzone/{Id}/disassociatevpc",
- }
- }
-
- req = c.newRequest(opDisassociateVPCFromHostedZone, input, output)
- output = &DisassociateVPCFromHostedZoneOutput{}
- req.Data = output
- return
-}
-
-// This action disassociates a VPC from an hosted zone.
-//
-// To disassociate a VPC to a hosted zone, send a POST request to the 2013-04-01/hostedzone/hosted
-// zone ID/disassociatevpc resource. The request body must include an XML document
-// with a DisassociateVPCFromHostedZoneRequest element. The response returns
-// the DisassociateVPCFromHostedZoneResponse element that contains ChangeInfo
-// for you to track the progress of the DisassociateVPCFromHostedZoneRequest
-// you made. See GetChange operation for how to track the progress of your change.
-func (c *Route53) DisassociateVPCFromHostedZone(input *DisassociateVPCFromHostedZoneInput) (output *DisassociateVPCFromHostedZoneOutput, err error) {
- req, out := c.DisassociateVPCFromHostedZoneRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opDisassociateVPCFromHostedZone *aws.Operation
-
-// GetChangeRequest generates a request for the GetChange operation.
-func (c *Route53) GetChangeRequest(input *GetChangeInput) (req *aws.Request, output *GetChangeOutput) {
- if opGetChange == nil {
- opGetChange = &aws.Operation{
- Name: "GetChange",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/change/{Id}",
- }
- }
-
- req = c.newRequest(opGetChange, input, output)
- output = &GetChangeOutput{}
- req.Data = output
- return
-}
-
-// This action returns the current status of a change batch request. The status
-// is one of the following values:
-//
-// - PENDING indicates that the changes in this request have not replicated
-// to all Route 53 DNS servers. This is the initial status of all change batch
-// requests.
-//
-// - INSYNC indicates that the changes have replicated to all Amazon Route
-// 53 DNS servers.
-func (c *Route53) GetChange(input *GetChangeInput) (output *GetChangeOutput, err error) {
- req, out := c.GetChangeRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetChange *aws.Operation
-
-// GetCheckerIPRangesRequest generates a request for the GetCheckerIPRanges operation.
-func (c *Route53) GetCheckerIPRangesRequest(input *GetCheckerIPRangesInput) (req *aws.Request, output *GetCheckerIPRangesOutput) {
- if opGetCheckerIPRanges == nil {
- opGetCheckerIPRanges = &aws.Operation{
- Name: "GetCheckerIpRanges",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/checkeripranges",
- }
- }
-
- req = c.newRequest(opGetCheckerIPRanges, input, output)
- output = &GetCheckerIPRangesOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a list of the IP ranges used by Amazon Route 53 health checkers
-// to check the health of your resources, send a GET request to the 2013-04-01/checkeripranges
-// resource. You can use these IP addresses to configure router and firewall
-// rules to allow health checkers to check the health of your resources.
-func (c *Route53) GetCheckerIPRanges(input *GetCheckerIPRangesInput) (output *GetCheckerIPRangesOutput, err error) {
- req, out := c.GetCheckerIPRangesRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetCheckerIPRanges *aws.Operation
-
-// GetGeoLocationRequest generates a request for the GetGeoLocation operation.
-func (c *Route53) GetGeoLocationRequest(input *GetGeoLocationInput) (req *aws.Request, output *GetGeoLocationOutput) {
- if opGetGeoLocation == nil {
- opGetGeoLocation = &aws.Operation{
- Name: "GetGeoLocation",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/geolocation",
- }
- }
-
- req = c.newRequest(opGetGeoLocation, input, output)
- output = &GetGeoLocationOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a single geo location, send a GET request to the 2013-04-01/geolocation
-// resource with one of these options: continentcode | countrycode | countrycode
-// and subdivisioncode.
-func (c *Route53) GetGeoLocation(input *GetGeoLocationInput) (output *GetGeoLocationOutput, err error) {
- req, out := c.GetGeoLocationRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetGeoLocation *aws.Operation
-
-// GetHealthCheckRequest generates a request for the GetHealthCheck operation.
-func (c *Route53) GetHealthCheckRequest(input *GetHealthCheckInput) (req *aws.Request, output *GetHealthCheckOutput) {
- if opGetHealthCheck == nil {
- opGetHealthCheck = &aws.Operation{
- Name: "GetHealthCheck",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/healthcheck/{HealthCheckId}",
- }
- }
-
- req = c.newRequest(opGetHealthCheck, input, output)
- output = &GetHealthCheckOutput{}
- req.Data = output
- return
-}
-
-// To retrieve the health check, send a GET request to the 2013-04-01/healthcheck/health
-// check ID resource.
-func (c *Route53) GetHealthCheck(input *GetHealthCheckInput) (output *GetHealthCheckOutput, err error) {
- req, out := c.GetHealthCheckRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetHealthCheck *aws.Operation
-
-// GetHealthCheckCountRequest generates a request for the GetHealthCheckCount operation.
-func (c *Route53) GetHealthCheckCountRequest(input *GetHealthCheckCountInput) (req *aws.Request, output *GetHealthCheckCountOutput) {
- if opGetHealthCheckCount == nil {
- opGetHealthCheckCount = &aws.Operation{
- Name: "GetHealthCheckCount",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/healthcheckcount",
- }
- }
-
- req = c.newRequest(opGetHealthCheckCount, input, output)
- output = &GetHealthCheckCountOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a count of all your health checks, send a GET request to the
-// 2013-04-01/healthcheckcount resource.
-func (c *Route53) GetHealthCheckCount(input *GetHealthCheckCountInput) (output *GetHealthCheckCountOutput, err error) {
- req, out := c.GetHealthCheckCountRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetHealthCheckCount *aws.Operation
-
-// GetHealthCheckLastFailureReasonRequest generates a request for the GetHealthCheckLastFailureReason operation.
-func (c *Route53) GetHealthCheckLastFailureReasonRequest(input *GetHealthCheckLastFailureReasonInput) (req *aws.Request, output *GetHealthCheckLastFailureReasonOutput) {
- if opGetHealthCheckLastFailureReason == nil {
- opGetHealthCheckLastFailureReason = &aws.Operation{
- Name: "GetHealthCheckLastFailureReason",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/healthcheck/{HealthCheckId}/lastfailurereason",
- }
- }
-
- req = c.newRequest(opGetHealthCheckLastFailureReason, input, output)
- output = &GetHealthCheckLastFailureReasonOutput{}
- req.Data = output
- return
-}
-
-// If you want to learn why a health check is currently failing or why it failed
-// most recently (if at all), you can get the failure reason for the most recent
-// failure. Send a GET request to the 2013-04-01/healthcheck/health check ID/lastfailurereason
-// resource.
-func (c *Route53) GetHealthCheckLastFailureReason(input *GetHealthCheckLastFailureReasonInput) (output *GetHealthCheckLastFailureReasonOutput, err error) {
- req, out := c.GetHealthCheckLastFailureReasonRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetHealthCheckLastFailureReason *aws.Operation
-
-// GetHealthCheckStatusRequest generates a request for the GetHealthCheckStatus operation.
-func (c *Route53) GetHealthCheckStatusRequest(input *GetHealthCheckStatusInput) (req *aws.Request, output *GetHealthCheckStatusOutput) {
- if opGetHealthCheckStatus == nil {
- opGetHealthCheckStatus = &aws.Operation{
- Name: "GetHealthCheckStatus",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/healthcheck/{HealthCheckId}/status",
- }
- }
-
- req = c.newRequest(opGetHealthCheckStatus, input, output)
- output = &GetHealthCheckStatusOutput{}
- req.Data = output
- return
-}
-
-// To retrieve the health check status, send a GET request to the 2013-04-01/healthcheck/health
-// check ID/status resource. You can use this call to get a health check's current
-// status.
-func (c *Route53) GetHealthCheckStatus(input *GetHealthCheckStatusInput) (output *GetHealthCheckStatusOutput, err error) {
- req, out := c.GetHealthCheckStatusRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetHealthCheckStatus *aws.Operation
-
-// GetHostedZoneRequest generates a request for the GetHostedZone operation.
-func (c *Route53) GetHostedZoneRequest(input *GetHostedZoneInput) (req *aws.Request, output *GetHostedZoneOutput) {
- if opGetHostedZone == nil {
- opGetHostedZone = &aws.Operation{
- Name: "GetHostedZone",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/hostedzone/{Id}",
- }
- }
-
- req = c.newRequest(opGetHostedZone, input, output)
- output = &GetHostedZoneOutput{}
- req.Data = output
- return
-}
-
-// To retrieve the delegation set for a hosted zone, send a GET request to the
-// 2013-04-01/hostedzone/hosted zone ID resource. The delegation set is the
-// four Route 53 name servers that were assigned to the hosted zone when you
-// created it.
-func (c *Route53) GetHostedZone(input *GetHostedZoneInput) (output *GetHostedZoneOutput, err error) {
- req, out := c.GetHostedZoneRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetHostedZone *aws.Operation
-
-// GetHostedZoneCountRequest generates a request for the GetHostedZoneCount operation.
-func (c *Route53) GetHostedZoneCountRequest(input *GetHostedZoneCountInput) (req *aws.Request, output *GetHostedZoneCountOutput) {
- if opGetHostedZoneCount == nil {
- opGetHostedZoneCount = &aws.Operation{
- Name: "GetHostedZoneCount",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/hostedzonecount",
- }
- }
-
- req = c.newRequest(opGetHostedZoneCount, input, output)
- output = &GetHostedZoneCountOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a count of all your hosted zones, send a GET request to the 2013-04-01/hostedzonecount
-// resource.
-func (c *Route53) GetHostedZoneCount(input *GetHostedZoneCountInput) (output *GetHostedZoneCountOutput, err error) {
- req, out := c.GetHostedZoneCountRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetHostedZoneCount *aws.Operation
-
-// GetReusableDelegationSetRequest generates a request for the GetReusableDelegationSet operation.
-func (c *Route53) GetReusableDelegationSetRequest(input *GetReusableDelegationSetInput) (req *aws.Request, output *GetReusableDelegationSetOutput) {
- if opGetReusableDelegationSet == nil {
- opGetReusableDelegationSet = &aws.Operation{
- Name: "GetReusableDelegationSet",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/delegationset/{Id}",
- }
- }
-
- req = c.newRequest(opGetReusableDelegationSet, input, output)
- output = &GetReusableDelegationSetOutput{}
- req.Data = output
- return
-}
-
-// To retrieve the reusable delegation set, send a GET request to the 2013-04-01/delegationset/delegation
-// set ID resource.
-func (c *Route53) GetReusableDelegationSet(input *GetReusableDelegationSetInput) (output *GetReusableDelegationSetOutput, err error) {
- req, out := c.GetReusableDelegationSetRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opGetReusableDelegationSet *aws.Operation
-
-// ListGeoLocationsRequest generates a request for the ListGeoLocations operation.
-func (c *Route53) ListGeoLocationsRequest(input *ListGeoLocationsInput) (req *aws.Request, output *ListGeoLocationsOutput) {
- if opListGeoLocations == nil {
- opListGeoLocations = &aws.Operation{
- Name: "ListGeoLocations",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/geolocations",
- }
- }
-
- req = c.newRequest(opListGeoLocations, input, output)
- output = &ListGeoLocationsOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a list of supported geo locations, send a GET request to the
-// 2013-04-01/geolocations resource. The response to this request includes a
-// GeoLocationDetailsList element with zero, one, or multiple GeoLocationDetails
-// child elements. The list is sorted by country code, and then subdivision
-// code, followed by continents at the end of the list.
-//
-// By default, the list of geo locations is displayed on a single page. You
-// can control the length of the page that is displayed by using the MaxItems
-// parameter. If the list is truncated, IsTruncated will be set to true and
-// a combination of NextContinentCode, NextCountryCode, NextSubdivisionCode
-// will be populated. You can pass these as parameters to StartContinentCode,
-// StartCountryCode, StartSubdivisionCode to control the geo location that the
-// list begins with.
-func (c *Route53) ListGeoLocations(input *ListGeoLocationsInput) (output *ListGeoLocationsOutput, err error) {
- req, out := c.ListGeoLocationsRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListGeoLocations *aws.Operation
-
-// ListHealthChecksRequest generates a request for the ListHealthChecks operation.
-func (c *Route53) ListHealthChecksRequest(input *ListHealthChecksInput) (req *aws.Request, output *ListHealthChecksOutput) {
- if opListHealthChecks == nil {
- opListHealthChecks = &aws.Operation{
- Name: "ListHealthChecks",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/healthcheck",
- }
- }
-
- req = c.newRequest(opListHealthChecks, input, output)
- output = &ListHealthChecksOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a list of your health checks, send a GET request to the 2013-04-01/healthcheck
-// resource. The response to this request includes a HealthChecks element with
-// zero, one, or multiple HealthCheck child elements. By default, the list of
-// health checks is displayed on a single page. You can control the length of
-// the page that is displayed by using the MaxItems parameter. You can use the
-// Marker parameter to control the health check that the list begins with.
-//
-// Amazon Route 53 returns a maximum of 100 items. If you set MaxItems to
-// a value greater than 100, Amazon Route 53 returns only the first 100.
-func (c *Route53) ListHealthChecks(input *ListHealthChecksInput) (output *ListHealthChecksOutput, err error) {
- req, out := c.ListHealthChecksRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListHealthChecks *aws.Operation
-
-// ListHostedZonesRequest generates a request for the ListHostedZones operation.
-func (c *Route53) ListHostedZonesRequest(input *ListHostedZonesInput) (req *aws.Request, output *ListHostedZonesOutput) {
- if opListHostedZones == nil {
- opListHostedZones = &aws.Operation{
- Name: "ListHostedZones",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/hostedzone",
- }
- }
-
- req = c.newRequest(opListHostedZones, input, output)
- output = &ListHostedZonesOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a list of your hosted zones, send a GET request to the 2013-04-01/hostedzone
-// resource. The response to this request includes a HostedZones element with
-// zero, one, or multiple HostedZone child elements. By default, the list of
-// hosted zones is displayed on a single page. You can control the length of
-// the page that is displayed by using the MaxItems parameter. You can use the
-// Marker parameter to control the hosted zone that the list begins with.
-//
-// Amazon Route 53 returns a maximum of 100 items. If you set MaxItems to
-// a value greater than 100, Amazon Route 53 returns only the first 100.
-func (c *Route53) ListHostedZones(input *ListHostedZonesInput) (output *ListHostedZonesOutput, err error) {
- req, out := c.ListHostedZonesRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListHostedZones *aws.Operation
-
-// ListHostedZonesByNameRequest generates a request for the ListHostedZonesByName operation.
-func (c *Route53) ListHostedZonesByNameRequest(input *ListHostedZonesByNameInput) (req *aws.Request, output *ListHostedZonesByNameOutput) {
- if opListHostedZonesByName == nil {
- opListHostedZonesByName = &aws.Operation{
- Name: "ListHostedZonesByName",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/hostedzonesbyname",
- }
- }
-
- req = c.newRequest(opListHostedZonesByName, input, output)
- output = &ListHostedZonesByNameOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a list of your hosted zones in lexicographic order, send a GET
-// request to the 2013-04-01/hostedzonesbyname resource. The response to this
-// request includes a HostedZones element with zero or more HostedZone child
-// elements lexicographically ordered by DNS name. By default, the list of hosted
-// zones is displayed on a single page. You can control the length of the page
-// that is displayed by using the MaxItems parameter. You can use the DNSName
-// and HostedZoneId parameters to control the hosted zone that the list begins
-// with.
-//
-// Amazon Route 53 returns a maximum of 100 items. If you set MaxItems to
-// a value greater than 100, Amazon Route 53 returns only the first 100.
-func (c *Route53) ListHostedZonesByName(input *ListHostedZonesByNameInput) (output *ListHostedZonesByNameOutput, err error) {
- req, out := c.ListHostedZonesByNameRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListHostedZonesByName *aws.Operation
-
-// ListResourceRecordSetsRequest generates a request for the ListResourceRecordSets operation.
-func (c *Route53) ListResourceRecordSetsRequest(input *ListResourceRecordSetsInput) (req *aws.Request, output *ListResourceRecordSetsOutput) {
- if opListResourceRecordSets == nil {
- opListResourceRecordSets = &aws.Operation{
- Name: "ListResourceRecordSets",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/hostedzone/{Id}/rrset",
- }
- }
-
- req = c.newRequest(opListResourceRecordSets, input, output)
- output = &ListResourceRecordSetsOutput{}
- req.Data = output
- return
-}
-
-// Imagine all the resource record sets in a zone listed out in front of you.
-// Imagine them sorted lexicographically first by DNS name (with the labels
-// reversed, like "com.amazon.www" for example), and secondarily, lexicographically
-// by record type. This operation retrieves at most MaxItems resource record
-// sets from this list, in order, starting at a position specified by the Name
-// and Type arguments:
-//
-// If both Name and Type are omitted, this means start the results at the
-// first RRSET in the HostedZone. If Name is specified but Type is omitted,
-// this means start the results at the first RRSET in the list whose name is
-// greater than or equal to Name. If both Name and Type are specified, this
-// means start the results at the first RRSET in the list whose name is greater
-// than or equal to Name and whose type is greater than or equal to Type. It
-// is an error to specify the Type but not the Name. Use ListResourceRecordSets
-// to retrieve a single known record set by specifying the record set's name
-// and type, and setting MaxItems = 1
-//
-// To retrieve all the records in a HostedZone, first pause any processes making
-// calls to ChangeResourceRecordSets. Initially call ListResourceRecordSets
-// without a Name and Type to get the first page of record sets. For subsequent
-// calls, set Name and Type to the NextName and NextType values returned by
-// the previous response.
-//
-// In the presence of concurrent ChangeResourceRecordSets calls, there is no
-// consistency of results across calls to ListResourceRecordSets. The only way
-// to get a consistent multi-page snapshot of all RRSETs in a zone is to stop
-// making changes while pagination is in progress.
-//
-// However, the results from ListResourceRecordSets are consistent within a
-// page. If MakeChange calls are taking place concurrently, the result of each
-// one will either be completely visible in your results or not at all. You
-// will not see partial changes, or changes that do not ultimately succeed.
-// (This follows from the fact that MakeChange is atomic)
-//
-// The results from ListResourceRecordSets are strongly consistent with ChangeResourceRecordSets.
-// To be precise, if a single process makes a call to ChangeResourceRecordSets
-// and receives a successful response, the effects of that change will be visible
-// in a subsequent call to ListResourceRecordSets by that process.
-func (c *Route53) ListResourceRecordSets(input *ListResourceRecordSetsInput) (output *ListResourceRecordSetsOutput, err error) {
- req, out := c.ListResourceRecordSetsRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListResourceRecordSets *aws.Operation
-
-// ListReusableDelegationSetsRequest generates a request for the ListReusableDelegationSets operation.
-func (c *Route53) ListReusableDelegationSetsRequest(input *ListReusableDelegationSetsInput) (req *aws.Request, output *ListReusableDelegationSetsOutput) {
- if opListReusableDelegationSets == nil {
- opListReusableDelegationSets = &aws.Operation{
- Name: "ListReusableDelegationSets",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/delegationset",
- }
- }
-
- req = c.newRequest(opListReusableDelegationSets, input, output)
- output = &ListReusableDelegationSetsOutput{}
- req.Data = output
- return
-}
-
-// To retrieve a list of your reusable delegation sets, send a GET request to
-// the 2013-04-01/delegationset resource. The response to this request includes
-// a DelegationSets element with zero, one, or multiple DelegationSet child
-// elements. By default, the list of delegation sets is displayed on a single
-// page. You can control the length of the page that is displayed by using the
-// MaxItems parameter. You can use the Marker parameter to control the delegation
-// set that the list begins with.
-//
-// Amazon Route 53 returns a maximum of 100 items. If you set MaxItems to
-// a value greater than 100, Amazon Route 53 returns only the first 100.
-func (c *Route53) ListReusableDelegationSets(input *ListReusableDelegationSetsInput) (output *ListReusableDelegationSetsOutput, err error) {
- req, out := c.ListReusableDelegationSetsRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListReusableDelegationSets *aws.Operation
-
-// ListTagsForResourceRequest generates a request for the ListTagsForResource operation.
-func (c *Route53) ListTagsForResourceRequest(input *ListTagsForResourceInput) (req *aws.Request, output *ListTagsForResourceOutput) {
- if opListTagsForResource == nil {
- opListTagsForResource = &aws.Operation{
- Name: "ListTagsForResource",
- HTTPMethod: "GET",
- HTTPPath: "/2013-04-01/tags/{ResourceType}/{ResourceId}",
- }
- }
-
- req = c.newRequest(opListTagsForResource, input, output)
- output = &ListTagsForResourceOutput{}
- req.Data = output
- return
-}
-
-func (c *Route53) ListTagsForResource(input *ListTagsForResourceInput) (output *ListTagsForResourceOutput, err error) {
- req, out := c.ListTagsForResourceRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListTagsForResource *aws.Operation
-
-// ListTagsForResourcesRequest generates a request for the ListTagsForResources operation.
-func (c *Route53) ListTagsForResourcesRequest(input *ListTagsForResourcesInput) (req *aws.Request, output *ListTagsForResourcesOutput) {
- if opListTagsForResources == nil {
- opListTagsForResources = &aws.Operation{
- Name: "ListTagsForResources",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/tags/{ResourceType}",
- }
- }
-
- req = c.newRequest(opListTagsForResources, input, output)
- output = &ListTagsForResourcesOutput{}
- req.Data = output
- return
-}
-
-func (c *Route53) ListTagsForResources(input *ListTagsForResourcesInput) (output *ListTagsForResourcesOutput, err error) {
- req, out := c.ListTagsForResourcesRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opListTagsForResources *aws.Operation
-
-// UpdateHealthCheckRequest generates a request for the UpdateHealthCheck operation.
-func (c *Route53) UpdateHealthCheckRequest(input *UpdateHealthCheckInput) (req *aws.Request, output *UpdateHealthCheckOutput) {
- if opUpdateHealthCheck == nil {
- opUpdateHealthCheck = &aws.Operation{
- Name: "UpdateHealthCheck",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/healthcheck/{HealthCheckId}",
- }
- }
-
- req = c.newRequest(opUpdateHealthCheck, input, output)
- output = &UpdateHealthCheckOutput{}
- req.Data = output
- return
-}
-
-// This action updates an existing health check.
-//
-// To update a health check, send a POST request to the 2013-04-01/healthcheck/health
-// check ID resource. The request body must include an XML document with an
-// UpdateHealthCheckRequest element. The response returns an UpdateHealthCheckResponse
-// element, which contains metadata about the health check.
-func (c *Route53) UpdateHealthCheck(input *UpdateHealthCheckInput) (output *UpdateHealthCheckOutput, err error) {
- req, out := c.UpdateHealthCheckRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opUpdateHealthCheck *aws.Operation
-
-// UpdateHostedZoneCommentRequest generates a request for the UpdateHostedZoneComment operation.
-func (c *Route53) UpdateHostedZoneCommentRequest(input *UpdateHostedZoneCommentInput) (req *aws.Request, output *UpdateHostedZoneCommentOutput) {
- if opUpdateHostedZoneComment == nil {
- opUpdateHostedZoneComment = &aws.Operation{
- Name: "UpdateHostedZoneComment",
- HTTPMethod: "POST",
- HTTPPath: "/2013-04-01/hostedzone/{Id}",
- }
- }
-
- req = c.newRequest(opUpdateHostedZoneComment, input, output)
- output = &UpdateHostedZoneCommentOutput{}
- req.Data = output
- return
-}
-
-// To update the hosted zone comment, send a POST request to the 2013-04-01/hostedzone/hosted
-// zone ID resource. The request body must include an XML document with a UpdateHostedZoneCommentRequest
-// element. The response to this request includes the modified HostedZone element.
-//
-// The comment can have a maximum length of 256 characters.
-func (c *Route53) UpdateHostedZoneComment(input *UpdateHostedZoneCommentInput) (output *UpdateHostedZoneCommentOutput, err error) {
- req, out := c.UpdateHostedZoneCommentRequest(input)
- output = out
- err = req.Send()
- return
-}
-
-var opUpdateHostedZoneComment *aws.Operation
-
-// Alias resource record sets only: Information about the domain to which you
-// are redirecting traffic.
-//
-// For more information and an example, see Creating Alias Resource Record
-// Sets (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingAliasRRSets.html)
-// in the Amazon Route 53 Developer Guide
-//
-// .
-type AliasTarget struct {
- // Alias resource record sets only: The external DNS name associated with the
- // AWS Resource.
- //
- // For more information and an example, see Creating Alias Resource Record
- // Sets (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingAliasRRSets.html)
- // in the Amazon Route 53 Developer Guide
- //
- // .
- DNSName *string `type:"string" required:"true"`
-
- // Alias resource record sets only: A boolean value that indicates whether this
- // Resource Record Set should respect the health status of any health checks
- // associated with the ALIAS target record which it is linked to.
- //
- // For more information and an example, see Creating Alias Resource Record
- // Sets (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingAliasRRSets.html)
- // in the Amazon Route 53 Developer Guide
- //
- // .
- EvaluateTargetHealth *bool `type:"boolean" required:"true"`
-
- // Alias resource record sets only: The value of the hosted zone ID for the
- // AWS resource.
- //
- // For more information and an example, see Creating Alias Resource Record
- // Sets (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingAliasRRSets.html)
- // in the Amazon Route 53 Developer Guide
- //
- // .
- HostedZoneID *string `locationName:"HostedZoneId" type:"string" required:"true"`
-
- metadataAliasTarget `json:"-", xml:"-"`
-}
-
-type metadataAliasTarget struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to associate a
-// VPC with an hosted zone.
-type AssociateVPCWithHostedZoneInput struct {
- // Optional: Any comments you want to include about a AssociateVPCWithHostedZoneRequest.
- Comment *string `type:"string"`
-
- // The ID of the hosted zone you want to associate your VPC with.
- //
- // Note that you cannot associate a VPC with a hosted zone that doesn't have
- // an existing VPC association.
- HostedZoneID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- // The VPC that you want your hosted zone to be associated with.
- VPC *VPC `type:"structure" required:"true"`
-
- metadataAssociateVPCWithHostedZoneInput `json:"-", xml:"-"`
-}
-
-type metadataAssociateVPCWithHostedZoneInput struct {
- SDKShapeTraits bool `locationName:"AssociateVPCWithHostedZoneRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing the response information for the request.
-type AssociateVPCWithHostedZoneOutput struct {
- // A complex type that contains the ID, the status, and the date and time of
- // your AssociateVPCWithHostedZoneRequest.
- ChangeInfo *ChangeInfo `type:"structure" required:"true"`
-
- metadataAssociateVPCWithHostedZoneOutput `json:"-", xml:"-"`
-}
-
-type metadataAssociateVPCWithHostedZoneOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the information for each change in a change
-// batch request.
-type Change struct {
- // The action to perform.
- //
- // Valid values: CREATE | DELETE | UPSERT
- Action *string `type:"string" required:"true"`
-
- // Information about the resource record set to create or delete.
- ResourceRecordSet *ResourceRecordSet `type:"structure" required:"true"`
-
- metadataChange `json:"-", xml:"-"`
-}
-
-type metadataChange struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains an optional comment and the changes that you
-// want to make with a change batch request.
-type ChangeBatch struct {
- // A complex type that contains one Change element for each resource record
- // set that you want to create or delete.
- Changes []*Change `locationNameList:"Change" type:"list" required:"true"`
-
- // Optional: Any comments you want to include about a change batch request.
- Comment *string `type:"string"`
-
- metadataChangeBatch `json:"-", xml:"-"`
-}
-
-type metadataChangeBatch struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that describes change information about changes made to your
-// hosted zone.
-//
-// This element contains an ID that you use when performing a GetChange action
-// to get detailed information about the change.
-type ChangeInfo struct {
- // A complex type that describes change information about changes made to your
- // hosted zone.
- //
- // This element contains an ID that you use when performing a GetChange action
- // to get detailed information about the change.
- Comment *string `type:"string"`
-
- // The ID of the request. Use this ID to track when the change has completed
- // across all Amazon Route 53 DNS servers.
- ID *string `locationName:"Id" type:"string" required:"true"`
-
- // The current state of the request. PENDING indicates that this request has
- // not yet been applied to all Amazon Route 53 DNS servers.
- //
- // Valid Values: PENDING | INSYNC
- Status *string `type:"string" required:"true"`
-
- // The date and time the change was submitted, in the format YYYY-MM-DDThh:mm:ssZ,
- // as specified in the ISO 8601 standard (for example, 2009-11-19T19:37:58Z).
- // The Z after the time indicates that the time is listed in Coordinated Universal
- // Time (UTC), which is synonymous with Greenwich Mean Time in this context.
- SubmittedAt *time.Time `type:"timestamp" timestampFormat:"iso8601" required:"true"`
-
- metadataChangeInfo `json:"-", xml:"-"`
-}
-
-type metadataChangeInfo struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains a change batch.
-type ChangeResourceRecordSetsInput struct {
- // A complex type that contains an optional comment and the Changes element.
- ChangeBatch *ChangeBatch `type:"structure" required:"true"`
-
- // The ID of the hosted zone that contains the resource record sets that you
- // want to change.
- HostedZoneID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataChangeResourceRecordSetsInput `json:"-", xml:"-"`
-}
-
-type metadataChangeResourceRecordSetsInput struct {
- SDKShapeTraits bool `locationName:"ChangeResourceRecordSetsRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing the response for the request.
-type ChangeResourceRecordSetsOutput struct {
- // A complex type that contains information about changes made to your hosted
- // zone.
- //
- // This element contains an ID that you use when performing a GetChange action
- // to get detailed information about the change.
- ChangeInfo *ChangeInfo `type:"structure" required:"true"`
-
- metadataChangeResourceRecordSetsOutput `json:"-", xml:"-"`
-}
-
-type metadataChangeResourceRecordSetsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about a request to add, change, or
-// delete the tags that are associated with a resource.
-type ChangeTagsForResourceInput struct {
- // A complex type that contains a list of Tag elements. Each Tag element identifies
- // a tag that you want to add or update for the specified resource.
- AddTags []*Tag `locationNameList:"Tag" type:"list"`
-
- // A list of Tag keys that you want to remove from the specified resource.
- RemoveTagKeys []*string `locationNameList:"Key" type:"list"`
-
- // The ID of the resource for which you want to add, change, or delete tags.
- ResourceID *string `location:"uri" locationName:"ResourceId" type:"string" required:"true"`
-
- // The type of the resource.
- //
- // - The resource type for health checks is healthcheck.
- //
- // - The resource type for hosted zones is hostedzone.
- ResourceType *string `location:"uri" locationName:"ResourceType" type:"string" required:"true"`
-
- metadataChangeTagsForResourceInput `json:"-", xml:"-"`
-}
-
-type metadataChangeTagsForResourceInput struct {
- SDKShapeTraits bool `locationName:"ChangeTagsForResourceRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// Empty response for the request.
-type ChangeTagsForResourceOutput struct {
- metadataChangeTagsForResourceOutput `json:"-", xml:"-"`
-}
-
-type metadataChangeTagsForResourceOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// >A complex type that contains information about the request to create a health
-// check.
-type CreateHealthCheckInput struct {
- // A unique string that identifies the request and that allows failed CreateHealthCheck
- // requests to be retried without the risk of executing the operation twice.
- // You must use a unique CallerReference string every time you create a health
- // check. CallerReference can be any unique string; you might choose to use
- // a string that identifies your project.
- //
- // Valid characters are any Unicode code points that are legal in an XML 1.0
- // document. The UTF-8 encoding of the value must be less than 128 bytes.
- CallerReference *string `type:"string" required:"true"`
-
- // A complex type that contains health check configuration.
- HealthCheckConfig *HealthCheckConfig `type:"structure" required:"true"`
-
- metadataCreateHealthCheckInput `json:"-", xml:"-"`
-}
-
-type metadataCreateHealthCheckInput struct {
- SDKShapeTraits bool `locationName:"CreateHealthCheckRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing the response information for the new health check.
-type CreateHealthCheckOutput struct {
- // A complex type that contains identifying information about the health check.
- HealthCheck *HealthCheck `type:"structure" required:"true"`
-
- // The unique URL representing the new health check.
- Location *string `location:"header" locationName:"Location" type:"string" required:"true"`
-
- metadataCreateHealthCheckOutput `json:"-", xml:"-"`
-}
-
-type metadataCreateHealthCheckOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to create a hosted
-// zone.
-type CreateHostedZoneInput struct {
- // A unique string that identifies the request and that allows failed CreateHostedZone
- // requests to be retried without the risk of executing the operation twice.
- // You must use a unique CallerReference string every time you create a hosted
- // zone. CallerReference can be any unique string; you might choose to use a
- // string that identifies your project, such as DNSMigration_01.
- //
- // Valid characters are any Unicode code points that are legal in an XML 1.0
- // document. The UTF-8 encoding of the value must be less than 128 bytes.
- CallerReference *string `type:"string" required:"true"`
-
- // The delegation set id of the reusable delgation set whose NS records you
- // want to assign to the new hosted zone.
- DelegationSetID *string `locationName:"DelegationSetId" type:"string"`
-
- // A complex type that contains an optional comment about your hosted zone.
- HostedZoneConfig *HostedZoneConfig `type:"structure"`
-
- // The name of the domain. This must be a fully-specified domain, for example,
- // www.example.com. The trailing dot is optional; Route 53 assumes that the
- // domain name is fully qualified. This means that Route 53 treats www.example.com
- // (without a trailing dot) and www.example.com. (with a trailing dot) as identical.
- //
- // This is the name you have registered with your DNS registrar. You should
- // ask your registrar to change the authoritative name servers for your domain
- // to the set of NameServers elements returned in DelegationSet.
- Name *string `type:"string" required:"true"`
-
- // The VPC that you want your hosted zone to be associated with. By providing
- // this parameter, your newly created hosted cannot be resolved anywhere other
- // than the given VPC.
- VPC *VPC `type:"structure"`
-
- metadataCreateHostedZoneInput `json:"-", xml:"-"`
-}
-
-type metadataCreateHostedZoneInput struct {
- SDKShapeTraits bool `locationName:"CreateHostedZoneRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing the response information for the new hosted zone.
-type CreateHostedZoneOutput struct {
- // A complex type that contains information about the request to create a hosted
- // zone. This includes an ID that you use when you call the GetChange action
- // to get the current status of the change request.
- ChangeInfo *ChangeInfo `type:"structure" required:"true"`
-
- // A complex type that contains name server information.
- DelegationSet *DelegationSet `type:"structure" required:"true"`
-
- // A complex type that contains identifying information about the hosted zone.
- HostedZone *HostedZone `type:"structure" required:"true"`
-
- // The unique URL representing the new hosted zone.
- Location *string `location:"header" locationName:"Location" type:"string" required:"true"`
-
- VPC *VPC `type:"structure"`
-
- metadataCreateHostedZoneOutput `json:"-", xml:"-"`
-}
-
-type metadataCreateHostedZoneOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CreateReusableDelegationSetInput struct {
- // A unique string that identifies the request and that allows failed CreateReusableDelegationSet
- // requests to be retried without the risk of executing the operation twice.
- // You must use a unique CallerReference string every time you create a reusable
- // delegation set. CallerReference can be any unique string; you might choose
- // to use a string that identifies your project, such as DNSMigration_01.
- //
- // Valid characters are any Unicode code points that are legal in an XML 1.0
- // document. The UTF-8 encoding of the value must be less than 128 bytes.
- CallerReference *string `type:"string" required:"true"`
-
- // The ID of the hosted zone whose delegation set you want to mark as reusable.
- // It is an optional parameter.
- HostedZoneID *string `locationName:"HostedZoneId" type:"string"`
-
- metadataCreateReusableDelegationSetInput `json:"-", xml:"-"`
-}
-
-type metadataCreateReusableDelegationSetInput struct {
- SDKShapeTraits bool `locationName:"CreateReusableDelegationSetRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-type CreateReusableDelegationSetOutput struct {
- // A complex type that contains name server information.
- DelegationSet *DelegationSet `type:"structure" required:"true"`
-
- // The unique URL representing the new reusbale delegation set.
- Location *string `location:"header" locationName:"Location" type:"string" required:"true"`
-
- metadataCreateReusableDelegationSetOutput `json:"-", xml:"-"`
-}
-
-type metadataCreateReusableDelegationSetOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains name server information.
-type DelegationSet struct {
- CallerReference *string `type:"string"`
-
- ID *string `locationName:"Id" type:"string"`
-
- // A complex type that contains the authoritative name servers for the hosted
- // zone. Use the method provided by your domain registrar to add an NS record
- // to your domain for each NameServer that is assigned to your hosted zone.
- NameServers []*string `locationNameList:"NameServer" type:"list" required:"true"`
-
- metadataDelegationSet `json:"-", xml:"-"`
-}
-
-type metadataDelegationSet struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing the request information for delete health check.
-type DeleteHealthCheckInput struct {
- // The ID of the health check to delete.
- HealthCheckID *string `location:"uri" locationName:"HealthCheckId" type:"string" required:"true"`
-
- metadataDeleteHealthCheckInput `json:"-", xml:"-"`
-}
-
-type metadataDeleteHealthCheckInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Empty response for the request.
-type DeleteHealthCheckOutput struct {
- metadataDeleteHealthCheckOutput `json:"-", xml:"-"`
-}
-
-type metadataDeleteHealthCheckOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the hosted zone that you want
-// to delete.
-type DeleteHostedZoneInput struct {
- // The ID of the hosted zone you want to delete.
- ID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataDeleteHostedZoneInput `json:"-", xml:"-"`
-}
-
-type metadataDeleteHostedZoneInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing the response information for the request.
-type DeleteHostedZoneOutput struct {
- // A complex type that contains the ID, the status, and the date and time of
- // your delete request.
- ChangeInfo *ChangeInfo `type:"structure" required:"true"`
-
- metadataDeleteHostedZoneOutput `json:"-", xml:"-"`
-}
-
-type metadataDeleteHostedZoneOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing the information for the delete request.
-type DeleteReusableDelegationSetInput struct {
- // The ID of the reusable delegation set you want to delete.
- ID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataDeleteReusableDelegationSetInput `json:"-", xml:"-"`
-}
-
-type metadataDeleteReusableDelegationSetInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Empty response for the request.
-type DeleteReusableDelegationSetOutput struct {
- metadataDeleteReusableDelegationSetOutput `json:"-", xml:"-"`
-}
-
-type metadataDeleteReusableDelegationSetOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to disassociate
-// a VPC from an hosted zone.
-type DisassociateVPCFromHostedZoneInput struct {
- // Optional: Any comments you want to include about a DisassociateVPCFromHostedZoneRequest.
- Comment *string `type:"string"`
-
- // The ID of the hosted zone you want to disassociate your VPC from.
- //
- // Note that you cannot disassociate the last VPC from a hosted zone.
- HostedZoneID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- // The VPC that you want your hosted zone to be disassociated from.
- VPC *VPC `type:"structure" required:"true"`
-
- metadataDisassociateVPCFromHostedZoneInput `json:"-", xml:"-"`
-}
-
-type metadataDisassociateVPCFromHostedZoneInput struct {
- SDKShapeTraits bool `locationName:"DisassociateVPCFromHostedZoneRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing the response information for the request.
-type DisassociateVPCFromHostedZoneOutput struct {
- // A complex type that contains the ID, the status, and the date and time of
- // your DisassociateVPCFromHostedZoneRequest.
- ChangeInfo *ChangeInfo `type:"structure" required:"true"`
-
- metadataDisassociateVPCFromHostedZoneOutput `json:"-", xml:"-"`
-}
-
-type metadataDisassociateVPCFromHostedZoneOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about a geo location.
-type GeoLocation struct {
- // The code for a continent geo location. Note: only continent locations have
- // a continent code.
- //
- // Valid values: AF | AN | AS | EU | OC | NA | SA
- //
- // Constraint: Specifying ContinentCode with either CountryCode or SubdivisionCode
- // returns an InvalidInput error.
- ContinentCode *string `type:"string"`
-
- // The code for a country geo location. The default location uses '*' for the
- // country code and will match all locations that are not matched by a geo location.
- //
- // The default geo location uses a * for the country code. All other country
- // codes follow the ISO 3166 two-character code.
- CountryCode *string `type:"string"`
-
- // The code for a country's subdivision (e.g., a province of Canada). A subdivision
- // code is only valid with the appropriate country code.
- //
- // Constraint: Specifying SubdivisionCode without CountryCode returns an InvalidInput
- // error.
- SubdivisionCode *string `type:"string"`
-
- metadataGeoLocation `json:"-", xml:"-"`
-}
-
-type metadataGeoLocation struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about a GeoLocation.
-type GeoLocationDetails struct {
- // The code for a continent geo location. Note: only continent locations have
- // a continent code.
- ContinentCode *string `type:"string"`
-
- // The name of the continent. This element is only present if ContinentCode
- // is also present.
- ContinentName *string `type:"string"`
-
- // The code for a country geo location. The default location uses '*' for the
- // country code and will match all locations that are not matched by a geo location.
- //
- // The default geo location uses a * for the country code. All other country
- // codes follow the ISO 3166 two-character code.
- CountryCode *string `type:"string"`
-
- // The name of the country. This element is only present if CountryCode is also
- // present.
- CountryName *string `type:"string"`
-
- // The code for a country's subdivision (e.g., a province of Canada). A subdivision
- // code is only valid with the appropriate country code.
- SubdivisionCode *string `type:"string"`
-
- // The name of the subdivision. This element is only present if SubdivisionCode
- // is also present.
- SubdivisionName *string `type:"string"`
-
- metadataGeoLocationDetails `json:"-", xml:"-"`
-}
-
-type metadataGeoLocationDetails struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// The input for a GetChange request.
-type GetChangeInput struct {
- // The ID of the change batch request. The value that you specify here is the
- // value that ChangeResourceRecordSets returned in the Id element when you submitted
- // the request.
- ID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataGetChangeInput `json:"-", xml:"-"`
-}
-
-type metadataGetChangeInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the ChangeInfo element.
-type GetChangeOutput struct {
- // A complex type that contains information about the specified change batch,
- // including the change batch ID, the status of the change, and the date and
- // time of the request.
- ChangeInfo *ChangeInfo `type:"structure" required:"true"`
-
- metadataGetChangeOutput `json:"-", xml:"-"`
-}
-
-type metadataGetChangeOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Empty request.
-type GetCheckerIPRangesInput struct {
- metadataGetCheckerIPRangesInput `json:"-", xml:"-"`
-}
-
-type metadataGetCheckerIPRangesInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the CheckerIpRanges element.
-type GetCheckerIPRangesOutput struct {
- // A complex type that contains sorted list of IP ranges in CIDR format for
- // Amazon Route 53 health checkers.
- CheckerIPRanges []*string `locationName:"CheckerIpRanges" type:"list" required:"true"`
-
- metadataGetCheckerIPRangesOutput `json:"-", xml:"-"`
-}
-
-type metadataGetCheckerIPRangesOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to get a geo location.
-type GetGeoLocationInput struct {
- // The code for a continent geo location. Note: only continent locations have
- // a continent code.
- //
- // Valid values: AF | AN | AS | EU | OC | NA | SA
- //
- // Constraint: Specifying ContinentCode with either CountryCode or SubdivisionCode
- // returns an InvalidInput error.
- ContinentCode *string `location:"querystring" locationName:"continentcode" type:"string"`
-
- // The code for a country geo location. The default location uses '*' for the
- // country code and will match all locations that are not matched by a geo location.
- //
- // The default geo location uses a * for the country code. All other country
- // codes follow the ISO 3166 two-character code.
- CountryCode *string `location:"querystring" locationName:"countrycode" type:"string"`
-
- // The code for a country's subdivision (e.g., a province of Canada). A subdivision
- // code is only valid with the appropriate country code.
- //
- // Constraint: Specifying SubdivisionCode without CountryCode returns an InvalidInput
- // error.
- SubdivisionCode *string `location:"querystring" locationName:"subdivisioncode" type:"string"`
-
- metadataGetGeoLocationInput `json:"-", xml:"-"`
-}
-
-type metadataGetGeoLocationInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about the specified geo location.
-type GetGeoLocationOutput struct {
- // A complex type that contains the information about the specified geo location.
- GeoLocationDetails *GeoLocationDetails `type:"structure" required:"true"`
-
- metadataGetGeoLocationOutput `json:"-", xml:"-"`
-}
-
-type metadataGetGeoLocationOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// To retrieve a count of all your health checks, send a GET request to the
-// 2013-04-01/healthcheckcount resource.
-type GetHealthCheckCountInput struct {
- metadataGetHealthCheckCountInput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckCountInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the count of health checks associated with the
-// current AWS account.
-type GetHealthCheckCountOutput struct {
- // The number of health checks associated with the current AWS account.
- HealthCheckCount *int64 `type:"long" required:"true"`
-
- metadataGetHealthCheckCountOutput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckCountOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to get a health
-// check.
-type GetHealthCheckInput struct {
- // The ID of the health check to retrieve.
- HealthCheckID *string `location:"uri" locationName:"HealthCheckId" type:"string" required:"true"`
-
- metadataGetHealthCheckInput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to get the most
-// recent failure reason for a health check.
-type GetHealthCheckLastFailureReasonInput struct {
- // The ID of the health check for which you want to retrieve the reason for
- // the most recent failure.
- HealthCheckID *string `location:"uri" locationName:"HealthCheckId" type:"string" required:"true"`
-
- metadataGetHealthCheckLastFailureReasonInput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckLastFailureReasonInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the most recent failure for
-// the specified health check.
-type GetHealthCheckLastFailureReasonOutput struct {
- // A list that contains one HealthCheckObservation element for each Route 53
- // health checker.
- HealthCheckObservations []*HealthCheckObservation `locationNameList:"HealthCheckObservation" type:"list" required:"true"`
-
- metadataGetHealthCheckLastFailureReasonOutput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckLastFailureReasonOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about the specified health check.
-type GetHealthCheckOutput struct {
- // A complex type that contains the information about the specified health check.
- HealthCheck *HealthCheck `type:"structure" required:"true"`
-
- metadataGetHealthCheckOutput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to get health
-// check status for a health check.
-type GetHealthCheckStatusInput struct {
- // The ID of the health check for which you want to retrieve the most recent
- // status.
- HealthCheckID *string `location:"uri" locationName:"HealthCheckId" type:"string" required:"true"`
-
- metadataGetHealthCheckStatusInput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckStatusInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the status of the specified
-// health check.
-type GetHealthCheckStatusOutput struct {
- // A list that contains one HealthCheckObservation element for each Route 53
- // health checker.
- HealthCheckObservations []*HealthCheckObservation `locationNameList:"HealthCheckObservation" type:"list" required:"true"`
-
- metadataGetHealthCheckStatusOutput `json:"-", xml:"-"`
-}
-
-type metadataGetHealthCheckStatusOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// To retrieve a count of all your hosted zones, send a GET request to the 2013-04-01/hostedzonecount
-// resource.
-type GetHostedZoneCountInput struct {
- metadataGetHostedZoneCountInput `json:"-", xml:"-"`
-}
-
-type metadataGetHostedZoneCountInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the count of hosted zones associated with the
-// current AWS account.
-type GetHostedZoneCountOutput struct {
- // The number of hosted zones associated with the current AWS account.
- HostedZoneCount *int64 `type:"long" required:"true"`
-
- metadataGetHostedZoneCountOutput `json:"-", xml:"-"`
-}
-
-type metadataGetHostedZoneCountOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// The input for a GetHostedZone request.
-type GetHostedZoneInput struct {
- // The ID of the hosted zone for which you want to get a list of the name servers
- // in the delegation set.
- ID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataGetHostedZoneInput `json:"-", xml:"-"`
-}
-
-type metadataGetHostedZoneInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about the specified hosted zone.
-type GetHostedZoneOutput struct {
- // A complex type that contains information about the name servers for the specified
- // hosted zone.
- DelegationSet *DelegationSet `type:"structure"`
-
- // A complex type that contains the information about the specified hosted zone.
- HostedZone *HostedZone `type:"structure" required:"true"`
-
- // A complex type that contains information about VPCs associated with the specified
- // hosted zone.
- VPCs []*VPC `locationNameList:"VPC" type:"list"`
-
- metadataGetHostedZoneOutput `json:"-", xml:"-"`
-}
-
-type metadataGetHostedZoneOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// The input for a GetReusableDelegationSet request.
-type GetReusableDelegationSetInput struct {
- // The ID of the reusable delegation set for which you want to get a list of
- // the name server.
- ID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataGetReusableDelegationSetInput `json:"-", xml:"-"`
-}
-
-type metadataGetReusableDelegationSetInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about the specified reusable delegation
-// set.
-type GetReusableDelegationSetOutput struct {
- // A complex type that contains the information about the nameservers for the
- // specified delegation set ID.
- DelegationSet *DelegationSet `type:"structure" required:"true"`
-
- metadataGetReusableDelegationSetOutput `json:"-", xml:"-"`
-}
-
-type metadataGetReusableDelegationSetOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains identifying information about the health check.
-type HealthCheck struct {
- // A unique string that identifies the request to create the health check.
- CallerReference *string `type:"string" required:"true"`
-
- // A complex type that contains the health check configuration.
- HealthCheckConfig *HealthCheckConfig `type:"structure" required:"true"`
-
- // The version of the health check. You can optionally pass this value in a
- // call to UpdateHealthCheck to prevent overwriting another change to the health
- // check.
- HealthCheckVersion *int64 `type:"long" required:"true"`
-
- // The ID of the specified health check.
- ID *string `locationName:"Id" type:"string" required:"true"`
-
- metadataHealthCheck `json:"-", xml:"-"`
-}
-
-type metadataHealthCheck struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the health check configuration.
-type HealthCheckConfig struct {
- // The number of consecutive health checks that an endpoint must pass or fail
- // for Route 53 to change the current status of the endpoint from unhealthy
- // to healthy or vice versa.
- //
- // Valid values are integers between 1 and 10. For more information, see "How
- // Amazon Route 53 Determines Whether an Endpoint Is Healthy" in the Amazon
- // Route 53 Developer Guide.
- FailureThreshold *int64 `type:"integer"`
-
- // Fully qualified domain name of the instance to be health checked.
- FullyQualifiedDomainName *string `type:"string"`
-
- // IP Address of the instance being checked.
- IPAddress *string `type:"string"`
-
- // Port on which connection will be opened to the instance to health check.
- // For HTTP and HTTP_STR_MATCH this defaults to 80 if the port is not specified.
- // For HTTPS and HTTPS_STR_MATCH this defaults to 443 if the port is not specified.
- Port *int64 `type:"integer"`
-
- // The number of seconds between the time that Route 53 gets a response from
- // your endpoint and the time that it sends the next health-check request.
- //
- // Each Route 53 health checker makes requests at this interval. Valid values
- // are 10 and 30. The default value is 30.
- RequestInterval *int64 `type:"integer"`
-
- // Path to ping on the instance to check the health. Required for HTTP, HTTPS,
- // HTTP_STR_MATCH, and HTTPS_STR_MATCH health checks, HTTP request is issued
- // to the instance on the given port and path.
- ResourcePath *string `type:"string"`
-
- // A string to search for in the body of a health check response. Required for
- // HTTP_STR_MATCH and HTTPS_STR_MATCH health checks.
- SearchString *string `type:"string"`
-
- // The type of health check to be performed. Currently supported types are TCP,
- // HTTP, HTTPS, HTTP_STR_MATCH, and HTTPS_STR_MATCH.
- Type *string `type:"string" required:"true"`
-
- metadataHealthCheckConfig `json:"-", xml:"-"`
-}
-
-type metadataHealthCheckConfig struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the IP address of a Route 53 health checker
-// and the reason for the health check status.
-type HealthCheckObservation struct {
- // The IP address of the Route 53 health checker that performed the health check.
- IPAddress *string `type:"string"`
-
- // A complex type that contains information about the health check status for
- // the current observation.
- StatusReport *StatusReport `type:"structure"`
-
- metadataHealthCheckObservation `json:"-", xml:"-"`
-}
-
-type metadataHealthCheckObservation struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contain information about the specified hosted zone.
-type HostedZone struct {
- // A unique string that identifies the request to create the hosted zone.
- CallerReference *string `type:"string" required:"true"`
-
- // A complex type that contains the Comment element.
- Config *HostedZoneConfig `type:"structure"`
-
- // The ID of the specified hosted zone.
- ID *string `locationName:"Id" type:"string" required:"true"`
-
- // The name of the domain. This must be a fully-specified domain, for example,
- // www.example.com. The trailing dot is optional; Route 53 assumes that the
- // domain name is fully qualified. This means that Route 53 treats www.example.com
- // (without a trailing dot) and www.example.com. (with a trailing dot) as identical.
- //
- // This is the name you have registered with your DNS registrar. You should
- // ask your registrar to change the authoritative name servers for your domain
- // to the set of NameServers elements returned in DelegationSet.
- Name *string `type:"string" required:"true"`
-
- // Total number of resource record sets in the hosted zone.
- ResourceRecordSetCount *int64 `type:"long"`
-
- metadataHostedZone `json:"-", xml:"-"`
-}
-
-type metadataHostedZone struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains an optional comment about your hosted zone.
-// If you don't want to specify a comment, you can omit the HostedZoneConfig
-// and Comment elements from the XML document.
-type HostedZoneConfig struct {
- // An optional comment about your hosted zone. If you don't want to specify
- // a comment, you can omit the HostedZoneConfig and Comment elements from the
- // XML document.
- Comment *string `type:"string"`
-
- // A value that indicates whether this is a private hosted zone. The value is
- // returned in the response; do not specify it in the request.
- PrivateZone *bool `type:"boolean"`
-
- metadataHostedZoneConfig `json:"-", xml:"-"`
-}
-
-type metadataHostedZoneConfig struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// The input for a ListGeoLocations request.
-type ListGeoLocationsInput struct {
- // The maximum number of geo locations you want in the response body.
- MaxItems *string `location:"querystring" locationName:"maxitems" type:"string"`
-
- // The first continent code in the lexicographic ordering of geo locations that
- // you want the ListGeoLocations request to list. For non-continent geo locations,
- // this should be null.
- //
- // Valid values: AF | AN | AS | EU | OC | NA | SA
- //
- // Constraint: Specifying ContinentCode with either CountryCode or SubdivisionCode
- // returns an InvalidInput error.
- StartContinentCode *string `location:"querystring" locationName:"startcontinentcode" type:"string"`
-
- // The first country code in the lexicographic ordering of geo locations that
- // you want the ListGeoLocations request to list.
- //
- // The default geo location uses a * for the country code. All other country
- // codes follow the ISO 3166 two-character code.
- StartCountryCode *string `location:"querystring" locationName:"startcountrycode" type:"string"`
-
- // The first subdivision code in the lexicographic ordering of geo locations
- // that you want the ListGeoLocations request to list.
- //
- // Constraint: Specifying SubdivisionCode without CountryCode returns an InvalidInput
- // error.
- StartSubdivisionCode *string `location:"querystring" locationName:"startsubdivisioncode" type:"string"`
-
- metadataListGeoLocationsInput `json:"-", xml:"-"`
-}
-
-type metadataListGeoLocationsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the geo locations that are
-// returned by the request and information about the response.
-type ListGeoLocationsOutput struct {
- // A complex type that contains information about the geo locations that are
- // returned by the request.
- GeoLocationDetailsList []*GeoLocationDetails `locationNameList:"GeoLocationDetails" type:"list" required:"true"`
-
- // A flag that indicates whether there are more geo locations to be listed.
- // If your results were truncated, you can make a follow-up request for the
- // next page of results by using the values included in the ListGeoLocationsResponse$NextContinentCode,
- // ListGeoLocationsResponse$NextCountryCode and ListGeoLocationsResponse$NextSubdivisionCode
- // elements.
- //
- // Valid Values: true | false
- IsTruncated *bool `type:"boolean" required:"true"`
-
- // The maximum number of records you requested. The maximum value of MaxItems
- // is 100.
- MaxItems *string `type:"string" required:"true"`
-
- // If the results were truncated, the continent code of the next geo location
- // in the list. This element is present only if ListGeoLocationsResponse$IsTruncated
- // is true and the next geo location to list is a continent location.
- NextContinentCode *string `type:"string"`
-
- // If the results were truncated, the country code of the next geo location
- // in the list. This element is present only if ListGeoLocationsResponse$IsTruncated
- // is true and the next geo location to list is not a continent location.
- NextCountryCode *string `type:"string"`
-
- // If the results were truncated, the subdivision code of the next geo location
- // in the list. This element is present only if ListGeoLocationsResponse$IsTruncated
- // is true and the next geo location has a subdivision.
- NextSubdivisionCode *string `type:"string"`
-
- metadataListGeoLocationsOutput `json:"-", xml:"-"`
-}
-
-type metadataListGeoLocationsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// To retrieve a list of your health checks, send a GET request to the 2013-04-01/healthcheck
-// resource. The response to this request includes a HealthChecks element with
-// zero or more HealthCheck child elements. By default, the list of health checks
-// is displayed on a single page. You can control the length of the page that
-// is displayed by using the MaxItems parameter. You can use the Marker parameter
-// to control the health check that the list begins with.
-//
-// Route 53 returns a maximum of 100 items. If you set MaxItems to a value
-// greater than 100, Route 53 returns only the first 100.
-type ListHealthChecksInput struct {
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextMarker from the last response in the marker
- // parameter to get the next page of results.
- Marker *string `location:"querystring" locationName:"marker" type:"string"`
-
- // Specify the maximum number of health checks to return per page of results.
- MaxItems *string `location:"querystring" locationName:"maxitems" type:"string"`
-
- metadataListHealthChecksInput `json:"-", xml:"-"`
-}
-
-type metadataListHealthChecksInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the response for the request.
-type ListHealthChecksOutput struct {
- // A complex type that contains information about the health checks associated
- // with the current AWS account.
- HealthChecks []*HealthCheck `locationNameList:"HealthCheck" type:"list" required:"true"`
-
- // A flag indicating whether there are more health checks to be listed. If your
- // results were truncated, you can make a follow-up request for the next page
- // of results by using the Marker element.
- //
- // Valid Values: true | false
- IsTruncated *bool `type:"boolean" required:"true"`
-
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextMarker from the last response in the marker
- // parameter to get the next page of results.
- Marker *string `type:"string" required:"true"`
-
- // The maximum number of health checks to be included in the response body.
- // If the number of health checks associated with this AWS account exceeds MaxItems,
- // the value of ListHealthChecksResponse$IsTruncated in the response is true.
- // Call ListHealthChecks again and specify the value of ListHealthChecksResponse$NextMarker
- // in the ListHostedZonesRequest$Marker element to get the next page of results.
- MaxItems *string `type:"string" required:"true"`
-
- // Indicates where to continue listing health checks. If ListHealthChecksResponse$IsTruncated
- // is true, make another request to ListHealthChecks and include the value of
- // the NextMarker element in the Marker element to get the next page of results.
- NextMarker *string `type:"string"`
-
- metadataListHealthChecksOutput `json:"-", xml:"-"`
-}
-
-type metadataListHealthChecksOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// To retrieve a list of your hosted zones in lexicographic order, send a GET
-// request to the 2013-04-01/hostedzonesbyname resource. The response to this
-// request includes a HostedZones element with zero or more HostedZone child
-// elements lexicographically ordered by DNS name. By default, the list of hosted
-// zones is displayed on a single page. You can control the length of the page
-// that is displayed by using the MaxItems parameter. You can use the DNSName
-// and HostedZoneId parameters to control the hosted zone that the list begins
-// with.
-//
-// For more information about listing hosted zones, see Listing the Hosted
-// Zones for an AWS Account (http://docs.amazonwebservices.com/Route53/latest/DeveloperGuide/ListInfoOnHostedZone.html)
-// in the Amazon Route 53 Developer Guide.
-type ListHostedZonesByNameInput struct {
- // The first name in the lexicographic ordering of domain names that you want
- // the ListHostedZonesByNameRequest request to list.
- //
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextDNSName and NextHostedZoneId from the last response
- // in the DNSName and HostedZoneId parameters to get the next page of results.
- DNSName *string `location:"querystring" locationName:"dnsname" type:"string"`
-
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextDNSName and NextHostedZoneId from the last response
- // in the DNSName and HostedZoneId parameters to get the next page of results.
- HostedZoneID *string `location:"querystring" locationName:"hostedzoneid" type:"string"`
-
- // Specify the maximum number of hosted zones to return per page of results.
- MaxItems *string `location:"querystring" locationName:"maxitems" type:"string"`
-
- metadataListHostedZonesByNameInput `json:"-", xml:"-"`
-}
-
-type metadataListHostedZonesByNameInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the response for the request.
-type ListHostedZonesByNameOutput struct {
- // The DNSName value sent in the request.
- DNSName *string `type:"string"`
-
- // The HostedZoneId value sent in the request.
- HostedZoneID *string `locationName:"HostedZoneId" type:"string"`
-
- // A complex type that contains information about the hosted zones associated
- // with the current AWS account.
- HostedZones []*HostedZone `locationNameList:"HostedZone" type:"list" required:"true"`
-
- // A flag indicating whether there are more hosted zones to be listed. If your
- // results were truncated, you can make a follow-up request for the next page
- // of results by using the NextDNSName and NextHostedZoneId elements.
- //
- // Valid Values: true | false
- IsTruncated *bool `type:"boolean" required:"true"`
-
- // The maximum number of hosted zones to be included in the response body. If
- // the number of hosted zones associated with this AWS account exceeds MaxItems,
- // the value of ListHostedZonesByNameResponse$IsTruncated in the response is
- // true. Call ListHostedZonesByName again and specify the value of ListHostedZonesByNameResponse$NextDNSName
- // and ListHostedZonesByNameResponse$NextHostedZoneId elements respectively
- // to get the next page of results.
- MaxItems *string `type:"string" required:"true"`
-
- // If ListHostedZonesByNameResponse$IsTruncated is true, there are more hosted
- // zones associated with the current AWS account. To get the next page of results,
- // make another request to ListHostedZonesByName. Specify the value of ListHostedZonesByNameResponse$NextDNSName
- // in the ListHostedZonesByNameRequest$DNSName element and ListHostedZonesByNameResponse$NextHostedZoneId
- // in the ListHostedZonesByNameRequest$HostedZoneId element.
- NextDNSName *string `type:"string"`
-
- // If ListHostedZonesByNameResponse$IsTruncated is true, there are more hosted
- // zones associated with the current AWS account. To get the next page of results,
- // make another request to ListHostedZonesByName. Specify the value of ListHostedZonesByNameResponse$NextDNSName
- // in the ListHostedZonesByNameRequest$DNSName element and ListHostedZonesByNameResponse$NextHostedZoneId
- // in the ListHostedZonesByNameRequest$HostedZoneId element.
- NextHostedZoneID *string `locationName:"NextHostedZoneId" type:"string"`
-
- metadataListHostedZonesByNameOutput `json:"-", xml:"-"`
-}
-
-type metadataListHostedZonesByNameOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// To retrieve a list of your hosted zones, send a GET request to the 2013-04-01/hostedzone
-// resource. The response to this request includes a HostedZones element with
-// zero or more HostedZone child elements. By default, the list of hosted zones
-// is displayed on a single page. You can control the length of the page that
-// is displayed by using the MaxItems parameter. You can use the Marker parameter
-// to control the hosted zone that the list begins with. For more information
-// about listing hosted zones, see Listing the Hosted Zones for an AWS Account
-// (http://docs.amazonwebservices.com/Route53/latest/DeveloperGuide/ListInfoOnHostedZone.html)
-// in the Amazon Route 53 Developer Guide.
-//
-// Route 53 returns a maximum of 100 items. If you set MaxItems to a value
-// greater than 100, Route 53 returns only the first 100.
-type ListHostedZonesInput struct {
- DelegationSetID *string `location:"querystring" locationName:"delegationsetid" type:"string"`
-
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextMarker from the last response in the marker
- // parameter to get the next page of results.
- Marker *string `location:"querystring" locationName:"marker" type:"string"`
-
- // Specify the maximum number of hosted zones to return per page of results.
- MaxItems *string `location:"querystring" locationName:"maxitems" type:"string"`
-
- metadataListHostedZonesInput `json:"-", xml:"-"`
-}
-
-type metadataListHostedZonesInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the response for the request.
-type ListHostedZonesOutput struct {
- // A complex type that contains information about the hosted zones associated
- // with the current AWS account.
- HostedZones []*HostedZone `locationNameList:"HostedZone" type:"list" required:"true"`
-
- // A flag indicating whether there are more hosted zones to be listed. If your
- // results were truncated, you can make a follow-up request for the next page
- // of results by using the Marker element.
- //
- // Valid Values: true | false
- IsTruncated *bool `type:"boolean" required:"true"`
-
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextMarker from the last response in the marker
- // parameter to get the next page of results.
- Marker *string `type:"string" required:"true"`
-
- // The maximum number of hosted zones to be included in the response body. If
- // the number of hosted zones associated with this AWS account exceeds MaxItems,
- // the value of ListHostedZonesResponse$IsTruncated in the response is true.
- // Call ListHostedZones again and specify the value of ListHostedZonesResponse$NextMarker
- // in the ListHostedZonesRequest$Marker element to get the next page of results.
- MaxItems *string `type:"string" required:"true"`
-
- // Indicates where to continue listing hosted zones. If ListHostedZonesResponse$IsTruncated
- // is true, make another request to ListHostedZones and include the value of
- // the NextMarker element in the Marker element to get the next page of results.
- NextMarker *string `type:"string"`
-
- metadataListHostedZonesOutput `json:"-", xml:"-"`
-}
-
-type metadataListHostedZonesOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// The input for a ListResourceRecordSets request.
-type ListResourceRecordSetsInput struct {
- // The ID of the hosted zone that contains the resource record sets that you
- // want to get.
- HostedZoneID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- // The maximum number of records you want in the response body.
- MaxItems *string `location:"querystring" locationName:"maxitems" type:"string"`
-
- // Weighted resource record sets only: If results were truncated for a given
- // DNS name and type, specify the value of ListResourceRecordSetsResponse$NextRecordIdentifier
- // from the previous response to get the next resource record set that has the
- // current DNS name and type.
- StartRecordIdentifier *string `location:"querystring" locationName:"identifier" type:"string"`
-
- // The first name in the lexicographic ordering of domain names that you want
- // the ListResourceRecordSets request to list.
- StartRecordName *string `location:"querystring" locationName:"name" type:"string"`
-
- // The DNS type at which to begin the listing of resource record sets.
- //
- // Valid values: A | AAAA | CNAME | MX | NS | PTR | SOA | SPF | SRV | TXT
- //
- // Values for Weighted Resource Record Sets: A | AAAA | CNAME | TXT
- //
- // Values for Regional Resource Record Sets: A | AAAA | CNAME | TXT
- //
- // Values for Alias Resource Record Sets: A | AAAA
- //
- // Constraint: Specifying type without specifying name returns an InvalidInput
- // error.
- StartRecordType *string `location:"querystring" locationName:"type" type:"string"`
-
- metadataListResourceRecordSetsInput `json:"-", xml:"-"`
-}
-
-type metadataListResourceRecordSetsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the resource record sets that
-// are returned by the request and information about the response.
-type ListResourceRecordSetsOutput struct {
- // A flag that indicates whether there are more resource record sets to be listed.
- // If your results were truncated, you can make a follow-up request for the
- // next page of results by using the ListResourceRecordSetsResponse$NextRecordName
- // element.
- //
- // Valid Values: true | false
- IsTruncated *bool `type:"boolean" required:"true"`
-
- // The maximum number of records you requested. The maximum value of MaxItems
- // is 100.
- MaxItems *string `type:"string" required:"true"`
-
- // Weighted resource record sets only: If results were truncated for a given
- // DNS name and type, the value of SetIdentifier for the next resource record
- // set that has the current DNS name and type.
- NextRecordIdentifier *string `type:"string"`
-
- // If the results were truncated, the name of the next record in the list. This
- // element is present only if ListResourceRecordSetsResponse$IsTruncated is
- // true.
- NextRecordName *string `type:"string"`
-
- // If the results were truncated, the type of the next record in the list. This
- // element is present only if ListResourceRecordSetsResponse$IsTruncated is
- // true.
- NextRecordType *string `type:"string"`
-
- // A complex type that contains information about the resource record sets that
- // are returned by the request.
- ResourceRecordSets []*ResourceRecordSet `locationNameList:"ResourceRecordSet" type:"list" required:"true"`
-
- metadataListResourceRecordSetsOutput `json:"-", xml:"-"`
-}
-
-type metadataListResourceRecordSetsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// To retrieve a list of your reusable delegation sets, send a GET request to
-// the 2013-04-01/delegationset resource. The response to this request includes
-// a DelegationSets element with zero or more DelegationSet child elements.
-// By default, the list of reusable delegation sets is displayed on a single
-// page. You can control the length of the page that is displayed by using the
-// MaxItems parameter. You can use the Marker parameter to control the delegation
-// set that the list begins with.
-//
-// Route 53 returns a maximum of 100 items. If you set MaxItems to a value
-// greater than 100, Route 53 returns only the first 100.
-type ListReusableDelegationSetsInput struct {
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextMarker from the last response in the marker
- // parameter to get the next page of results.
- Marker *string `location:"querystring" locationName:"marker" type:"string"`
-
- // Specify the maximum number of reusable delegation sets to return per page
- // of results.
- MaxItems *string `location:"querystring" locationName:"maxitems" type:"string"`
-
- metadataListReusableDelegationSetsInput `json:"-", xml:"-"`
-}
-
-type metadataListReusableDelegationSetsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the response for the request.
-type ListReusableDelegationSetsOutput struct {
- // A complex type that contains information about the reusable delegation sets
- // associated with the current AWS account.
- DelegationSets []*DelegationSet `locationNameList:"DelegationSet" type:"list" required:"true"`
-
- // A flag indicating whether there are more reusable delegation sets to be listed.
- // If your results were truncated, you can make a follow-up request for the
- // next page of results by using the Marker element.
- //
- // Valid Values: true | false
- IsTruncated *bool `type:"boolean" required:"true"`
-
- // If the request returned more than one page of results, submit another request
- // and specify the value of NextMarker from the last response in the marker
- // parameter to get the next page of results.
- Marker *string `type:"string" required:"true"`
-
- // The maximum number of reusable delegation sets to be included in the response
- // body. If the number of reusable delegation sets associated with this AWS
- // account exceeds MaxItems, the value of ListReusablDelegationSetsResponse$IsTruncated
- // in the response is true. Call ListReusableDelegationSets again and specify
- // the value of ListReusableDelegationSetsResponse$NextMarker in the ListReusableDelegationSetsRequest$Marker
- // element to get the next page of results.
- MaxItems *string `type:"string" required:"true"`
-
- // Indicates where to continue listing reusable delegation sets. If ListReusableDelegationSetsResponse$IsTruncated
- // is true, make another request to ListReusableDelegationSets and include the
- // value of the NextMarker element in the Marker element to get the next page
- // of results.
- NextMarker *string `type:"string"`
-
- metadataListReusableDelegationSetsOutput `json:"-", xml:"-"`
-}
-
-type metadataListReusableDelegationSetsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about a request for a list of the tags
-// that are associated with an individual resource.
-type ListTagsForResourceInput struct {
- // The ID of the resource for which you want to retrieve tags.
- ResourceID *string `location:"uri" locationName:"ResourceId" type:"string" required:"true"`
-
- // The type of the resource.
- //
- // - The resource type for health checks is healthcheck.
- //
- // - The resource type for hosted zones is hostedzone.
- ResourceType *string `location:"uri" locationName:"ResourceType" type:"string" required:"true"`
-
- metadataListTagsForResourceInput `json:"-", xml:"-"`
-}
-
-type metadataListTagsForResourceInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing tags for the specified resource.
-type ListTagsForResourceOutput struct {
- // A ResourceTagSet containing tags associated with the specified resource.
- ResourceTagSet *ResourceTagSet `type:"structure" required:"true"`
-
- metadataListTagsForResourceOutput `json:"-", xml:"-"`
-}
-
-type metadataListTagsForResourceOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing information about a request for a list of the tags
-// that are associated with up to 10 specified resources.
-type ListTagsForResourcesInput struct {
- // A complex type that contains the ResourceId element for each resource for
- // which you want to get a list of tags.
- ResourceIDs []*string `locationName:"ResourceIds" locationNameList:"ResourceId" type:"list" required:"true"`
-
- // The type of the resources.
- //
- // - The resource type for health checks is healthcheck.
- //
- // - The resource type for hosted zones is hostedzone.
- ResourceType *string `location:"uri" locationName:"ResourceType" type:"string" required:"true"`
-
- metadataListTagsForResourcesInput `json:"-", xml:"-"`
-}
-
-type metadataListTagsForResourcesInput struct {
- SDKShapeTraits bool `locationName:"ListTagsForResourcesRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing tags for the specified resources.
-type ListTagsForResourcesOutput struct {
- // A list of ResourceTagSets containing tags associated with the specified resources.
- ResourceTagSets []*ResourceTagSet `locationNameList:"ResourceTagSet" type:"list" required:"true"`
-
- metadataListTagsForResourcesOutput `json:"-", xml:"-"`
-}
-
-type metadataListTagsForResourcesOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains the value of the Value element for the current
-// resource record set.
-type ResourceRecord struct {
- // The value of the Value element for the current resource record set.
- Value *string `type:"string" required:"true"`
-
- metadataResourceRecord `json:"-", xml:"-"`
-}
-
-type metadataResourceRecord struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the current resource record
-// set.
-type ResourceRecordSet struct {
- // Alias resource record sets only: Information about the AWS resource to which
- // you are redirecting traffic.
- AliasTarget *AliasTarget `type:"structure"`
-
- // Failover resource record sets only: Among resource record sets that have
- // the same combination of DNS name and type, a value that indicates whether
- // the current resource record set is a primary or secondary resource record
- // set. A failover set may contain at most one resource record set marked as
- // primary and one resource record set marked as secondary. A resource record
- // set marked as primary will be returned if any of the following are true:
- // (1) an associated health check is passing, (2) if the resource record set
- // is an alias with the evaluate target health and at least one target resource
- // record set is healthy, (3) both the primary and secondary resource record
- // set are failing health checks or (4) there is no secondary resource record
- // set. A secondary resource record set will be returned if: (1) the primary
- // is failing a health check and either the secondary is passing a health check
- // or has no associated health check, or (2) there is no primary resource record
- // set.
- //
- // Valid values: PRIMARY | SECONDARY
- Failover *string `type:"string"`
-
- // Geo location resource record sets only: Among resource record sets that have
- // the same combination of DNS name and type, a value that specifies the geo
- // location for the current resource record set.
- GeoLocation *GeoLocation `type:"structure"`
-
- // Health Check resource record sets only, not required for alias resource record
- // sets: An identifier that is used to identify health check associated with
- // the resource record set.
- HealthCheckID *string `locationName:"HealthCheckId" type:"string"`
-
- // The domain name of the current resource record set.
- Name *string `type:"string" required:"true"`
-
- // Latency-based resource record sets only: Among resource record sets that
- // have the same combination of DNS name and type, a value that specifies the
- // AWS region for the current resource record set.
- Region *string `type:"string"`
-
- // A complex type that contains the resource records for the current resource
- // record set.
- ResourceRecords []*ResourceRecord `locationNameList:"ResourceRecord" type:"list"`
-
- // Weighted, Latency, Geo, and Failover resource record sets only: An identifier
- // that differentiates among multiple resource record sets that have the same
- // combination of DNS name and type.
- SetIdentifier *string `type:"string"`
-
- // The cache time to live for the current resource record set.
- TTL *int64 `type:"long"`
-
- // The type of the current resource record set.
- Type *string `type:"string" required:"true"`
-
- // Weighted resource record sets only: Among resource record sets that have
- // the same combination of DNS name and type, a value that determines what portion
- // of traffic for the current resource record set is routed to the associated
- // location.
- Weight *int64 `type:"long"`
-
- metadataResourceRecordSet `json:"-", xml:"-"`
-}
-
-type metadataResourceRecordSet struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type containing a resource and its associated tags.
-type ResourceTagSet struct {
- // The ID for the specified resource.
- ResourceID *string `locationName:"ResourceId" type:"string"`
-
- // The type of the resource.
- //
- // - The resource type for health checks is healthcheck.
- //
- // - The resource type for hosted zones is hostedzone.
- ResourceType *string `type:"string"`
-
- // The tags associated with the specified resource.
- Tags []*Tag `locationNameList:"Tag" type:"list"`
-
- metadataResourceTagSet `json:"-", xml:"-"`
-}
-
-type metadataResourceTagSet struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the health check status for
-// the current observation.
-type StatusReport struct {
- // The date and time the health check status was observed, in the format YYYY-MM-DDThh:mm:ssZ,
- // as specified in the ISO 8601 standard (for example, 2009-11-19T19:37:58Z).
- // The Z after the time indicates that the time is listed in Coordinated Universal
- // Time (UTC), which is synonymous with Greenwich Mean Time in this context.
- CheckedTime *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- // The observed health check status.
- Status *string `type:"string"`
-
- metadataStatusReport `json:"-", xml:"-"`
-}
-
-type metadataStatusReport struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A single tag containing a key and value.
-type Tag struct {
- // The key for a Tag.
- Key *string `type:"string"`
-
- // The value for a Tag.
- Value *string `type:"string"`
-
- metadataTag `json:"-", xml:"-"`
-}
-
-type metadataTag struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// >A complex type that contains information about the request to update a health
-// check.
-type UpdateHealthCheckInput struct {
- // The number of consecutive health checks that an endpoint must pass or fail
- // for Route 53 to change the current status of the endpoint from unhealthy
- // to healthy or vice versa.
- //
- // Valid values are integers between 1 and 10. For more information, see "How
- // Amazon Route 53 Determines Whether an Endpoint Is Healthy" in the Amazon
- // Route 53 Developer Guide.
- //
- // Specify this value only if you want to change it.
- FailureThreshold *int64 `type:"integer"`
-
- // Fully qualified domain name of the instance to be health checked.
- //
- // Specify this value only if you want to change it.
- FullyQualifiedDomainName *string `type:"string"`
-
- // The ID of the health check to update.
- HealthCheckID *string `location:"uri" locationName:"HealthCheckId" type:"string" required:"true"`
-
- // Optional. When you specify a health check version, Route 53 compares this
- // value with the current value in the health check, which prevents you from
- // updating the health check when the versions don't match. Using HealthCheckVersion
- // lets you prevent overwriting another change to the health check.
- HealthCheckVersion *int64 `type:"long"`
-
- // The IP address of the resource that you want to check.
- //
- // Specify this value only if you want to change it.
- IPAddress *string `type:"string"`
-
- // The port on which you want Route 53 to open a connection to perform health
- // checks.
- //
- // Specify this value only if you want to change it.
- Port *int64 `type:"integer"`
-
- // The path that you want Amazon Route 53 to request when performing health
- // checks. The path can be any value for which your endpoint will return an
- // HTTP status code of 2xx or 3xx when the endpoint is healthy, for example
- // the file /docs/route53-health-check.html.
- //
- // Specify this value only if you want to change it.
- ResourcePath *string `type:"string"`
-
- // If the value of Type is HTTP_STR_MATCH or HTTP_STR_MATCH, the string that
- // you want Route 53 to search for in the response body from the specified resource.
- // If the string appears in the response body, Route 53 considers the resource
- // healthy.
- //
- // Specify this value only if you want to change it.
- SearchString *string `type:"string"`
-
- metadataUpdateHealthCheckInput `json:"-", xml:"-"`
-}
-
-type metadataUpdateHealthCheckInput struct {
- SDKShapeTraits bool `locationName:"UpdateHealthCheckRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-type UpdateHealthCheckOutput struct {
- // A complex type that contains identifying information about the health check.
- HealthCheck *HealthCheck `type:"structure" required:"true"`
-
- metadataUpdateHealthCheckOutput `json:"-", xml:"-"`
-}
-
-type metadataUpdateHealthCheckOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// A complex type that contains information about the request to update a hosted
-// zone comment.
-type UpdateHostedZoneCommentInput struct {
- // A comment about your hosted zone.
- Comment *string `type:"string"`
-
- // The ID of the hosted zone you want to update.
- ID *string `location:"uri" locationName:"Id" type:"string" required:"true"`
-
- metadataUpdateHostedZoneCommentInput `json:"-", xml:"-"`
-}
-
-type metadataUpdateHostedZoneCommentInput struct {
- SDKShapeTraits bool `locationName:"UpdateHostedZoneCommentRequest" type:"structure" xmlURI:"https://route53.amazonaws.com/doc/2013-04-01/"`
-}
-
-// A complex type containing information about the specified hosted zone after
-// the update.
-type UpdateHostedZoneCommentOutput struct {
- // A complex type that contain information about the specified hosted zone.
- HostedZone *HostedZone `type:"structure" required:"true"`
-
- metadataUpdateHostedZoneCommentOutput `json:"-", xml:"-"`
-}
-
-type metadataUpdateHostedZoneCommentOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type VPC struct {
- // A VPC ID
- VPCID *string `locationName:"VPCId" type:"string"`
-
- VPCRegion *string `type:"string"`
-
- metadataVPC `json:"-", xml:"-"`
-}
-
-type metadataVPC struct {
- SDKShapeTraits bool `type:"structure"`
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations.go
deleted file mode 100644
index 341e20d81..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package route53
-
-import (
- "regexp"
-
- "github.com/awslabs/aws-sdk-go/aws"
-)
-
-func init() {
- initService = func(s *aws.Service) {
- s.Handlers.Build.PushBack(sanitizeURL)
- }
-}
-
-var reSanitizeURL = regexp.MustCompile(`\/%2F\w+%2F`)
-
-func sanitizeURL(r *aws.Request) {
- r.HTTPRequest.URL.Opaque =
- reSanitizeURL.ReplaceAllString(r.HTTPRequest.URL.Opaque, "/")
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations_test.go
deleted file mode 100644
index f0fe7e954..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/customizations_test.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package route53_test
-
-import (
- "testing"
-
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/util/utilassert"
- "github.com/awslabs/aws-sdk-go/service/route53"
-)
-
-func TestBuildCorrectURI(t *testing.T) {
- svc := route53.New(nil)
- req, _ := svc.GetHostedZoneRequest(&route53.GetHostedZoneInput{
- ID: aws.String("/hostedzone/ABCDEFG"),
- })
-
- req.Build()
-
- utilassert.Match(t, `\/hostedzone\/ABCDEFG$`, req.HTTPRequest.URL.String())
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/examples_test.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/examples_test.go
deleted file mode 100644
index 5584c5d6b..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/examples_test.go
+++ /dev/null
@@ -1,714 +0,0 @@
-package route53_test
-
-import (
- "bytes"
- "fmt"
- "time"
-
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/aws/awsutil"
- "github.com/awslabs/aws-sdk-go/service/route53"
-)
-
-var _ time.Duration
-var _ bytes.Buffer
-
-func ExampleRoute53_AssociateVPCWithHostedZone() {
- svc := route53.New(nil)
-
- params := &route53.AssociateVPCWithHostedZoneInput{
- HostedZoneID: aws.String("ResourceId"), // Required
- VPC: &route53.VPC{ // Required
- VPCID: aws.String("VPCId"),
- VPCRegion: aws.String("VPCRegion"),
- },
- Comment: aws.String("AssociateVPCComment"),
- }
- resp, err := svc.AssociateVPCWithHostedZone(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ChangeResourceRecordSets() {
- svc := route53.New(nil)
-
- params := &route53.ChangeResourceRecordSetsInput{
- ChangeBatch: &route53.ChangeBatch{ // Required
- Changes: []*route53.Change{ // Required
- &route53.Change{ // Required
- Action: aws.String("ChangeAction"), // Required
- ResourceRecordSet: &route53.ResourceRecordSet{ // Required
- Name: aws.String("DNSName"), // Required
- Type: aws.String("RRType"), // Required
- AliasTarget: &route53.AliasTarget{
- DNSName: aws.String("DNSName"), // Required
- EvaluateTargetHealth: aws.Boolean(true), // Required
- HostedZoneID: aws.String("ResourceId"), // Required
- },
- Failover: aws.String("ResourceRecordSetFailover"),
- GeoLocation: &route53.GeoLocation{
- ContinentCode: aws.String("GeoLocationContinentCode"),
- CountryCode: aws.String("GeoLocationCountryCode"),
- SubdivisionCode: aws.String("GeoLocationSubdivisionCode"),
- },
- HealthCheckID: aws.String("HealthCheckId"),
- Region: aws.String("ResourceRecordSetRegion"),
- ResourceRecords: []*route53.ResourceRecord{
- &route53.ResourceRecord{ // Required
- Value: aws.String("RData"), // Required
- },
- // More values...
- },
- SetIdentifier: aws.String("ResourceRecordSetIdentifier"),
- TTL: aws.Long(1),
- Weight: aws.Long(1),
- },
- },
- // More values...
- },
- Comment: aws.String("ResourceDescription"),
- },
- HostedZoneID: aws.String("ResourceId"), // Required
- }
- resp, err := svc.ChangeResourceRecordSets(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ChangeTagsForResource() {
- svc := route53.New(nil)
-
- params := &route53.ChangeTagsForResourceInput{
- ResourceID: aws.String("TagResourceId"), // Required
- ResourceType: aws.String("TagResourceType"), // Required
- AddTags: []*route53.Tag{
- &route53.Tag{ // Required
- Key: aws.String("TagKey"),
- Value: aws.String("TagValue"),
- },
- // More values...
- },
- RemoveTagKeys: []*string{
- aws.String("TagKey"), // Required
- // More values...
- },
- }
- resp, err := svc.ChangeTagsForResource(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_CreateHealthCheck() {
- svc := route53.New(nil)
-
- params := &route53.CreateHealthCheckInput{
- CallerReference: aws.String("HealthCheckNonce"), // Required
- HealthCheckConfig: &route53.HealthCheckConfig{ // Required
- Type: aws.String("HealthCheckType"), // Required
- FailureThreshold: aws.Long(1),
- FullyQualifiedDomainName: aws.String("FullyQualifiedDomainName"),
- IPAddress: aws.String("IPAddress"),
- Port: aws.Long(1),
- RequestInterval: aws.Long(1),
- ResourcePath: aws.String("ResourcePath"),
- SearchString: aws.String("SearchString"),
- },
- }
- resp, err := svc.CreateHealthCheck(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_CreateHostedZone() {
- svc := route53.New(nil)
-
- params := &route53.CreateHostedZoneInput{
- CallerReference: aws.String("Nonce"), // Required
- Name: aws.String("DNSName"), // Required
- DelegationSetID: aws.String("ResourceId"),
- HostedZoneConfig: &route53.HostedZoneConfig{
- Comment: aws.String("ResourceDescription"),
- PrivateZone: aws.Boolean(true),
- },
- VPC: &route53.VPC{
- VPCID: aws.String("VPCId"),
- VPCRegion: aws.String("VPCRegion"),
- },
- }
- resp, err := svc.CreateHostedZone(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_CreateReusableDelegationSet() {
- svc := route53.New(nil)
-
- params := &route53.CreateReusableDelegationSetInput{
- CallerReference: aws.String("Nonce"), // Required
- HostedZoneID: aws.String("ResourceId"),
- }
- resp, err := svc.CreateReusableDelegationSet(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_DeleteHealthCheck() {
- svc := route53.New(nil)
-
- params := &route53.DeleteHealthCheckInput{
- HealthCheckID: aws.String("HealthCheckId"), // Required
- }
- resp, err := svc.DeleteHealthCheck(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_DeleteHostedZone() {
- svc := route53.New(nil)
-
- params := &route53.DeleteHostedZoneInput{
- ID: aws.String("ResourceId"), // Required
- }
- resp, err := svc.DeleteHostedZone(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_DeleteReusableDelegationSet() {
- svc := route53.New(nil)
-
- params := &route53.DeleteReusableDelegationSetInput{
- ID: aws.String("ResourceId"), // Required
- }
- resp, err := svc.DeleteReusableDelegationSet(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_DisassociateVPCFromHostedZone() {
- svc := route53.New(nil)
-
- params := &route53.DisassociateVPCFromHostedZoneInput{
- HostedZoneID: aws.String("ResourceId"), // Required
- VPC: &route53.VPC{ // Required
- VPCID: aws.String("VPCId"),
- VPCRegion: aws.String("VPCRegion"),
- },
- Comment: aws.String("DisassociateVPCComment"),
- }
- resp, err := svc.DisassociateVPCFromHostedZone(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetChange() {
- svc := route53.New(nil)
-
- params := &route53.GetChangeInput{
- ID: aws.String("ResourceId"), // Required
- }
- resp, err := svc.GetChange(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetCheckerIPRanges() {
- svc := route53.New(nil)
-
- var params *route53.GetCheckerIPRangesInput
- resp, err := svc.GetCheckerIPRanges(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetGeoLocation() {
- svc := route53.New(nil)
-
- params := &route53.GetGeoLocationInput{
- ContinentCode: aws.String("GeoLocationContinentCode"),
- CountryCode: aws.String("GeoLocationCountryCode"),
- SubdivisionCode: aws.String("GeoLocationSubdivisionCode"),
- }
- resp, err := svc.GetGeoLocation(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetHealthCheck() {
- svc := route53.New(nil)
-
- params := &route53.GetHealthCheckInput{
- HealthCheckID: aws.String("HealthCheckId"), // Required
- }
- resp, err := svc.GetHealthCheck(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetHealthCheckCount() {
- svc := route53.New(nil)
-
- var params *route53.GetHealthCheckCountInput
- resp, err := svc.GetHealthCheckCount(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetHealthCheckLastFailureReason() {
- svc := route53.New(nil)
-
- params := &route53.GetHealthCheckLastFailureReasonInput{
- HealthCheckID: aws.String("HealthCheckId"), // Required
- }
- resp, err := svc.GetHealthCheckLastFailureReason(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetHealthCheckStatus() {
- svc := route53.New(nil)
-
- params := &route53.GetHealthCheckStatusInput{
- HealthCheckID: aws.String("HealthCheckId"), // Required
- }
- resp, err := svc.GetHealthCheckStatus(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetHostedZone() {
- svc := route53.New(nil)
-
- params := &route53.GetHostedZoneInput{
- ID: aws.String("ResourceId"), // Required
- }
- resp, err := svc.GetHostedZone(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetHostedZoneCount() {
- svc := route53.New(nil)
-
- var params *route53.GetHostedZoneCountInput
- resp, err := svc.GetHostedZoneCount(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_GetReusableDelegationSet() {
- svc := route53.New(nil)
-
- params := &route53.GetReusableDelegationSetInput{
- ID: aws.String("ResourceId"), // Required
- }
- resp, err := svc.GetReusableDelegationSet(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListGeoLocations() {
- svc := route53.New(nil)
-
- params := &route53.ListGeoLocationsInput{
- MaxItems: aws.String("PageMaxItems"),
- StartContinentCode: aws.String("GeoLocationContinentCode"),
- StartCountryCode: aws.String("GeoLocationCountryCode"),
- StartSubdivisionCode: aws.String("GeoLocationSubdivisionCode"),
- }
- resp, err := svc.ListGeoLocations(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListHealthChecks() {
- svc := route53.New(nil)
-
- params := &route53.ListHealthChecksInput{
- Marker: aws.String("PageMarker"),
- MaxItems: aws.String("PageMaxItems"),
- }
- resp, err := svc.ListHealthChecks(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListHostedZones() {
- svc := route53.New(nil)
-
- params := &route53.ListHostedZonesInput{
- DelegationSetID: aws.String("ResourceId"),
- Marker: aws.String("PageMarker"),
- MaxItems: aws.String("PageMaxItems"),
- }
- resp, err := svc.ListHostedZones(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListHostedZonesByName() {
- svc := route53.New(nil)
-
- params := &route53.ListHostedZonesByNameInput{
- DNSName: aws.String("DNSName"),
- HostedZoneID: aws.String("ResourceId"),
- MaxItems: aws.String("PageMaxItems"),
- }
- resp, err := svc.ListHostedZonesByName(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListResourceRecordSets() {
- svc := route53.New(nil)
-
- params := &route53.ListResourceRecordSetsInput{
- HostedZoneID: aws.String("ResourceId"), // Required
- MaxItems: aws.String("PageMaxItems"),
- StartRecordIdentifier: aws.String("ResourceRecordSetIdentifier"),
- StartRecordName: aws.String("DNSName"),
- StartRecordType: aws.String("RRType"),
- }
- resp, err := svc.ListResourceRecordSets(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListReusableDelegationSets() {
- svc := route53.New(nil)
-
- params := &route53.ListReusableDelegationSetsInput{
- Marker: aws.String("PageMarker"),
- MaxItems: aws.String("PageMaxItems"),
- }
- resp, err := svc.ListReusableDelegationSets(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListTagsForResource() {
- svc := route53.New(nil)
-
- params := &route53.ListTagsForResourceInput{
- ResourceID: aws.String("TagResourceId"), // Required
- ResourceType: aws.String("TagResourceType"), // Required
- }
- resp, err := svc.ListTagsForResource(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_ListTagsForResources() {
- svc := route53.New(nil)
-
- params := &route53.ListTagsForResourcesInput{
- ResourceIDs: []*string{ // Required
- aws.String("TagResourceId"), // Required
- // More values...
- },
- ResourceType: aws.String("TagResourceType"), // Required
- }
- resp, err := svc.ListTagsForResources(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_UpdateHealthCheck() {
- svc := route53.New(nil)
-
- params := &route53.UpdateHealthCheckInput{
- HealthCheckID: aws.String("HealthCheckId"), // Required
- FailureThreshold: aws.Long(1),
- FullyQualifiedDomainName: aws.String("FullyQualifiedDomainName"),
- HealthCheckVersion: aws.Long(1),
- IPAddress: aws.String("IPAddress"),
- Port: aws.Long(1),
- ResourcePath: aws.String("ResourcePath"),
- SearchString: aws.String("SearchString"),
- }
- resp, err := svc.UpdateHealthCheck(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
-
-func ExampleRoute53_UpdateHostedZoneComment() {
- svc := route53.New(nil)
-
- params := &route53.UpdateHostedZoneCommentInput{
- ID: aws.String("ResourceId"), // Required
- Comment: aws.String("ResourceDescription"),
- }
- resp, err := svc.UpdateHostedZoneComment(params)
-
- if awserr := aws.Error(err); awserr != nil {
- // A service error occurred.
- fmt.Println("Error:", awserr.Code, awserr.Message)
- } else if err != nil {
- // A non-service error occurred.
- panic(err)
- }
-
- // Pretty-print the response data.
- fmt.Println(awsutil.StringValue(resp))
-}
diff --git a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/service.go b/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/service.go
deleted file mode 100644
index a2f792798..000000000
--- a/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/service/route53/service.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package route53
-
-import (
- "github.com/awslabs/aws-sdk-go/aws"
- "github.com/awslabs/aws-sdk-go/internal/protocol/restxml"
- "github.com/awslabs/aws-sdk-go/internal/signer/v4"
-)
-
-// Route53 is a client for Route 53.
-type Route53 struct {
- *aws.Service
-}
-
-// Used for custom service initialization logic
-var initService func(*aws.Service)
-
-// Used for custom request initialization logic
-var initRequest func(*aws.Request)
-
-// New returns a new Route53 client.
-func New(config *aws.Config) *Route53 {
- if config == nil {
- config = &aws.Config{}
- }
-
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "route53",
- APIVersion: "2013-04-01",
- }
- service.Initialize()
-
- // Handlers
- service.Handlers.Sign.PushBack(v4.Sign)
- service.Handlers.Build.PushBack(restxml.Build)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- // Run custom service initialization if present
- if initService != nil {
- initService(service)
- }
-
- return &Route53{service}
-}
-
-// newRequest creates a new request for a Route53 operation and runs any
-// custom request initialization.
-func (c *Route53) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {
- req := aws.NewRequest(c.Service, op, params, data)
-
- // Run custom request initialization if present
- if initRequest != nil {
- initRequest(req)
- }
-
- return req
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go
new file mode 100644
index 000000000..dbc60fc8e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go
@@ -0,0 +1,54 @@
+// Copyright 2014 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package internal
+
+import (
+ "strings"
+)
+
+const (
+ WatchState = 1 << iota
+ MultiState
+ SubscribeState
+ MonitorState
+)
+
+type CommandInfo struct {
+ Set, Clear int
+}
+
+var commandInfos = map[string]CommandInfo{
+ "WATCH": {Set: WatchState},
+ "UNWATCH": {Clear: WatchState},
+ "MULTI": {Set: MultiState},
+ "EXEC": {Clear: WatchState | MultiState},
+ "DISCARD": {Clear: WatchState | MultiState},
+ "PSUBSCRIBE": {Set: SubscribeState},
+ "SUBSCRIBE": {Set: SubscribeState},
+ "MONITOR": {Set: MonitorState},
+}
+
+func init() {
+ for n, ci := range commandInfos {
+ commandInfos[strings.ToLower(n)] = ci
+ }
+}
+
+func LookupCommandInfo(commandName string) CommandInfo {
+ if ci, ok := commandInfos[commandName]; ok {
+ return ci
+ }
+ return commandInfos[strings.ToUpper(commandName)]
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo_test.go
new file mode 100644
index 000000000..118e94b67
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo_test.go
@@ -0,0 +1,27 @@
+package internal
+
+import "testing"
+
+func TestLookupCommandInfo(t *testing.T) {
+ for _, n := range []string{"watch", "WATCH", "wAtch"} {
+ if LookupCommandInfo(n) == (CommandInfo{}) {
+ t.Errorf("LookupCommandInfo(%q) = CommandInfo{}, expected non-zero value", n)
+ }
+ }
+}
+
+func benchmarkLookupCommandInfo(b *testing.B, names ...string) {
+ for i := 0; i < b.N; i++ {
+ for _, c := range names {
+ LookupCommandInfo(c)
+ }
+ }
+}
+
+func BenchmarkLookupCommandInfoCorrectCase(b *testing.B) {
+ benchmarkLookupCommandInfo(b, "watch", "WATCH", "monitor", "MONITOR")
+}
+
+func BenchmarkLookupCommandInfoMixedCase(b *testing.B) {
+ benchmarkLookupCommandInfo(b, "wAtch", "WeTCH", "monItor", "MONiTOR")
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go
new file mode 100644
index 000000000..5f955c424
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go
@@ -0,0 +1,65 @@
+// Copyright 2014 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+// Package redistest contains utilities for writing Redigo tests.
+package redistest
+
+import (
+ "errors"
+ "time"
+
+ "github.com/garyburd/redigo/redis"
+)
+
+type testConn struct {
+ redis.Conn
+}
+
+func (t testConn) Close() error {
+ _, err := t.Conn.Do("SELECT", "9")
+ if err != nil {
+ return nil
+ }
+ _, err = t.Conn.Do("FLUSHDB")
+ if err != nil {
+ return err
+ }
+ return t.Conn.Close()
+}
+
+// Dial dials the local Redis server and selects database 9. To prevent
+// stomping on real data, DialTestDB fails if database 9 contains data. The
+// returned connection flushes database 9 on close.
+func Dial() (redis.Conn, error) {
+ c, err := redis.DialTimeout("tcp", ":6379", 0, 1*time.Second, 1*time.Second)
+ if err != nil {
+ return nil, err
+ }
+
+ _, err = c.Do("SELECT", "9")
+ if err != nil {
+ return nil, err
+ }
+
+ n, err := redis.Int(c.Do("DBSIZE"))
+ if err != nil {
+ return nil, err
+ }
+
+ if n != 0 {
+ return nil, errors.New("database #9 is not empty, test can not continue")
+ }
+
+ return testConn{c}, nil
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go
new file mode 100644
index 000000000..ac0e971c4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go
@@ -0,0 +1,455 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "bufio"
+ "bytes"
+ "errors"
+ "fmt"
+ "io"
+ "net"
+ "strconv"
+ "sync"
+ "time"
+)
+
+// conn is the low-level implementation of Conn
+type conn struct {
+
+ // Shared
+ mu sync.Mutex
+ pending int
+ err error
+ conn net.Conn
+
+ // Read
+ readTimeout time.Duration
+ br *bufio.Reader
+
+ // Write
+ writeTimeout time.Duration
+ bw *bufio.Writer
+
+ // Scratch space for formatting argument length.
+ // '*' or '$', length, "\r\n"
+ lenScratch [32]byte
+
+ // Scratch space for formatting integers and floats.
+ numScratch [40]byte
+}
+
+// Dial connects to the Redis server at the given network and address.
+func Dial(network, address string) (Conn, error) {
+ dialer := xDialer{}
+ return dialer.Dial(network, address)
+}
+
+// DialTimeout acts like Dial but takes timeouts for establishing the
+// connection to the server, writing a command and reading a reply.
+func DialTimeout(network, address string, connectTimeout, readTimeout, writeTimeout time.Duration) (Conn, error) {
+ netDialer := net.Dialer{Timeout: connectTimeout}
+ dialer := xDialer{
+ NetDial: netDialer.Dial,
+ ReadTimeout: readTimeout,
+ WriteTimeout: writeTimeout,
+ }
+ return dialer.Dial(network, address)
+}
+
+// A Dialer specifies options for connecting to a Redis server.
+type xDialer struct {
+ // NetDial specifies the dial function for creating TCP connections. If
+ // NetDial is nil, then net.Dial is used.
+ NetDial func(network, addr string) (net.Conn, error)
+
+ // ReadTimeout specifies the timeout for reading a single command
+ // reply. If ReadTimeout is zero, then no timeout is used.
+ ReadTimeout time.Duration
+
+ // WriteTimeout specifies the timeout for writing a single command. If
+ // WriteTimeout is zero, then no timeout is used.
+ WriteTimeout time.Duration
+}
+
+// Dial connects to the Redis server at address on the named network.
+func (d *xDialer) Dial(network, address string) (Conn, error) {
+ dial := d.NetDial
+ if dial == nil {
+ dial = net.Dial
+ }
+ netConn, err := dial(network, address)
+ if err != nil {
+ return nil, err
+ }
+ return &conn{
+ conn: netConn,
+ bw: bufio.NewWriter(netConn),
+ br: bufio.NewReader(netConn),
+ readTimeout: d.ReadTimeout,
+ writeTimeout: d.WriteTimeout,
+ }, nil
+}
+
+// NewConn returns a new Redigo connection for the given net connection.
+func NewConn(netConn net.Conn, readTimeout, writeTimeout time.Duration) Conn {
+ return &conn{
+ conn: netConn,
+ bw: bufio.NewWriter(netConn),
+ br: bufio.NewReader(netConn),
+ readTimeout: readTimeout,
+ writeTimeout: writeTimeout,
+ }
+}
+
+func (c *conn) Close() error {
+ c.mu.Lock()
+ err := c.err
+ if c.err == nil {
+ c.err = errors.New("redigo: closed")
+ err = c.conn.Close()
+ }
+ c.mu.Unlock()
+ return err
+}
+
+func (c *conn) fatal(err error) error {
+ c.mu.Lock()
+ if c.err == nil {
+ c.err = err
+ // Close connection to force errors on subsequent calls and to unblock
+ // other reader or writer.
+ c.conn.Close()
+ }
+ c.mu.Unlock()
+ return err
+}
+
+func (c *conn) Err() error {
+ c.mu.Lock()
+ err := c.err
+ c.mu.Unlock()
+ return err
+}
+
+func (c *conn) writeLen(prefix byte, n int) error {
+ c.lenScratch[len(c.lenScratch)-1] = '\n'
+ c.lenScratch[len(c.lenScratch)-2] = '\r'
+ i := len(c.lenScratch) - 3
+ for {
+ c.lenScratch[i] = byte('0' + n%10)
+ i -= 1
+ n = n / 10
+ if n == 0 {
+ break
+ }
+ }
+ c.lenScratch[i] = prefix
+ _, err := c.bw.Write(c.lenScratch[i:])
+ return err
+}
+
+func (c *conn) writeString(s string) error {
+ c.writeLen('$', len(s))
+ c.bw.WriteString(s)
+ _, err := c.bw.WriteString("\r\n")
+ return err
+}
+
+func (c *conn) writeBytes(p []byte) error {
+ c.writeLen('$', len(p))
+ c.bw.Write(p)
+ _, err := c.bw.WriteString("\r\n")
+ return err
+}
+
+func (c *conn) writeInt64(n int64) error {
+ return c.writeBytes(strconv.AppendInt(c.numScratch[:0], n, 10))
+}
+
+func (c *conn) writeFloat64(n float64) error {
+ return c.writeBytes(strconv.AppendFloat(c.numScratch[:0], n, 'g', -1, 64))
+}
+
+func (c *conn) writeCommand(cmd string, args []interface{}) (err error) {
+ c.writeLen('*', 1+len(args))
+ err = c.writeString(cmd)
+ for _, arg := range args {
+ if err != nil {
+ break
+ }
+ switch arg := arg.(type) {
+ case string:
+ err = c.writeString(arg)
+ case []byte:
+ err = c.writeBytes(arg)
+ case int:
+ err = c.writeInt64(int64(arg))
+ case int64:
+ err = c.writeInt64(arg)
+ case float64:
+ err = c.writeFloat64(arg)
+ case bool:
+ if arg {
+ err = c.writeString("1")
+ } else {
+ err = c.writeString("0")
+ }
+ case nil:
+ err = c.writeString("")
+ default:
+ var buf bytes.Buffer
+ fmt.Fprint(&buf, arg)
+ err = c.writeBytes(buf.Bytes())
+ }
+ }
+ return err
+}
+
+type protocolError string
+
+func (pe protocolError) Error() string {
+ return fmt.Sprintf("redigo: %s (possible server error or unsupported concurrent read by application)", string(pe))
+}
+
+func (c *conn) readLine() ([]byte, error) {
+ p, err := c.br.ReadSlice('\n')
+ if err == bufio.ErrBufferFull {
+ return nil, protocolError("long response line")
+ }
+ if err != nil {
+ return nil, err
+ }
+ i := len(p) - 2
+ if i < 0 || p[i] != '\r' {
+ return nil, protocolError("bad response line terminator")
+ }
+ return p[:i], nil
+}
+
+// parseLen parses bulk string and array lengths.
+func parseLen(p []byte) (int, error) {
+ if len(p) == 0 {
+ return -1, protocolError("malformed length")
+ }
+
+ if p[0] == '-' && len(p) == 2 && p[1] == '1' {
+ // handle $-1 and $-1 null replies.
+ return -1, nil
+ }
+
+ var n int
+ for _, b := range p {
+ n *= 10
+ if b < '0' || b > '9' {
+ return -1, protocolError("illegal bytes in length")
+ }
+ n += int(b - '0')
+ }
+
+ return n, nil
+}
+
+// parseInt parses an integer reply.
+func parseInt(p []byte) (interface{}, error) {
+ if len(p) == 0 {
+ return 0, protocolError("malformed integer")
+ }
+
+ var negate bool
+ if p[0] == '-' {
+ negate = true
+ p = p[1:]
+ if len(p) == 0 {
+ return 0, protocolError("malformed integer")
+ }
+ }
+
+ var n int64
+ for _, b := range p {
+ n *= 10
+ if b < '0' || b > '9' {
+ return 0, protocolError("illegal bytes in length")
+ }
+ n += int64(b - '0')
+ }
+
+ if negate {
+ n = -n
+ }
+ return n, nil
+}
+
+var (
+ okReply interface{} = "OK"
+ pongReply interface{} = "PONG"
+)
+
+func (c *conn) readReply() (interface{}, error) {
+ line, err := c.readLine()
+ if err != nil {
+ return nil, err
+ }
+ if len(line) == 0 {
+ return nil, protocolError("short response line")
+ }
+ switch line[0] {
+ case '+':
+ switch {
+ case len(line) == 3 && line[1] == 'O' && line[2] == 'K':
+ // Avoid allocation for frequent "+OK" response.
+ return okReply, nil
+ case len(line) == 5 && line[1] == 'P' && line[2] == 'O' && line[3] == 'N' && line[4] == 'G':
+ // Avoid allocation in PING command benchmarks :)
+ return pongReply, nil
+ default:
+ return string(line[1:]), nil
+ }
+ case '-':
+ return Error(string(line[1:])), nil
+ case ':':
+ return parseInt(line[1:])
+ case '$':
+ n, err := parseLen(line[1:])
+ if n < 0 || err != nil {
+ return nil, err
+ }
+ p := make([]byte, n)
+ _, err = io.ReadFull(c.br, p)
+ if err != nil {
+ return nil, err
+ }
+ if line, err := c.readLine(); err != nil {
+ return nil, err
+ } else if len(line) != 0 {
+ return nil, protocolError("bad bulk string format")
+ }
+ return p, nil
+ case '*':
+ n, err := parseLen(line[1:])
+ if n < 0 || err != nil {
+ return nil, err
+ }
+ r := make([]interface{}, n)
+ for i := range r {
+ r[i], err = c.readReply()
+ if err != nil {
+ return nil, err
+ }
+ }
+ return r, nil
+ }
+ return nil, protocolError("unexpected response line")
+}
+
+func (c *conn) Send(cmd string, args ...interface{}) error {
+ c.mu.Lock()
+ c.pending += 1
+ c.mu.Unlock()
+ if c.writeTimeout != 0 {
+ c.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout))
+ }
+ if err := c.writeCommand(cmd, args); err != nil {
+ return c.fatal(err)
+ }
+ return nil
+}
+
+func (c *conn) Flush() error {
+ if c.writeTimeout != 0 {
+ c.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout))
+ }
+ if err := c.bw.Flush(); err != nil {
+ return c.fatal(err)
+ }
+ return nil
+}
+
+func (c *conn) Receive() (reply interface{}, err error) {
+ if c.readTimeout != 0 {
+ c.conn.SetReadDeadline(time.Now().Add(c.readTimeout))
+ }
+ if reply, err = c.readReply(); err != nil {
+ return nil, c.fatal(err)
+ }
+ // When using pub/sub, the number of receives can be greater than the
+ // number of sends. To enable normal use of the connection after
+ // unsubscribing from all channels, we do not decrement pending to a
+ // negative value.
+ //
+ // The pending field is decremented after the reply is read to handle the
+ // case where Receive is called before Send.
+ c.mu.Lock()
+ if c.pending > 0 {
+ c.pending -= 1
+ }
+ c.mu.Unlock()
+ if err, ok := reply.(Error); ok {
+ return nil, err
+ }
+ return
+}
+
+func (c *conn) Do(cmd string, args ...interface{}) (interface{}, error) {
+ c.mu.Lock()
+ pending := c.pending
+ c.pending = 0
+ c.mu.Unlock()
+
+ if cmd == "" && pending == 0 {
+ return nil, nil
+ }
+
+ if c.writeTimeout != 0 {
+ c.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout))
+ }
+
+ if cmd != "" {
+ c.writeCommand(cmd, args)
+ }
+
+ if err := c.bw.Flush(); err != nil {
+ return nil, c.fatal(err)
+ }
+
+ if c.readTimeout != 0 {
+ c.conn.SetReadDeadline(time.Now().Add(c.readTimeout))
+ }
+
+ if cmd == "" {
+ reply := make([]interface{}, pending)
+ for i := range reply {
+ r, e := c.readReply()
+ if e != nil {
+ return nil, c.fatal(e)
+ }
+ reply[i] = r
+ }
+ return reply, nil
+ }
+
+ var err error
+ var reply interface{}
+ for i := 0; i <= pending; i++ {
+ var e error
+ if reply, e = c.readReply(); e != nil {
+ return nil, c.fatal(e)
+ }
+ if e, ok := reply.(Error); ok && err == nil {
+ err = e
+ }
+ }
+ return reply, err
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn_test.go
new file mode 100644
index 000000000..800370136
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn_test.go
@@ -0,0 +1,542 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "bufio"
+ "bytes"
+ "math"
+ "net"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/garyburd/redigo/internal/redistest"
+ "github.com/garyburd/redigo/redis"
+)
+
+var writeTests = []struct {
+ args []interface{}
+ expected string
+}{
+ {
+ []interface{}{"SET", "key", "value"},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n",
+ },
+ {
+ []interface{}{"SET", "key", "value"},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n",
+ },
+ {
+ []interface{}{"SET", "key", byte(100)},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$3\r\n100\r\n",
+ },
+ {
+ []interface{}{"SET", "key", 100},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$3\r\n100\r\n",
+ },
+ {
+ []interface{}{"SET", "key", int64(math.MinInt64)},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$20\r\n-9223372036854775808\r\n",
+ },
+ {
+ []interface{}{"SET", "key", float64(1349673917.939762)},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$21\r\n1.349673917939762e+09\r\n",
+ },
+ {
+ []interface{}{"SET", "key", ""},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$0\r\n\r\n",
+ },
+ {
+ []interface{}{"SET", "key", nil},
+ "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$0\r\n\r\n",
+ },
+ {
+ []interface{}{"ECHO", true, false},
+ "*3\r\n$4\r\nECHO\r\n$1\r\n1\r\n$1\r\n0\r\n",
+ },
+}
+
+func TestWrite(t *testing.T) {
+ for _, tt := range writeTests {
+ var buf bytes.Buffer
+ rw := bufio.ReadWriter{Writer: bufio.NewWriter(&buf)}
+ c := redis.NewConnBufio(rw)
+ err := c.Send(tt.args[0].(string), tt.args[1:]...)
+ if err != nil {
+ t.Errorf("Send(%v) returned error %v", tt.args, err)
+ continue
+ }
+ rw.Flush()
+ actual := buf.String()
+ if actual != tt.expected {
+ t.Errorf("Send(%v) = %q, want %q", tt.args, actual, tt.expected)
+ }
+ }
+}
+
+var errorSentinel = &struct{}{}
+
+var readTests = []struct {
+ reply string
+ expected interface{}
+}{
+ {
+ "+OK\r\n",
+ "OK",
+ },
+ {
+ "+PONG\r\n",
+ "PONG",
+ },
+ {
+ "@OK\r\n",
+ errorSentinel,
+ },
+ {
+ "$6\r\nfoobar\r\n",
+ []byte("foobar"),
+ },
+ {
+ "$-1\r\n",
+ nil,
+ },
+ {
+ ":1\r\n",
+ int64(1),
+ },
+ {
+ ":-2\r\n",
+ int64(-2),
+ },
+ {
+ "*0\r\n",
+ []interface{}{},
+ },
+ {
+ "*-1\r\n",
+ nil,
+ },
+ {
+ "*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n",
+ []interface{}{[]byte("foo"), []byte("bar"), []byte("Hello"), []byte("World")},
+ },
+ {
+ "*3\r\n$3\r\nfoo\r\n$-1\r\n$3\r\nbar\r\n",
+ []interface{}{[]byte("foo"), nil, []byte("bar")},
+ },
+
+ {
+ // "x" is not a valid length
+ "$x\r\nfoobar\r\n",
+ errorSentinel,
+ },
+ {
+ // -2 is not a valid length
+ "$-2\r\n",
+ errorSentinel,
+ },
+ {
+ // "x" is not a valid integer
+ ":x\r\n",
+ errorSentinel,
+ },
+ {
+ // missing \r\n following value
+ "$6\r\nfoobar",
+ errorSentinel,
+ },
+ {
+ // short value
+ "$6\r\nxx",
+ errorSentinel,
+ },
+ {
+ // long value
+ "$6\r\nfoobarx\r\n",
+ errorSentinel,
+ },
+}
+
+func TestRead(t *testing.T) {
+ for _, tt := range readTests {
+ rw := bufio.ReadWriter{
+ Reader: bufio.NewReader(strings.NewReader(tt.reply)),
+ Writer: bufio.NewWriter(nil), // writer need to support Flush
+ }
+ c := redis.NewConnBufio(rw)
+ actual, err := c.Receive()
+ if tt.expected == errorSentinel {
+ if err == nil {
+ t.Errorf("Receive(%q) did not return expected error", tt.reply)
+ }
+ } else {
+ if err != nil {
+ t.Errorf("Receive(%q) returned error %v", tt.reply, err)
+ continue
+ }
+ if !reflect.DeepEqual(actual, tt.expected) {
+ t.Errorf("Receive(%q) = %v, want %v", tt.reply, actual, tt.expected)
+ }
+ }
+ }
+}
+
+var testCommands = []struct {
+ args []interface{}
+ expected interface{}
+}{
+ {
+ []interface{}{"PING"},
+ "PONG",
+ },
+ {
+ []interface{}{"SET", "foo", "bar"},
+ "OK",
+ },
+ {
+ []interface{}{"GET", "foo"},
+ []byte("bar"),
+ },
+ {
+ []interface{}{"GET", "nokey"},
+ nil,
+ },
+ {
+ []interface{}{"MGET", "nokey", "foo"},
+ []interface{}{nil, []byte("bar")},
+ },
+ {
+ []interface{}{"INCR", "mycounter"},
+ int64(1),
+ },
+ {
+ []interface{}{"LPUSH", "mylist", "foo"},
+ int64(1),
+ },
+ {
+ []interface{}{"LPUSH", "mylist", "bar"},
+ int64(2),
+ },
+ {
+ []interface{}{"LRANGE", "mylist", 0, -1},
+ []interface{}{[]byte("bar"), []byte("foo")},
+ },
+ {
+ []interface{}{"MULTI"},
+ "OK",
+ },
+ {
+ []interface{}{"LRANGE", "mylist", 0, -1},
+ "QUEUED",
+ },
+ {
+ []interface{}{"PING"},
+ "QUEUED",
+ },
+ {
+ []interface{}{"EXEC"},
+ []interface{}{
+ []interface{}{[]byte("bar"), []byte("foo")},
+ "PONG",
+ },
+ },
+}
+
+func TestDoCommands(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+
+ for _, cmd := range testCommands {
+ actual, err := c.Do(cmd.args[0].(string), cmd.args[1:]...)
+ if err != nil {
+ t.Errorf("Do(%v) returned error %v", cmd.args, err)
+ continue
+ }
+ if !reflect.DeepEqual(actual, cmd.expected) {
+ t.Errorf("Do(%v) = %v, want %v", cmd.args, actual, cmd.expected)
+ }
+ }
+}
+
+func TestPipelineCommands(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+
+ for _, cmd := range testCommands {
+ if err := c.Send(cmd.args[0].(string), cmd.args[1:]...); err != nil {
+ t.Fatalf("Send(%v) returned error %v", cmd.args, err)
+ }
+ }
+ if err := c.Flush(); err != nil {
+ t.Errorf("Flush() returned error %v", err)
+ }
+ for _, cmd := range testCommands {
+ actual, err := c.Receive()
+ if err != nil {
+ t.Fatalf("Receive(%v) returned error %v", cmd.args, err)
+ }
+ if !reflect.DeepEqual(actual, cmd.expected) {
+ t.Errorf("Receive(%v) = %v, want %v", cmd.args, actual, cmd.expected)
+ }
+ }
+}
+
+func TestBlankCommmand(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+
+ for _, cmd := range testCommands {
+ if err := c.Send(cmd.args[0].(string), cmd.args[1:]...); err != nil {
+ t.Fatalf("Send(%v) returned error %v", cmd.args, err)
+ }
+ }
+ reply, err := redis.Values(c.Do(""))
+ if err != nil {
+ t.Fatalf("Do() returned error %v", err)
+ }
+ if len(reply) != len(testCommands) {
+ t.Fatalf("len(reply)=%d, want %d", len(reply), len(testCommands))
+ }
+ for i, cmd := range testCommands {
+ actual := reply[i]
+ if !reflect.DeepEqual(actual, cmd.expected) {
+ t.Errorf("Receive(%v) = %v, want %v", cmd.args, actual, cmd.expected)
+ }
+ }
+}
+
+func TestRecvBeforeSend(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+ done := make(chan struct{})
+ go func() {
+ c.Receive()
+ close(done)
+ }()
+ time.Sleep(time.Millisecond)
+ c.Send("PING")
+ c.Flush()
+ <-done
+ _, err = c.Do("")
+ if err != nil {
+ t.Fatalf("error=%v", err)
+ }
+}
+
+func TestError(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+
+ c.Do("SET", "key", "val")
+ _, err = c.Do("HSET", "key", "fld", "val")
+ if err == nil {
+ t.Errorf("Expected err for HSET on string key.")
+ }
+ if c.Err() != nil {
+ t.Errorf("Conn has Err()=%v, expect nil", c.Err())
+ }
+ _, err = c.Do("SET", "key", "val")
+ if err != nil {
+ t.Errorf("Do(SET, key, val) returned error %v, expected nil.", err)
+ }
+}
+
+func TestReadDeadline(t *testing.T) {
+ l, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("net.Listen returned %v", err)
+ }
+ defer l.Close()
+
+ go func() {
+ for {
+ c, err := l.Accept()
+ if err != nil {
+ return
+ }
+ go func() {
+ time.Sleep(time.Second)
+ c.Write([]byte("+OK\r\n"))
+ c.Close()
+ }()
+ }
+ }()
+
+ c1, err := redis.DialTimeout(l.Addr().Network(), l.Addr().String(), 0, time.Millisecond, 0)
+ if err != nil {
+ t.Fatalf("redis.Dial returned %v", err)
+ }
+ defer c1.Close()
+
+ _, err = c1.Do("PING")
+ if err == nil {
+ t.Fatalf("c1.Do() returned nil, expect error")
+ }
+ if c1.Err() == nil {
+ t.Fatalf("c1.Err() = nil, expect error")
+ }
+
+ c2, err := redis.DialTimeout(l.Addr().Network(), l.Addr().String(), 0, time.Millisecond, 0)
+ if err != nil {
+ t.Fatalf("redis.Dial returned %v", err)
+ }
+ defer c2.Close()
+
+ c2.Send("PING")
+ c2.Flush()
+ _, err = c2.Receive()
+ if err == nil {
+ t.Fatalf("c2.Receive() returned nil, expect error")
+ }
+ if c2.Err() == nil {
+ t.Fatalf("c2.Err() = nil, expect error")
+ }
+}
+
+// Connect to local instance of Redis running on the default port.
+func ExampleDial(x int) {
+ c, err := redis.Dial("tcp", ":6379")
+ if err != nil {
+ // handle error
+ }
+ defer c.Close()
+}
+
+// TextExecError tests handling of errors in a transaction. See
+// http://redis.io/topics/transactions for information on how Redis handles
+// errors in a transaction.
+func TestExecError(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+
+ // Execute commands that fail before EXEC is called.
+
+ c.Do("ZADD", "k0", 0, 0)
+ c.Send("MULTI")
+ c.Send("NOTACOMMAND", "k0", 0, 0)
+ c.Send("ZINCRBY", "k0", 0, 0)
+ v, err := c.Do("EXEC")
+ if err == nil {
+ t.Fatalf("EXEC returned values %v, expected error", v)
+ }
+
+ // Execute commands that fail after EXEC is called. The first command
+ // returns an error.
+
+ c.Do("ZADD", "k1", 0, 0)
+ c.Send("MULTI")
+ c.Send("HSET", "k1", 0, 0)
+ c.Send("ZINCRBY", "k1", 0, 0)
+ v, err = c.Do("EXEC")
+ if err != nil {
+ t.Fatalf("EXEC returned error %v", err)
+ }
+
+ vs, err := redis.Values(v, nil)
+ if err != nil {
+ t.Fatalf("Values(v) returned error %v", err)
+ }
+
+ if len(vs) != 2 {
+ t.Fatalf("len(vs) == %d, want 2", len(vs))
+ }
+
+ if _, ok := vs[0].(error); !ok {
+ t.Fatalf("first result is type %T, expected error", vs[0])
+ }
+
+ if _, ok := vs[1].([]byte); !ok {
+ t.Fatalf("second result is type %T, expected []byte", vs[2])
+ }
+
+ // Execute commands that fail after EXEC is called. The second command
+ // returns an error.
+
+ c.Do("ZADD", "k2", 0, 0)
+ c.Send("MULTI")
+ c.Send("ZINCRBY", "k2", 0, 0)
+ c.Send("HSET", "k2", 0, 0)
+ v, err = c.Do("EXEC")
+ if err != nil {
+ t.Fatalf("EXEC returned error %v", err)
+ }
+
+ vs, err = redis.Values(v, nil)
+ if err != nil {
+ t.Fatalf("Values(v) returned error %v", err)
+ }
+
+ if len(vs) != 2 {
+ t.Fatalf("len(vs) == %d, want 2", len(vs))
+ }
+
+ if _, ok := vs[0].([]byte); !ok {
+ t.Fatalf("first result is type %T, expected []byte", vs[0])
+ }
+
+ if _, ok := vs[1].(error); !ok {
+ t.Fatalf("second result is type %T, expected error", vs[2])
+ }
+}
+
+func BenchmarkDoEmpty(b *testing.B) {
+ b.StopTimer()
+ c, err := redistest.Dial()
+ if err != nil {
+ b.Fatal(err)
+ }
+ defer c.Close()
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ if _, err := c.Do(""); err != nil {
+ b.Fatal(err)
+ }
+ }
+}
+
+func BenchmarkDoPing(b *testing.B) {
+ b.StopTimer()
+ c, err := redistest.Dial()
+ if err != nil {
+ b.Fatal(err)
+ }
+ defer c.Close()
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ if _, err := c.Do("PING"); err != nil {
+ b.Fatal(err)
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go
new file mode 100644
index 000000000..1ae6f0cc2
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go
@@ -0,0 +1,169 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+// Package redis is a client for the Redis database.
+//
+// The Redigo FAQ (https://github.com/garyburd/redigo/wiki/FAQ) contains more
+// documentation about this package.
+//
+// Connections
+//
+// The Conn interface is the primary interface for working with Redis.
+// Applications create connections by calling the Dial, DialWithTimeout or
+// NewConn functions. In the future, functions will be added for creating
+// sharded and other types of connections.
+//
+// The application must call the connection Close method when the application
+// is done with the connection.
+//
+// Executing Commands
+//
+// The Conn interface has a generic method for executing Redis commands:
+//
+// Do(commandName string, args ...interface{}) (reply interface{}, err error)
+//
+// The Redis command reference (http://redis.io/commands) lists the available
+// commands. An example of using the Redis APPEND command is:
+//
+// n, err := conn.Do("APPEND", "key", "value")
+//
+// The Do method converts command arguments to binary strings for transmission
+// to the server as follows:
+//
+// Go Type Conversion
+// []byte Sent as is
+// string Sent as is
+// int, int64 strconv.FormatInt(v)
+// float64 strconv.FormatFloat(v, 'g', -1, 64)
+// bool true -> "1", false -> "0"
+// nil ""
+// all other types fmt.Print(v)
+//
+// Redis command reply types are represented using the following Go types:
+//
+// Redis type Go type
+// error redis.Error
+// integer int64
+// simple string string
+// bulk string []byte or nil if value not present.
+// array []interface{} or nil if value not present.
+//
+// Use type assertions or the reply helper functions to convert from
+// interface{} to the specific Go type for the command result.
+//
+// Pipelining
+//
+// Connections support pipelining using the Send, Flush and Receive methods.
+//
+// Send(commandName string, args ...interface{}) error
+// Flush() error
+// Receive() (reply interface{}, err error)
+//
+// Send writes the command to the connection's output buffer. Flush flushes the
+// connection's output buffer to the server. Receive reads a single reply from
+// the server. The following example shows a simple pipeline.
+//
+// c.Send("SET", "foo", "bar")
+// c.Send("GET", "foo")
+// c.Flush()
+// c.Receive() // reply from SET
+// v, err = c.Receive() // reply from GET
+//
+// The Do method combines the functionality of the Send, Flush and Receive
+// methods. The Do method starts by writing the command and flushing the output
+// buffer. Next, the Do method receives all pending replies including the reply
+// for the command just sent by Do. If any of the received replies is an error,
+// then Do returns the error. If there are no errors, then Do returns the last
+// reply. If the command argument to the Do method is "", then the Do method
+// will flush the output buffer and receive pending replies without sending a
+// command.
+//
+// Use the Send and Do methods to implement pipelined transactions.
+//
+// c.Send("MULTI")
+// c.Send("INCR", "foo")
+// c.Send("INCR", "bar")
+// r, err := c.Do("EXEC")
+// fmt.Println(r) // prints [1, 1]
+//
+// Concurrency
+//
+// Connections do not support concurrent calls to the write methods (Send,
+// Flush) or concurrent calls to the read method (Receive). Connections do
+// allow a concurrent reader and writer.
+//
+// Because the Do method combines the functionality of Send, Flush and Receive,
+// the Do method cannot be called concurrently with the other methods.
+//
+// For full concurrent access to Redis, use the thread-safe Pool to get and
+// release connections from within a goroutine.
+//
+// Publish and Subscribe
+//
+// Use the Send, Flush and Receive methods to implement Pub/Sub subscribers.
+//
+// c.Send("SUBSCRIBE", "example")
+// c.Flush()
+// for {
+// reply, err := c.Receive()
+// if err != nil {
+// return err
+// }
+// // process pushed message
+// }
+//
+// The PubSubConn type wraps a Conn with convenience methods for implementing
+// subscribers. The Subscribe, PSubscribe, Unsubscribe and PUnsubscribe methods
+// send and flush a subscription management command. The receive method
+// converts a pushed message to convenient types for use in a type switch.
+//
+// psc := redis.PubSubConn{c}
+// psc.Subscribe("example")
+// for {
+// switch v := psc.Receive().(type) {
+// case redis.Message:
+// fmt.Printf("%s: message: %s\n", v.Channel, v.Data)
+// case redis.Subscription:
+// fmt.Printf("%s: %s %d\n", v.Channel, v.Kind, v.Count)
+// case error:
+// return v
+// }
+// }
+//
+// Reply Helpers
+//
+// The Bool, Int, Bytes, String, Strings and Values functions convert a reply
+// to a value of a specific type. To allow convenient wrapping of calls to the
+// connection Do and Receive methods, the functions take a second argument of
+// type error. If the error is non-nil, then the helper function returns the
+// error. If the error is nil, the function converts the reply to the specified
+// type:
+//
+// exists, err := redis.Bool(c.Do("EXISTS", "foo"))
+// if err != nil {
+// // handle error return from c.Do or type conversion error.
+// }
+//
+// The Scan function converts elements of a array reply to Go types:
+//
+// var value1 int
+// var value2 string
+// reply, err := redis.Values(c.Do("MGET", "key1", "key2"))
+// if err != nil {
+// // handle error
+// }
+// if _, err := redis.Scan(reply, &value1, &value2); err != nil {
+// // handle error
+// }
+package redis
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go
new file mode 100644
index 000000000..129b86d67
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go
@@ -0,0 +1,117 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "bytes"
+ "fmt"
+ "log"
+)
+
+// NewLoggingConn returns a logging wrapper around a connection.
+func NewLoggingConn(conn Conn, logger *log.Logger, prefix string) Conn {
+ if prefix != "" {
+ prefix = prefix + "."
+ }
+ return &loggingConn{conn, logger, prefix}
+}
+
+type loggingConn struct {
+ Conn
+ logger *log.Logger
+ prefix string
+}
+
+func (c *loggingConn) Close() error {
+ err := c.Conn.Close()
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "%sClose() -> (%v)", c.prefix, err)
+ c.logger.Output(2, buf.String())
+ return err
+}
+
+func (c *loggingConn) printValue(buf *bytes.Buffer, v interface{}) {
+ const chop = 32
+ switch v := v.(type) {
+ case []byte:
+ if len(v) > chop {
+ fmt.Fprintf(buf, "%q...", v[:chop])
+ } else {
+ fmt.Fprintf(buf, "%q", v)
+ }
+ case string:
+ if len(v) > chop {
+ fmt.Fprintf(buf, "%q...", v[:chop])
+ } else {
+ fmt.Fprintf(buf, "%q", v)
+ }
+ case []interface{}:
+ if len(v) == 0 {
+ buf.WriteString("[]")
+ } else {
+ sep := "["
+ fin := "]"
+ if len(v) > chop {
+ v = v[:chop]
+ fin = "...]"
+ }
+ for _, vv := range v {
+ buf.WriteString(sep)
+ c.printValue(buf, vv)
+ sep = ", "
+ }
+ buf.WriteString(fin)
+ }
+ default:
+ fmt.Fprint(buf, v)
+ }
+}
+
+func (c *loggingConn) print(method, commandName string, args []interface{}, reply interface{}, err error) {
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "%s%s(", c.prefix, method)
+ if method != "Receive" {
+ buf.WriteString(commandName)
+ for _, arg := range args {
+ buf.WriteString(", ")
+ c.printValue(&buf, arg)
+ }
+ }
+ buf.WriteString(") -> (")
+ if method != "Send" {
+ c.printValue(&buf, reply)
+ buf.WriteString(", ")
+ }
+ fmt.Fprintf(&buf, "%v)", err)
+ c.logger.Output(3, buf.String())
+}
+
+func (c *loggingConn) Do(commandName string, args ...interface{}) (interface{}, error) {
+ reply, err := c.Conn.Do(commandName, args...)
+ c.print("Do", commandName, args, reply, err)
+ return reply, err
+}
+
+func (c *loggingConn) Send(commandName string, args ...interface{}) error {
+ err := c.Conn.Send(commandName, args...)
+ c.print("Send", commandName, args, nil, err)
+ return err
+}
+
+func (c *loggingConn) Receive() (interface{}, error) {
+ reply, err := c.Conn.Receive()
+ c.print("Receive", "", nil, reply, err)
+ return reply, err
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go
new file mode 100644
index 000000000..9daf2e33f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go
@@ -0,0 +1,389 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "bytes"
+ "container/list"
+ "crypto/rand"
+ "crypto/sha1"
+ "errors"
+ "io"
+ "strconv"
+ "sync"
+ "time"
+
+ "github.com/garyburd/redigo/internal"
+)
+
+var nowFunc = time.Now // for testing
+
+// ErrPoolExhausted is returned from a pool connection method (Do, Send,
+// Receive, Flush, Err) when the maximum number of database connections in the
+// pool has been reached.
+var ErrPoolExhausted = errors.New("redigo: connection pool exhausted")
+
+var (
+ errPoolClosed = errors.New("redigo: connection pool closed")
+ errConnClosed = errors.New("redigo: connection closed")
+)
+
+// Pool maintains a pool of connections. The application calls the Get method
+// to get a connection from the pool and the connection's Close method to
+// return the connection's resources to the pool.
+//
+// The following example shows how to use a pool in a web application. The
+// application creates a pool at application startup and makes it available to
+// request handlers using a global variable.
+//
+// func newPool(server, password string) *redis.Pool {
+// return &redis.Pool{
+// MaxIdle: 3,
+// IdleTimeout: 240 * time.Second,
+// Dial: func () (redis.Conn, error) {
+// c, err := redis.Dial("tcp", server)
+// if err != nil {
+// return nil, err
+// }
+// if _, err := c.Do("AUTH", password); err != nil {
+// c.Close()
+// return nil, err
+// }
+// return c, err
+// },
+// TestOnBorrow: func(c redis.Conn, t time.Time) error {
+// _, err := c.Do("PING")
+// return err
+// },
+// }
+// }
+//
+// var (
+// pool *redis.Pool
+// redisServer = flag.String("redisServer", ":6379", "")
+// redisPassword = flag.String("redisPassword", "", "")
+// )
+//
+// func main() {
+// flag.Parse()
+// pool = newPool(*redisServer, *redisPassword)
+// ...
+// }
+//
+// A request handler gets a connection from the pool and closes the connection
+// when the handler is done:
+//
+// func serveHome(w http.ResponseWriter, r *http.Request) {
+// conn := pool.Get()
+// defer conn.Close()
+// ....
+// }
+//
+type Pool struct {
+
+ // Dial is an application supplied function for creating and configuring a
+ // connection
+ Dial func() (Conn, error)
+
+ // TestOnBorrow is an optional application supplied function for checking
+ // the health of an idle connection before the connection is used again by
+ // the application. Argument t is the time that the connection was returned
+ // to the pool. If the function returns an error, then the connection is
+ // closed.
+ TestOnBorrow func(c Conn, t time.Time) error
+
+ // Maximum number of idle connections in the pool.
+ MaxIdle int
+
+ // Maximum number of connections allocated by the pool at a given time.
+ // When zero, there is no limit on the number of connections in the pool.
+ MaxActive int
+
+ // Close connections after remaining idle for this duration. If the value
+ // is zero, then idle connections are not closed. Applications should set
+ // the timeout to a value less than the server's timeout.
+ IdleTimeout time.Duration
+
+ // If Wait is true and the pool is at the MaxIdle limit, then Get() waits
+ // for a connection to be returned to the pool before returning.
+ Wait bool
+
+ // mu protects fields defined below.
+ mu sync.Mutex
+ cond *sync.Cond
+ closed bool
+ active int
+
+ // Stack of idleConn with most recently used at the front.
+ idle list.List
+}
+
+type idleConn struct {
+ c Conn
+ t time.Time
+}
+
+// NewPool creates a new pool. This function is deprecated. Applications should
+// initialize the Pool fields directly as shown in example.
+func NewPool(newFn func() (Conn, error), maxIdle int) *Pool {
+ return &Pool{Dial: newFn, MaxIdle: maxIdle}
+}
+
+// Get gets a connection. The application must close the returned connection.
+// This method always returns a valid connection so that applications can defer
+// error handling to the first use of the connection. If there is an error
+// getting an underlying connection, then the connection Err, Do, Send, Flush
+// and Receive methods return that error.
+func (p *Pool) Get() Conn {
+ c, err := p.get()
+ if err != nil {
+ return errorConnection{err}
+ }
+ return &pooledConnection{p: p, c: c}
+}
+
+// ActiveCount returns the number of active connections in the pool.
+func (p *Pool) ActiveCount() int {
+ p.mu.Lock()
+ active := p.active
+ p.mu.Unlock()
+ return active
+}
+
+// Close releases the resources used by the pool.
+func (p *Pool) Close() error {
+ p.mu.Lock()
+ idle := p.idle
+ p.idle.Init()
+ p.closed = true
+ p.active -= idle.Len()
+ if p.cond != nil {
+ p.cond.Broadcast()
+ }
+ p.mu.Unlock()
+ for e := idle.Front(); e != nil; e = e.Next() {
+ e.Value.(idleConn).c.Close()
+ }
+ return nil
+}
+
+// release decrements the active count and signals waiters. The caller must
+// hold p.mu during the call.
+func (p *Pool) release() {
+ p.active -= 1
+ if p.cond != nil {
+ p.cond.Signal()
+ }
+}
+
+// get prunes stale connections and returns a connection from the idle list or
+// creates a new connection.
+func (p *Pool) get() (Conn, error) {
+ p.mu.Lock()
+
+ // Prune stale connections.
+
+ if timeout := p.IdleTimeout; timeout > 0 {
+ for i, n := 0, p.idle.Len(); i < n; i++ {
+ e := p.idle.Back()
+ if e == nil {
+ break
+ }
+ ic := e.Value.(idleConn)
+ if ic.t.Add(timeout).After(nowFunc()) {
+ break
+ }
+ p.idle.Remove(e)
+ p.release()
+ p.mu.Unlock()
+ ic.c.Close()
+ p.mu.Lock()
+ }
+ }
+
+ for {
+
+ // Get idle connection.
+
+ for i, n := 0, p.idle.Len(); i < n; i++ {
+ e := p.idle.Front()
+ if e == nil {
+ break
+ }
+ ic := e.Value.(idleConn)
+ p.idle.Remove(e)
+ test := p.TestOnBorrow
+ p.mu.Unlock()
+ if test == nil || test(ic.c, ic.t) == nil {
+ return ic.c, nil
+ }
+ ic.c.Close()
+ p.mu.Lock()
+ p.release()
+ }
+
+ // Check for pool closed before dialing a new connection.
+
+ if p.closed {
+ p.mu.Unlock()
+ return nil, errors.New("redigo: get on closed pool")
+ }
+
+ // Dial new connection if under limit.
+
+ if p.MaxActive == 0 || p.active < p.MaxActive {
+ dial := p.Dial
+ p.active += 1
+ p.mu.Unlock()
+ c, err := dial()
+ if err != nil {
+ p.mu.Lock()
+ p.release()
+ p.mu.Unlock()
+ c = nil
+ }
+ return c, err
+ }
+
+ if !p.Wait {
+ p.mu.Unlock()
+ return nil, ErrPoolExhausted
+ }
+
+ if p.cond == nil {
+ p.cond = sync.NewCond(&p.mu)
+ }
+ p.cond.Wait()
+ }
+}
+
+func (p *Pool) put(c Conn, forceClose bool) error {
+ err := c.Err()
+ p.mu.Lock()
+ if !p.closed && err == nil && !forceClose {
+ p.idle.PushFront(idleConn{t: nowFunc(), c: c})
+ if p.idle.Len() > p.MaxIdle {
+ c = p.idle.Remove(p.idle.Back()).(idleConn).c
+ } else {
+ c = nil
+ }
+ }
+
+ if c == nil {
+ if p.cond != nil {
+ p.cond.Signal()
+ }
+ p.mu.Unlock()
+ return nil
+ }
+
+ p.release()
+ p.mu.Unlock()
+ return c.Close()
+}
+
+type pooledConnection struct {
+ p *Pool
+ c Conn
+ state int
+}
+
+var (
+ sentinel []byte
+ sentinelOnce sync.Once
+)
+
+func initSentinel() {
+ p := make([]byte, 64)
+ if _, err := rand.Read(p); err == nil {
+ sentinel = p
+ } else {
+ h := sha1.New()
+ io.WriteString(h, "Oops, rand failed. Use time instead.")
+ io.WriteString(h, strconv.FormatInt(time.Now().UnixNano(), 10))
+ sentinel = h.Sum(nil)
+ }
+}
+
+func (pc *pooledConnection) Close() error {
+ c := pc.c
+ if _, ok := c.(errorConnection); ok {
+ return nil
+ }
+ pc.c = errorConnection{errConnClosed}
+
+ if pc.state&internal.MultiState != 0 {
+ c.Send("DISCARD")
+ pc.state &^= (internal.MultiState | internal.WatchState)
+ } else if pc.state&internal.WatchState != 0 {
+ c.Send("UNWATCH")
+ pc.state &^= internal.WatchState
+ }
+ if pc.state&internal.SubscribeState != 0 {
+ c.Send("UNSUBSCRIBE")
+ c.Send("PUNSUBSCRIBE")
+ // To detect the end of the message stream, ask the server to echo
+ // a sentinel value and read until we see that value.
+ sentinelOnce.Do(initSentinel)
+ c.Send("ECHO", sentinel)
+ c.Flush()
+ for {
+ p, err := c.Receive()
+ if err != nil {
+ break
+ }
+ if p, ok := p.([]byte); ok && bytes.Equal(p, sentinel) {
+ pc.state &^= internal.SubscribeState
+ break
+ }
+ }
+ }
+ c.Do("")
+ pc.p.put(c, pc.state != 0)
+ return nil
+}
+
+func (pc *pooledConnection) Err() error {
+ return pc.c.Err()
+}
+
+func (pc *pooledConnection) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
+ ci := internal.LookupCommandInfo(commandName)
+ pc.state = (pc.state | ci.Set) &^ ci.Clear
+ return pc.c.Do(commandName, args...)
+}
+
+func (pc *pooledConnection) Send(commandName string, args ...interface{}) error {
+ ci := internal.LookupCommandInfo(commandName)
+ pc.state = (pc.state | ci.Set) &^ ci.Clear
+ return pc.c.Send(commandName, args...)
+}
+
+func (pc *pooledConnection) Flush() error {
+ return pc.c.Flush()
+}
+
+func (pc *pooledConnection) Receive() (reply interface{}, err error) {
+ return pc.c.Receive()
+}
+
+type errorConnection struct{ err error }
+
+func (ec errorConnection) Do(string, ...interface{}) (interface{}, error) { return nil, ec.err }
+func (ec errorConnection) Send(string, ...interface{}) error { return ec.err }
+func (ec errorConnection) Err() error { return ec.err }
+func (ec errorConnection) Close() error { return ec.err }
+func (ec errorConnection) Flush() error { return ec.err }
+func (ec errorConnection) Receive() (interface{}, error) { return nil, ec.err }
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool_test.go
new file mode 100644
index 000000000..1fe305f16
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool_test.go
@@ -0,0 +1,674 @@
+// Copyright 2011 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "errors"
+ "io"
+ "reflect"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/garyburd/redigo/internal/redistest"
+ "github.com/garyburd/redigo/redis"
+)
+
+type poolTestConn struct {
+ d *poolDialer
+ err error
+ redis.Conn
+}
+
+func (c *poolTestConn) Close() error { c.d.open -= 1; return nil }
+func (c *poolTestConn) Err() error { return c.err }
+
+func (c *poolTestConn) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
+ if commandName == "ERR" {
+ c.err = args[0].(error)
+ commandName = "PING"
+ }
+ if commandName != "" {
+ c.d.commands = append(c.d.commands, commandName)
+ }
+ return c.Conn.Do(commandName, args...)
+}
+
+func (c *poolTestConn) Send(commandName string, args ...interface{}) error {
+ c.d.commands = append(c.d.commands, commandName)
+ return c.Conn.Send(commandName, args...)
+}
+
+type poolDialer struct {
+ t *testing.T
+ dialed int
+ open int
+ commands []string
+ dialErr error
+}
+
+func (d *poolDialer) dial() (redis.Conn, error) {
+ d.dialed += 1
+ if d.dialErr != nil {
+ return nil, d.dialErr
+ }
+ c, err := redistest.Dial()
+ if err != nil {
+ return nil, err
+ }
+ d.open += 1
+ return &poolTestConn{d: d, Conn: c}, nil
+}
+
+func (d *poolDialer) check(message string, p *redis.Pool, dialed, open int) {
+ if d.dialed != dialed {
+ d.t.Errorf("%s: dialed=%d, want %d", message, d.dialed, dialed)
+ }
+ if d.open != open {
+ d.t.Errorf("%s: open=%d, want %d", message, d.open, open)
+ }
+ if active := p.ActiveCount(); active != open {
+ d.t.Errorf("%s: active=%d, want %d", message, active, open)
+ }
+}
+
+func TestPoolReuse(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ Dial: d.dial,
+ }
+
+ for i := 0; i < 10; i++ {
+ c1 := p.Get()
+ c1.Do("PING")
+ c2 := p.Get()
+ c2.Do("PING")
+ c1.Close()
+ c2.Close()
+ }
+
+ d.check("before close", p, 2, 2)
+ p.Close()
+ d.check("after close", p, 2, 0)
+}
+
+func TestPoolMaxIdle(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ Dial: d.dial,
+ }
+ for i := 0; i < 10; i++ {
+ c1 := p.Get()
+ c1.Do("PING")
+ c2 := p.Get()
+ c2.Do("PING")
+ c3 := p.Get()
+ c3.Do("PING")
+ c1.Close()
+ c2.Close()
+ c3.Close()
+ }
+ d.check("before close", p, 12, 2)
+ p.Close()
+ d.check("after close", p, 12, 0)
+}
+
+func TestPoolError(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ Dial: d.dial,
+ }
+
+ c := p.Get()
+ c.Do("ERR", io.EOF)
+ if c.Err() == nil {
+ t.Errorf("expected c.Err() != nil")
+ }
+ c.Close()
+
+ c = p.Get()
+ c.Do("ERR", io.EOF)
+ c.Close()
+
+ d.check(".", p, 2, 0)
+}
+
+func TestPoolClose(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ Dial: d.dial,
+ }
+
+ c1 := p.Get()
+ c1.Do("PING")
+ c2 := p.Get()
+ c2.Do("PING")
+ c3 := p.Get()
+ c3.Do("PING")
+
+ c1.Close()
+ if _, err := c1.Do("PING"); err == nil {
+ t.Errorf("expected error after connection closed")
+ }
+
+ c2.Close()
+ c2.Close()
+
+ p.Close()
+
+ d.check("after pool close", p, 3, 1)
+
+ if _, err := c1.Do("PING"); err == nil {
+ t.Errorf("expected error after connection and pool closed")
+ }
+
+ c3.Close()
+
+ d.check("after conn close", p, 3, 0)
+
+ c1 = p.Get()
+ if _, err := c1.Do("PING"); err == nil {
+ t.Errorf("expected error after pool closed")
+ }
+}
+
+func TestPoolTimeout(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ IdleTimeout: 300 * time.Second,
+ Dial: d.dial,
+ }
+
+ now := time.Now()
+ redis.SetNowFunc(func() time.Time { return now })
+ defer redis.SetNowFunc(time.Now)
+
+ c := p.Get()
+ c.Do("PING")
+ c.Close()
+
+ d.check("1", p, 1, 1)
+
+ now = now.Add(p.IdleTimeout)
+
+ c = p.Get()
+ c.Do("PING")
+ c.Close()
+
+ d.check("2", p, 2, 1)
+
+ p.Close()
+}
+
+func TestPoolConcurrenSendReceive(t *testing.T) {
+ p := &redis.Pool{
+ Dial: redistest.Dial,
+ }
+ c := p.Get()
+ done := make(chan error, 1)
+ go func() {
+ _, err := c.Receive()
+ done <- err
+ }()
+ c.Send("PING")
+ c.Flush()
+ err := <-done
+ if err != nil {
+ t.Fatalf("Receive() returned error %v", err)
+ }
+ _, err = c.Do("")
+ if err != nil {
+ t.Fatalf("Do() returned error %v", err)
+ }
+ c.Close()
+ p.Close()
+}
+
+func TestPoolBorrowCheck(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ Dial: d.dial,
+ TestOnBorrow: func(redis.Conn, time.Time) error { return redis.Error("BLAH") },
+ }
+
+ for i := 0; i < 10; i++ {
+ c := p.Get()
+ c.Do("PING")
+ c.Close()
+ }
+ d.check("1", p, 10, 1)
+ p.Close()
+}
+
+func TestPoolMaxActive(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ MaxActive: 2,
+ Dial: d.dial,
+ }
+ c1 := p.Get()
+ c1.Do("PING")
+ c2 := p.Get()
+ c2.Do("PING")
+
+ d.check("1", p, 2, 2)
+
+ c3 := p.Get()
+ if _, err := c3.Do("PING"); err != redis.ErrPoolExhausted {
+ t.Errorf("expected pool exhausted")
+ }
+
+ c3.Close()
+ d.check("2", p, 2, 2)
+ c2.Close()
+ d.check("3", p, 2, 2)
+
+ c3 = p.Get()
+ if _, err := c3.Do("PING"); err != nil {
+ t.Errorf("expected good channel, err=%v", err)
+ }
+ c3.Close()
+
+ d.check("4", p, 2, 2)
+ p.Close()
+}
+
+func TestPoolMonitorCleanup(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ MaxActive: 2,
+ Dial: d.dial,
+ }
+ c := p.Get()
+ c.Send("MONITOR")
+ c.Close()
+
+ d.check("", p, 1, 0)
+ p.Close()
+}
+
+func TestPoolPubSubCleanup(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ MaxActive: 2,
+ Dial: d.dial,
+ }
+
+ c := p.Get()
+ c.Send("SUBSCRIBE", "x")
+ c.Close()
+
+ want := []string{"SUBSCRIBE", "UNSUBSCRIBE", "PUNSUBSCRIBE", "ECHO"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ c = p.Get()
+ c.Send("PSUBSCRIBE", "x*")
+ c.Close()
+
+ want = []string{"PSUBSCRIBE", "UNSUBSCRIBE", "PUNSUBSCRIBE", "ECHO"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ p.Close()
+}
+
+func TestPoolTransactionCleanup(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 2,
+ MaxActive: 2,
+ Dial: d.dial,
+ }
+
+ c := p.Get()
+ c.Do("WATCH", "key")
+ c.Do("PING")
+ c.Close()
+
+ want := []string{"WATCH", "PING", "UNWATCH"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ c = p.Get()
+ c.Do("WATCH", "key")
+ c.Do("UNWATCH")
+ c.Do("PING")
+ c.Close()
+
+ want = []string{"WATCH", "UNWATCH", "PING"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ c = p.Get()
+ c.Do("WATCH", "key")
+ c.Do("MULTI")
+ c.Do("PING")
+ c.Close()
+
+ want = []string{"WATCH", "MULTI", "PING", "DISCARD"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ c = p.Get()
+ c.Do("WATCH", "key")
+ c.Do("MULTI")
+ c.Do("DISCARD")
+ c.Do("PING")
+ c.Close()
+
+ want = []string{"WATCH", "MULTI", "DISCARD", "PING"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ c = p.Get()
+ c.Do("WATCH", "key")
+ c.Do("MULTI")
+ c.Do("EXEC")
+ c.Do("PING")
+ c.Close()
+
+ want = []string{"WATCH", "MULTI", "EXEC", "PING"}
+ if !reflect.DeepEqual(d.commands, want) {
+ t.Errorf("got commands %v, want %v", d.commands, want)
+ }
+ d.commands = nil
+
+ p.Close()
+}
+
+func startGoroutines(p *redis.Pool, cmd string, args ...interface{}) chan error {
+ errs := make(chan error, 10)
+ for i := 0; i < cap(errs); i++ {
+ go func() {
+ c := p.Get()
+ _, err := c.Do(cmd, args...)
+ errs <- err
+ c.Close()
+ }()
+ }
+
+ // Wait for goroutines to block.
+ time.Sleep(time.Second / 4)
+
+ return errs
+}
+
+func TestWaitPool(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 1,
+ MaxActive: 1,
+ Dial: d.dial,
+ Wait: true,
+ }
+ defer p.Close()
+ c := p.Get()
+ errs := startGoroutines(p, "PING")
+ d.check("before close", p, 1, 1)
+ c.Close()
+ timeout := time.After(2 * time.Second)
+ for i := 0; i < cap(errs); i++ {
+ select {
+ case err := <-errs:
+ if err != nil {
+ t.Fatal(err)
+ }
+ case <-timeout:
+ t.Fatalf("timeout waiting for blocked goroutine %d", i)
+ }
+ }
+ d.check("done", p, 1, 1)
+}
+
+func TestWaitPoolClose(t *testing.T) {
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 1,
+ MaxActive: 1,
+ Dial: d.dial,
+ Wait: true,
+ }
+ c := p.Get()
+ if _, err := c.Do("PING"); err != nil {
+ t.Fatal(err)
+ }
+ errs := startGoroutines(p, "PING")
+ d.check("before close", p, 1, 1)
+ p.Close()
+ timeout := time.After(2 * time.Second)
+ for i := 0; i < cap(errs); i++ {
+ select {
+ case err := <-errs:
+ switch err {
+ case nil:
+ t.Fatal("blocked goroutine did not get error")
+ case redis.ErrPoolExhausted:
+ t.Fatal("blocked goroutine got pool exhausted error")
+ }
+ case <-timeout:
+ t.Fatal("timeout waiting for blocked goroutine")
+ }
+ }
+ c.Close()
+ d.check("done", p, 1, 0)
+}
+
+func TestWaitPoolCommandError(t *testing.T) {
+ testErr := errors.New("test")
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 1,
+ MaxActive: 1,
+ Dial: d.dial,
+ Wait: true,
+ }
+ defer p.Close()
+ c := p.Get()
+ errs := startGoroutines(p, "ERR", testErr)
+ d.check("before close", p, 1, 1)
+ c.Close()
+ timeout := time.After(2 * time.Second)
+ for i := 0; i < cap(errs); i++ {
+ select {
+ case err := <-errs:
+ if err != nil {
+ t.Fatal(err)
+ }
+ case <-timeout:
+ t.Fatalf("timeout waiting for blocked goroutine %d", i)
+ }
+ }
+ d.check("done", p, cap(errs), 0)
+}
+
+func TestWaitPoolDialError(t *testing.T) {
+ testErr := errors.New("test")
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: 1,
+ MaxActive: 1,
+ Dial: d.dial,
+ Wait: true,
+ }
+ defer p.Close()
+ c := p.Get()
+ errs := startGoroutines(p, "ERR", testErr)
+ d.check("before close", p, 1, 1)
+
+ d.dialErr = errors.New("dial")
+ c.Close()
+
+ nilCount := 0
+ errCount := 0
+ timeout := time.After(2 * time.Second)
+ for i := 0; i < cap(errs); i++ {
+ select {
+ case err := <-errs:
+ switch err {
+ case nil:
+ nilCount++
+ case d.dialErr:
+ errCount++
+ default:
+ t.Fatalf("expected dial error or nil, got %v", err)
+ }
+ case <-timeout:
+ t.Fatalf("timeout waiting for blocked goroutine %d", i)
+ }
+ }
+ if nilCount != 1 {
+ t.Errorf("expected one nil error, got %d", nilCount)
+ }
+ if errCount != cap(errs)-1 {
+ t.Errorf("expected %d dial erors, got %d", cap(errs)-1, errCount)
+ }
+ d.check("done", p, cap(errs), 0)
+}
+
+// Borrowing requires us to iterate over the idle connections, unlock the pool,
+// and perform a blocking operation to check the connection still works. If
+// TestOnBorrow fails, we must reacquire the lock and continue iteration. This
+// test ensures that iteration will work correctly if multiple threads are
+// iterating simultaneously.
+func TestLocking_TestOnBorrowFails_PoolDoesntCrash(t *testing.T) {
+ count := 100
+
+ // First we'll Create a pool where the pilfering of idle connections fails.
+ d := poolDialer{t: t}
+ p := &redis.Pool{
+ MaxIdle: count,
+ MaxActive: count,
+ Dial: d.dial,
+ TestOnBorrow: func(c redis.Conn, t time.Time) error {
+ return errors.New("No way back into the real world.")
+ },
+ }
+ defer p.Close()
+
+ // Fill the pool with idle connections.
+ b1 := sync.WaitGroup{}
+ b1.Add(count)
+ b2 := sync.WaitGroup{}
+ b2.Add(count)
+ for i := 0; i < count; i++ {
+ go func() {
+ c := p.Get()
+ if c.Err() != nil {
+ t.Errorf("pool get failed: %v", c.Err())
+ }
+ b1.Done()
+ b1.Wait()
+ c.Close()
+ b2.Done()
+ }()
+ }
+ b2.Wait()
+ if d.dialed != count {
+ t.Errorf("Expected %d dials, got %d", count, d.dialed)
+ }
+
+ // Spawn a bunch of goroutines to thrash the pool.
+ b2.Add(count)
+ for i := 0; i < count; i++ {
+ go func() {
+ c := p.Get()
+ if c.Err() != nil {
+ t.Errorf("pool get failed: %v", c.Err())
+ }
+ c.Close()
+ b2.Done()
+ }()
+ }
+ b2.Wait()
+ if d.dialed != count*2 {
+ t.Errorf("Expected %d dials, got %d", count*2, d.dialed)
+ }
+}
+
+func BenchmarkPoolGet(b *testing.B) {
+ b.StopTimer()
+ p := redis.Pool{Dial: redistest.Dial, MaxIdle: 2}
+ c := p.Get()
+ if err := c.Err(); err != nil {
+ b.Fatal(err)
+ }
+ c.Close()
+ defer p.Close()
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ c = p.Get()
+ c.Close()
+ }
+}
+
+func BenchmarkPoolGetErr(b *testing.B) {
+ b.StopTimer()
+ p := redis.Pool{Dial: redistest.Dial, MaxIdle: 2}
+ c := p.Get()
+ if err := c.Err(); err != nil {
+ b.Fatal(err)
+ }
+ c.Close()
+ defer p.Close()
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ c = p.Get()
+ if err := c.Err(); err != nil {
+ b.Fatal(err)
+ }
+ c.Close()
+ }
+}
+
+func BenchmarkPoolGetPing(b *testing.B) {
+ b.StopTimer()
+ p := redis.Pool{Dial: redistest.Dial, MaxIdle: 2}
+ c := p.Get()
+ if err := c.Err(); err != nil {
+ b.Fatal(err)
+ }
+ c.Close()
+ defer p.Close()
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ c = p.Get()
+ if _, err := c.Do("PING"); err != nil {
+ b.Fatal(err)
+ }
+ c.Close()
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go
new file mode 100644
index 000000000..c0ecce824
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go
@@ -0,0 +1,144 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import "errors"
+
+// Subscription represents a subscribe or unsubscribe notification.
+type Subscription struct {
+
+ // Kind is "subscribe", "unsubscribe", "psubscribe" or "punsubscribe"
+ Kind string
+
+ // The channel that was changed.
+ Channel string
+
+ // The current number of subscriptions for connection.
+ Count int
+}
+
+// Message represents a message notification.
+type Message struct {
+
+ // The originating channel.
+ Channel string
+
+ // The message data.
+ Data []byte
+}
+
+// PMessage represents a pmessage notification.
+type PMessage struct {
+
+ // The matched pattern.
+ Pattern string
+
+ // The originating channel.
+ Channel string
+
+ // The message data.
+ Data []byte
+}
+
+// Pong represents a pubsub pong notification.
+type Pong struct {
+ Data string
+}
+
+// PubSubConn wraps a Conn with convenience methods for subscribers.
+type PubSubConn struct {
+ Conn Conn
+}
+
+// Close closes the connection.
+func (c PubSubConn) Close() error {
+ return c.Conn.Close()
+}
+
+// Subscribe subscribes the connection to the specified channels.
+func (c PubSubConn) Subscribe(channel ...interface{}) error {
+ c.Conn.Send("SUBSCRIBE", channel...)
+ return c.Conn.Flush()
+}
+
+// PSubscribe subscribes the connection to the given patterns.
+func (c PubSubConn) PSubscribe(channel ...interface{}) error {
+ c.Conn.Send("PSUBSCRIBE", channel...)
+ return c.Conn.Flush()
+}
+
+// Unsubscribe unsubscribes the connection from the given channels, or from all
+// of them if none is given.
+func (c PubSubConn) Unsubscribe(channel ...interface{}) error {
+ c.Conn.Send("UNSUBSCRIBE", channel...)
+ return c.Conn.Flush()
+}
+
+// PUnsubscribe unsubscribes the connection from the given patterns, or from all
+// of them if none is given.
+func (c PubSubConn) PUnsubscribe(channel ...interface{}) error {
+ c.Conn.Send("PUNSUBSCRIBE", channel...)
+ return c.Conn.Flush()
+}
+
+// Ping sends a PING to the server with the specified data.
+func (c PubSubConn) Ping(data string) error {
+ c.Conn.Send("PING", data)
+ return c.Conn.Flush()
+}
+
+// Receive returns a pushed message as a Subscription, Message, PMessage, Pong
+// or error. The return value is intended to be used directly in a type switch
+// as illustrated in the PubSubConn example.
+func (c PubSubConn) Receive() interface{} {
+ reply, err := Values(c.Conn.Receive())
+ if err != nil {
+ return err
+ }
+
+ var kind string
+ reply, err = Scan(reply, &kind)
+ if err != nil {
+ return err
+ }
+
+ switch kind {
+ case "message":
+ var m Message
+ if _, err := Scan(reply, &m.Channel, &m.Data); err != nil {
+ return err
+ }
+ return m
+ case "pmessage":
+ var pm PMessage
+ if _, err := Scan(reply, &pm.Pattern, &pm.Channel, &pm.Data); err != nil {
+ return err
+ }
+ return pm
+ case "subscribe", "psubscribe", "unsubscribe", "punsubscribe":
+ s := Subscription{Kind: kind}
+ if _, err := Scan(reply, &s.Channel, &s.Count); err != nil {
+ return err
+ }
+ return s
+ case "pong":
+ var p Pong
+ if _, err := Scan(reply, &p.Data); err != nil {
+ return err
+ }
+ return p
+ }
+ return errors.New("redigo: unknown pubsub notification")
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub_test.go
new file mode 100644
index 000000000..365a58821
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub_test.go
@@ -0,0 +1,150 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "fmt"
+ "net"
+ "reflect"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/garyburd/redigo/internal/redistest"
+ "github.com/garyburd/redigo/redis"
+)
+
+func publish(channel, value interface{}) {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+ c.Do("PUBLISH", channel, value)
+}
+
+// Applications can receive pushed messages from one goroutine and manage subscriptions from another goroutine.
+func ExamplePubSubConn() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+ var wg sync.WaitGroup
+ wg.Add(2)
+
+ psc := redis.PubSubConn{Conn: c}
+
+ // This goroutine receives and prints pushed notifications from the server.
+ // The goroutine exits when the connection is unsubscribed from all
+ // channels or there is an error.
+ go func() {
+ defer wg.Done()
+ for {
+ switch n := psc.Receive().(type) {
+ case redis.Message:
+ fmt.Printf("Message: %s %s\n", n.Channel, n.Data)
+ case redis.PMessage:
+ fmt.Printf("PMessage: %s %s %s\n", n.Pattern, n.Channel, n.Data)
+ case redis.Subscription:
+ fmt.Printf("Subscription: %s %s %d\n", n.Kind, n.Channel, n.Count)
+ if n.Count == 0 {
+ return
+ }
+ case error:
+ fmt.Printf("error: %v\n", n)
+ return
+ }
+ }
+ }()
+
+ // This goroutine manages subscriptions for the connection.
+ go func() {
+ defer wg.Done()
+
+ psc.Subscribe("example")
+ psc.PSubscribe("p*")
+
+ // The following function calls publish a message using another
+ // connection to the Redis server.
+ publish("example", "hello")
+ publish("example", "world")
+ publish("pexample", "foo")
+ publish("pexample", "bar")
+
+ // Unsubscribe from all connections. This will cause the receiving
+ // goroutine to exit.
+ psc.Unsubscribe()
+ psc.PUnsubscribe()
+ }()
+
+ wg.Wait()
+
+ // Output:
+ // Subscription: subscribe example 1
+ // Subscription: psubscribe p* 2
+ // Message: example hello
+ // Message: example world
+ // PMessage: p* pexample foo
+ // PMessage: p* pexample bar
+ // Subscription: unsubscribe example 1
+ // Subscription: punsubscribe p* 0
+}
+
+func expectPushed(t *testing.T, c redis.PubSubConn, message string, expected interface{}) {
+ actual := c.Receive()
+ if !reflect.DeepEqual(actual, expected) {
+ t.Errorf("%s = %v, want %v", message, actual, expected)
+ }
+}
+
+func TestPushed(t *testing.T) {
+ pc, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer pc.Close()
+
+ nc, err := net.Dial("tcp", ":6379")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer nc.Close()
+ nc.SetReadDeadline(time.Now().Add(4 * time.Second))
+
+ c := redis.PubSubConn{Conn: redis.NewConn(nc, 0, 0)}
+
+ c.Subscribe("c1")
+ expectPushed(t, c, "Subscribe(c1)", redis.Subscription{Kind: "subscribe", Channel: "c1", Count: 1})
+ c.Subscribe("c2")
+ expectPushed(t, c, "Subscribe(c2)", redis.Subscription{Kind: "subscribe", Channel: "c2", Count: 2})
+ c.PSubscribe("p1")
+ expectPushed(t, c, "PSubscribe(p1)", redis.Subscription{Kind: "psubscribe", Channel: "p1", Count: 3})
+ c.PSubscribe("p2")
+ expectPushed(t, c, "PSubscribe(p2)", redis.Subscription{Kind: "psubscribe", Channel: "p2", Count: 4})
+ c.PUnsubscribe()
+ expectPushed(t, c, "Punsubscribe(p1)", redis.Subscription{Kind: "punsubscribe", Channel: "p1", Count: 3})
+ expectPushed(t, c, "Punsubscribe()", redis.Subscription{Kind: "punsubscribe", Channel: "p2", Count: 2})
+
+ pc.Do("PUBLISH", "c1", "hello")
+ expectPushed(t, c, "PUBLISH c1 hello", redis.Message{Channel: "c1", Data: []byte("hello")})
+
+ c.Ping("hello")
+ expectPushed(t, c, `Ping("hello")`, redis.Pong{"hello"})
+
+ c.Conn.Send("PING")
+ c.Conn.Flush()
+ expectPushed(t, c, `Send("PING")`, redis.Pong{})
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go
new file mode 100644
index 000000000..c90a48ed4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go
@@ -0,0 +1,44 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+// Error represents an error returned in a command reply.
+type Error string
+
+func (err Error) Error() string { return string(err) }
+
+// Conn represents a connection to a Redis server.
+type Conn interface {
+ // Close closes the connection.
+ Close() error
+
+ // Err returns a non-nil value if the connection is broken. The returned
+ // value is either the first non-nil value returned from the underlying
+ // network connection or a protocol parsing error. Applications should
+ // close broken connections.
+ Err() error
+
+ // Do sends a command to the server and returns the received reply.
+ Do(commandName string, args ...interface{}) (reply interface{}, err error)
+
+ // Send writes the command to the client's output buffer.
+ Send(commandName string, args ...interface{}) error
+
+ // Flush flushes the output buffer to the Redis server.
+ Flush() error
+
+ // Receive receives a single reply from the Redis server
+ Receive() (reply interface{}, err error)
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go
new file mode 100644
index 000000000..5af29bf51
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go
@@ -0,0 +1,364 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "errors"
+ "fmt"
+ "strconv"
+)
+
+// ErrNil indicates that a reply value is nil.
+var ErrNil = errors.New("redigo: nil returned")
+
+// Int is a helper that converts a command reply to an integer. If err is not
+// equal to nil, then Int returns 0, err. Otherwise, Int converts the
+// reply to an int as follows:
+//
+// Reply type Result
+// integer int(reply), nil
+// bulk string parsed reply, nil
+// nil 0, ErrNil
+// other 0, error
+func Int(reply interface{}, err error) (int, error) {
+ if err != nil {
+ return 0, err
+ }
+ switch reply := reply.(type) {
+ case int64:
+ x := int(reply)
+ if int64(x) != reply {
+ return 0, strconv.ErrRange
+ }
+ return x, nil
+ case []byte:
+ n, err := strconv.ParseInt(string(reply), 10, 0)
+ return int(n), err
+ case nil:
+ return 0, ErrNil
+ case Error:
+ return 0, reply
+ }
+ return 0, fmt.Errorf("redigo: unexpected type for Int, got type %T", reply)
+}
+
+// Int64 is a helper that converts a command reply to 64 bit integer. If err is
+// not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the
+// reply to an int64 as follows:
+//
+// Reply type Result
+// integer reply, nil
+// bulk string parsed reply, nil
+// nil 0, ErrNil
+// other 0, error
+func Int64(reply interface{}, err error) (int64, error) {
+ if err != nil {
+ return 0, err
+ }
+ switch reply := reply.(type) {
+ case int64:
+ return reply, nil
+ case []byte:
+ n, err := strconv.ParseInt(string(reply), 10, 64)
+ return n, err
+ case nil:
+ return 0, ErrNil
+ case Error:
+ return 0, reply
+ }
+ return 0, fmt.Errorf("redigo: unexpected type for Int64, got type %T", reply)
+}
+
+var errNegativeInt = errors.New("redigo: unexpected value for Uint64")
+
+// Uint64 is a helper that converts a command reply to 64 bit integer. If err is
+// not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the
+// reply to an int64 as follows:
+//
+// Reply type Result
+// integer reply, nil
+// bulk string parsed reply, nil
+// nil 0, ErrNil
+// other 0, error
+func Uint64(reply interface{}, err error) (uint64, error) {
+ if err != nil {
+ return 0, err
+ }
+ switch reply := reply.(type) {
+ case int64:
+ if reply < 0 {
+ return 0, errNegativeInt
+ }
+ return uint64(reply), nil
+ case []byte:
+ n, err := strconv.ParseUint(string(reply), 10, 64)
+ return n, err
+ case nil:
+ return 0, ErrNil
+ case Error:
+ return 0, reply
+ }
+ return 0, fmt.Errorf("redigo: unexpected type for Uint64, got type %T", reply)
+}
+
+// Float64 is a helper that converts a command reply to 64 bit float. If err is
+// not equal to nil, then Float64 returns 0, err. Otherwise, Float64 converts
+// the reply to an int as follows:
+//
+// Reply type Result
+// bulk string parsed reply, nil
+// nil 0, ErrNil
+// other 0, error
+func Float64(reply interface{}, err error) (float64, error) {
+ if err != nil {
+ return 0, err
+ }
+ switch reply := reply.(type) {
+ case []byte:
+ n, err := strconv.ParseFloat(string(reply), 64)
+ return n, err
+ case nil:
+ return 0, ErrNil
+ case Error:
+ return 0, reply
+ }
+ return 0, fmt.Errorf("redigo: unexpected type for Float64, got type %T", reply)
+}
+
+// String is a helper that converts a command reply to a string. If err is not
+// equal to nil, then String returns "", err. Otherwise String converts the
+// reply to a string as follows:
+//
+// Reply type Result
+// bulk string string(reply), nil
+// simple string reply, nil
+// nil "", ErrNil
+// other "", error
+func String(reply interface{}, err error) (string, error) {
+ if err != nil {
+ return "", err
+ }
+ switch reply := reply.(type) {
+ case []byte:
+ return string(reply), nil
+ case string:
+ return reply, nil
+ case nil:
+ return "", ErrNil
+ case Error:
+ return "", reply
+ }
+ return "", fmt.Errorf("redigo: unexpected type for String, got type %T", reply)
+}
+
+// Bytes is a helper that converts a command reply to a slice of bytes. If err
+// is not equal to nil, then Bytes returns nil, err. Otherwise Bytes converts
+// the reply to a slice of bytes as follows:
+//
+// Reply type Result
+// bulk string reply, nil
+// simple string []byte(reply), nil
+// nil nil, ErrNil
+// other nil, error
+func Bytes(reply interface{}, err error) ([]byte, error) {
+ if err != nil {
+ return nil, err
+ }
+ switch reply := reply.(type) {
+ case []byte:
+ return reply, nil
+ case string:
+ return []byte(reply), nil
+ case nil:
+ return nil, ErrNil
+ case Error:
+ return nil, reply
+ }
+ return nil, fmt.Errorf("redigo: unexpected type for Bytes, got type %T", reply)
+}
+
+// Bool is a helper that converts a command reply to a boolean. If err is not
+// equal to nil, then Bool returns false, err. Otherwise Bool converts the
+// reply to boolean as follows:
+//
+// Reply type Result
+// integer value != 0, nil
+// bulk string strconv.ParseBool(reply)
+// nil false, ErrNil
+// other false, error
+func Bool(reply interface{}, err error) (bool, error) {
+ if err != nil {
+ return false, err
+ }
+ switch reply := reply.(type) {
+ case int64:
+ return reply != 0, nil
+ case []byte:
+ return strconv.ParseBool(string(reply))
+ case nil:
+ return false, ErrNil
+ case Error:
+ return false, reply
+ }
+ return false, fmt.Errorf("redigo: unexpected type for Bool, got type %T", reply)
+}
+
+// MultiBulk is deprecated. Use Values.
+func MultiBulk(reply interface{}, err error) ([]interface{}, error) { return Values(reply, err) }
+
+// Values is a helper that converts an array command reply to a []interface{}.
+// If err is not equal to nil, then Values returns nil, err. Otherwise, Values
+// converts the reply as follows:
+//
+// Reply type Result
+// array reply, nil
+// nil nil, ErrNil
+// other nil, error
+func Values(reply interface{}, err error) ([]interface{}, error) {
+ if err != nil {
+ return nil, err
+ }
+ switch reply := reply.(type) {
+ case []interface{}:
+ return reply, nil
+ case nil:
+ return nil, ErrNil
+ case Error:
+ return nil, reply
+ }
+ return nil, fmt.Errorf("redigo: unexpected type for Values, got type %T", reply)
+}
+
+// Strings is a helper that converts an array command reply to a []string. If
+// err is not equal to nil, then Strings returns nil, err. Nil array items are
+// converted to "" in the output slice. Strings returns an error if an array
+// item is not a bulk string or nil.
+func Strings(reply interface{}, err error) ([]string, error) {
+ if err != nil {
+ return nil, err
+ }
+ switch reply := reply.(type) {
+ case []interface{}:
+ result := make([]string, len(reply))
+ for i := range reply {
+ if reply[i] == nil {
+ continue
+ }
+ p, ok := reply[i].([]byte)
+ if !ok {
+ return nil, fmt.Errorf("redigo: unexpected element type for Strings, got type %T", reply[i])
+ }
+ result[i] = string(p)
+ }
+ return result, nil
+ case nil:
+ return nil, ErrNil
+ case Error:
+ return nil, reply
+ }
+ return nil, fmt.Errorf("redigo: unexpected type for Strings, got type %T", reply)
+}
+
+// Ints is a helper that converts an array command reply to a []int. If
+// err is not equal to nil, then Ints returns nil, err.
+func Ints(reply interface{}, err error) ([]int, error) {
+ var ints []int
+ if reply == nil {
+ return ints, ErrNil
+ }
+ values, err := Values(reply, err)
+ if err != nil {
+ return ints, err
+ }
+ if err := ScanSlice(values, &ints); err != nil {
+ return ints, err
+ }
+ return ints, nil
+}
+
+// StringMap is a helper that converts an array of strings (alternating key, value)
+// into a map[string]string. The HGETALL and CONFIG GET commands return replies in this format.
+// Requires an even number of values in result.
+func StringMap(result interface{}, err error) (map[string]string, error) {
+ values, err := Values(result, err)
+ if err != nil {
+ return nil, err
+ }
+ if len(values)%2 != 0 {
+ return nil, errors.New("redigo: StringMap expects even number of values result")
+ }
+ m := make(map[string]string, len(values)/2)
+ for i := 0; i < len(values); i += 2 {
+ 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")
+ }
+ m[string(key)] = string(value)
+ }
+ return m, nil
+}
+
+// IntMap is a helper that converts an array of strings (alternating key, value)
+// into a map[string]int. The HGETALL commands return replies in this format.
+// Requires an even number of values in result.
+func IntMap(result interface{}, err error) (map[string]int, error) {
+ values, err := Values(result, err)
+ if err != nil {
+ return nil, err
+ }
+ if len(values)%2 != 0 {
+ return nil, errors.New("redigo: IntMap expects even number of values result")
+ }
+ m := make(map[string]int, len(values)/2)
+ 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")
+ }
+ value, err := Int(values[i+1], nil)
+ if err != nil {
+ return nil, err
+ }
+ m[string(key)] = value
+ }
+ return m, nil
+}
+
+// Int64Map is a helper that converts an array of strings (alternating key, value)
+// into a map[string]int64. The HGETALL commands return replies in this format.
+// Requires an even number of values in result.
+func Int64Map(result interface{}, err error) (map[string]int64, error) {
+ values, err := Values(result, err)
+ if err != nil {
+ return nil, err
+ }
+ if len(values)%2 != 0 {
+ return nil, errors.New("redigo: Int64Map expects even number of values result")
+ }
+ m := make(map[string]int64, len(values)/2)
+ 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")
+ }
+ value, err := Int64(values[i+1], nil)
+ if err != nil {
+ return nil, err
+ }
+ m[string(key)] = value
+ }
+ return m, nil
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply_test.go
new file mode 100644
index 000000000..92744c590
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply_test.go
@@ -0,0 +1,166 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "fmt"
+ "reflect"
+ "testing"
+
+ "github.com/garyburd/redigo/internal/redistest"
+ "github.com/garyburd/redigo/redis"
+)
+
+type valueError struct {
+ v interface{}
+ err error
+}
+
+func ve(v interface{}, err error) valueError {
+ return valueError{v, err}
+}
+
+var replyTests = []struct {
+ name interface{}
+ actual valueError
+ expected valueError
+}{
+ {
+ "ints([v1, v2])",
+ ve(redis.Ints([]interface{}{[]byte("4"), []byte("5")}, nil)),
+ ve([]int{4, 5}, nil),
+ },
+ {
+ "ints(nil)",
+ ve(redis.Ints(nil, nil)),
+ ve([]int(nil), redis.ErrNil),
+ },
+ {
+ "strings([v1, v2])",
+ ve(redis.Strings([]interface{}{[]byte("v1"), []byte("v2")}, nil)),
+ ve([]string{"v1", "v2"}, nil),
+ },
+ {
+ "strings(nil)",
+ ve(redis.Strings(nil, nil)),
+ ve([]string(nil), redis.ErrNil),
+ },
+ {
+ "values([v1, v2])",
+ ve(redis.Values([]interface{}{[]byte("v1"), []byte("v2")}, nil)),
+ ve([]interface{}{[]byte("v1"), []byte("v2")}, nil),
+ },
+ {
+ "values(nil)",
+ ve(redis.Values(nil, nil)),
+ ve([]interface{}(nil), redis.ErrNil),
+ },
+ {
+ "float64(1.0)",
+ ve(redis.Float64([]byte("1.0"), nil)),
+ ve(float64(1.0), nil),
+ },
+ {
+ "float64(nil)",
+ ve(redis.Float64(nil, nil)),
+ ve(float64(0.0), redis.ErrNil),
+ },
+ {
+ "uint64(1)",
+ ve(redis.Uint64(int64(1), nil)),
+ ve(uint64(1), nil),
+ },
+ {
+ "uint64(-1)",
+ ve(redis.Uint64(int64(-1), nil)),
+ ve(uint64(0), redis.ErrNegativeInt),
+ },
+}
+
+func TestReply(t *testing.T) {
+ for _, rt := range replyTests {
+ if rt.actual.err != rt.expected.err {
+ t.Errorf("%s returned err %v, want %v", rt.name, rt.actual.err, rt.expected.err)
+ continue
+ }
+ if !reflect.DeepEqual(rt.actual.v, rt.expected.v) {
+ t.Errorf("%s=%+v, want %+v", rt.name, rt.actual.v, rt.expected.v)
+ }
+ }
+}
+
+// dial wraps DialTestDB() with a more suitable function name for examples.
+func dial() (redis.Conn, error) {
+ return redistest.Dial()
+}
+
+func ExampleBool() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ c.Do("SET", "foo", 1)
+ exists, _ := redis.Bool(c.Do("EXISTS", "foo"))
+ fmt.Printf("%#v\n", exists)
+ // Output:
+ // true
+}
+
+func ExampleInt() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ c.Do("SET", "k1", 1)
+ n, _ := redis.Int(c.Do("GET", "k1"))
+ fmt.Printf("%#v\n", n)
+ n, _ = redis.Int(c.Do("INCR", "k1"))
+ fmt.Printf("%#v\n", n)
+ // Output:
+ // 1
+ // 2
+}
+
+func ExampleInts() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ c.Do("SADD", "set_with_integers", 4, 5, 6)
+ ints, _ := redis.Ints(c.Do("SMEMBERS", "set_with_integers"))
+ fmt.Printf("%#v\n", ints)
+ // Output:
+ // []int{4, 5, 6}
+}
+
+func ExampleString() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ c.Do("SET", "hello", "world")
+ s, err := redis.String(c.Do("GET", "hello"))
+ fmt.Printf("%#v\n", s)
+ // Output:
+ // "world"
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go
new file mode 100644
index 000000000..8c9cfa18d
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go
@@ -0,0 +1,513 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "strconv"
+ "strings"
+ "sync"
+)
+
+func ensureLen(d reflect.Value, n int) {
+ if n > d.Cap() {
+ d.Set(reflect.MakeSlice(d.Type(), n, n))
+ } else {
+ d.SetLen(n)
+ }
+}
+
+func cannotConvert(d reflect.Value, s interface{}) error {
+ return fmt.Errorf("redigo: Scan cannot convert from %s to %s",
+ reflect.TypeOf(s), d.Type())
+}
+
+func convertAssignBytes(d reflect.Value, s []byte) (err error) {
+ switch d.Type().Kind() {
+ case reflect.Float32, reflect.Float64:
+ var x float64
+ x, err = strconv.ParseFloat(string(s), d.Type().Bits())
+ d.SetFloat(x)
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ var x int64
+ x, err = strconv.ParseInt(string(s), 10, d.Type().Bits())
+ d.SetInt(x)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ var x uint64
+ x, err = strconv.ParseUint(string(s), 10, d.Type().Bits())
+ d.SetUint(x)
+ case reflect.Bool:
+ var x bool
+ x, err = strconv.ParseBool(string(s))
+ d.SetBool(x)
+ case reflect.String:
+ d.SetString(string(s))
+ case reflect.Slice:
+ if d.Type().Elem().Kind() != reflect.Uint8 {
+ err = cannotConvert(d, s)
+ } else {
+ d.SetBytes(s)
+ }
+ default:
+ err = cannotConvert(d, s)
+ }
+ return
+}
+
+func convertAssignInt(d reflect.Value, s int64) (err error) {
+ switch d.Type().Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ d.SetInt(s)
+ if d.Int() != s {
+ err = strconv.ErrRange
+ d.SetInt(0)
+ }
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ if s < 0 {
+ err = strconv.ErrRange
+ } else {
+ x := uint64(s)
+ d.SetUint(x)
+ if d.Uint() != x {
+ err = strconv.ErrRange
+ d.SetUint(0)
+ }
+ }
+ case reflect.Bool:
+ d.SetBool(s != 0)
+ default:
+ err = cannotConvert(d, s)
+ }
+ return
+}
+
+func convertAssignValue(d reflect.Value, s interface{}) (err error) {
+ switch s := s.(type) {
+ case []byte:
+ err = convertAssignBytes(d, s)
+ case int64:
+ err = convertAssignInt(d, s)
+ default:
+ err = cannotConvert(d, s)
+ }
+ return err
+}
+
+func convertAssignValues(d reflect.Value, s []interface{}) error {
+ if d.Type().Kind() != reflect.Slice {
+ return cannotConvert(d, s)
+ }
+ ensureLen(d, len(s))
+ for i := 0; i < len(s); i++ {
+ if err := convertAssignValue(d.Index(i), s[i]); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func convertAssign(d interface{}, s interface{}) (err error) {
+ // 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
+ case []byte:
+ switch d := d.(type) {
+ case *string:
+ *d = string(s)
+ case *int:
+ *d, err = strconv.Atoi(string(s))
+ case *bool:
+ *d, err = strconv.ParseBool(string(s))
+ case *[]byte:
+ *d = s
+ case *interface{}:
+ *d = s
+ case nil:
+ // skip value
+ default:
+ if d := reflect.ValueOf(d); d.Type().Kind() != reflect.Ptr {
+ err = cannotConvert(d, s)
+ } else {
+ err = convertAssignBytes(d.Elem(), s)
+ }
+ }
+ case int64:
+ switch d := d.(type) {
+ case *int:
+ x := int(s)
+ if int64(x) != s {
+ err = strconv.ErrRange
+ x = 0
+ }
+ *d = x
+ case *bool:
+ *d = s != 0
+ case *interface{}:
+ *d = s
+ case nil:
+ // skip value
+ default:
+ if d := reflect.ValueOf(d); d.Type().Kind() != reflect.Ptr {
+ err = cannotConvert(d, s)
+ } else {
+ err = convertAssignInt(d.Elem(), s)
+ }
+ }
+ case []interface{}:
+ switch d := d.(type) {
+ case *[]interface{}:
+ *d = s
+ case *interface{}:
+ *d = s
+ case nil:
+ // skip value
+ default:
+ if d := reflect.ValueOf(d); d.Type().Kind() != reflect.Ptr {
+ err = cannotConvert(d, s)
+ } else {
+ err = convertAssignValues(d.Elem(), s)
+ }
+ }
+ case Error:
+ err = s
+ default:
+ err = cannotConvert(reflect.ValueOf(d), s)
+ }
+ return
+}
+
+// Scan copies from src to the values pointed at by dest.
+//
+// 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.
+//
+// If a dest value is nil, then the corresponding src value is skipped.
+//
+// If a src element is nil, then the corresponding dest value is not modified.
+//
+// To enable easy use of Scan in a loop, Scan returns the slice of src
+// following the copied values.
+func Scan(src []interface{}, dest ...interface{}) ([]interface{}, error) {
+ if len(src) < len(dest) {
+ return nil, errors.New("redigo: Scan array short")
+ }
+ var err error
+ for i, d := range dest {
+ err = convertAssign(d, src[i])
+ if err != nil {
+ break
+ }
+ }
+ return src[len(dest):], err
+}
+
+type fieldSpec struct {
+ name string
+ index []int
+ //omitEmpty bool
+}
+
+type structSpec struct {
+ m map[string]*fieldSpec
+ l []*fieldSpec
+}
+
+func (ss *structSpec) fieldSpec(name []byte) *fieldSpec {
+ return ss.m[string(name)]
+}
+
+func compileStructSpec(t reflect.Type, depth map[string]int, index []int, ss *structSpec) {
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ switch {
+ case f.PkgPath != "":
+ // Ignore unexported fields.
+ case f.Anonymous:
+ // TODO: Handle pointers. Requires change to decoder and
+ // protection against infinite recursion.
+ if f.Type.Kind() == reflect.Struct {
+ compileStructSpec(f.Type, depth, append(index, i), ss)
+ }
+ default:
+ fs := &fieldSpec{name: f.Name}
+ tag := f.Tag.Get("redis")
+ p := strings.Split(tag, ",")
+ if len(p) > 0 {
+ if p[0] == "-" {
+ continue
+ }
+ if len(p[0]) > 0 {
+ fs.name = p[0]
+ }
+ for _, s := range p[1:] {
+ switch s {
+ //case "omitempty":
+ // fs.omitempty = true
+ default:
+ panic(errors.New("redigo: unknown field flag " + s + " for type " + t.Name()))
+ }
+ }
+ }
+ d, found := depth[fs.name]
+ if !found {
+ d = 1 << 30
+ }
+ switch {
+ case len(index) == d:
+ // At same depth, remove from result.
+ delete(ss.m, fs.name)
+ j := 0
+ for i := 0; i < len(ss.l); i++ {
+ if fs.name != ss.l[i].name {
+ ss.l[j] = ss.l[i]
+ j += 1
+ }
+ }
+ ss.l = ss.l[:j]
+ case len(index) < d:
+ fs.index = make([]int, len(index)+1)
+ copy(fs.index, index)
+ fs.index[len(index)] = i
+ depth[fs.name] = len(index)
+ ss.m[fs.name] = fs
+ ss.l = append(ss.l, fs)
+ }
+ }
+ }
+}
+
+var (
+ structSpecMutex sync.RWMutex
+ structSpecCache = make(map[reflect.Type]*structSpec)
+ defaultFieldSpec = &fieldSpec{}
+)
+
+func structSpecForType(t reflect.Type) *structSpec {
+
+ structSpecMutex.RLock()
+ ss, found := structSpecCache[t]
+ structSpecMutex.RUnlock()
+ if found {
+ return ss
+ }
+
+ structSpecMutex.Lock()
+ defer structSpecMutex.Unlock()
+ ss, found = structSpecCache[t]
+ if found {
+ return ss
+ }
+
+ ss = &structSpec{m: make(map[string]*fieldSpec)}
+ compileStructSpec(t, make(map[string]int), nil, ss)
+ structSpecCache[t] = ss
+ return ss
+}
+
+var errScanStructValue = errors.New("redigo: ScanStruct value must be non-nil pointer to a struct")
+
+// ScanStruct scans alternating names and values from src to a struct. The
+// HGETALL and CONFIG GET commands return replies in this format.
+//
+// ScanStruct uses exported field names to match values in the response. Use
+// 'redis' field tag to override the name:
+//
+// Field int `redis:"myName"`
+//
+// Fields with the tag redis:"-" are ignored.
+//
+// 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.
+//
+// If a src element is nil, then the corresponding field is not modified.
+func ScanStruct(src []interface{}, dest interface{}) error {
+ d := reflect.ValueOf(dest)
+ if d.Kind() != reflect.Ptr || d.IsNil() {
+ return errScanStructValue
+ }
+ d = d.Elem()
+ if d.Kind() != reflect.Struct {
+ return errScanStructValue
+ }
+ ss := structSpecForType(d.Type())
+
+ if len(src)%2 != 0 {
+ return errors.New("redigo: ScanStruct expects even number of values in values")
+ }
+
+ for i := 0; i < len(src); i += 2 {
+ s := src[i+1]
+ if s == nil {
+ continue
+ }
+ name, ok := src[i].([]byte)
+ if !ok {
+ return errors.New("redigo: ScanStruct key not a bulk string value")
+ }
+ fs := ss.fieldSpec(name)
+ if fs == nil {
+ continue
+ }
+ if err := convertAssignValue(d.FieldByIndex(fs.index), s); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+var (
+ errScanSliceValue = errors.New("redigo: ScanSlice dest must be non-nil pointer to a struct")
+)
+
+// ScanSlice scans src to the slice pointed to by dest. The elements the dest
+// slice must be integer, float, boolean, string, struct or pointer to struct
+// values.
+//
+// Struct fields must be integer, float, boolean or string values. All struct
+// fields are used unless a subset is specified using fieldNames.
+func ScanSlice(src []interface{}, dest interface{}, fieldNames ...string) error {
+ d := reflect.ValueOf(dest)
+ if d.Kind() != reflect.Ptr || d.IsNil() {
+ return errScanSliceValue
+ }
+ d = d.Elem()
+ if d.Kind() != reflect.Slice {
+ return errScanSliceValue
+ }
+
+ isPtr := false
+ t := d.Type().Elem()
+ if t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct {
+ isPtr = true
+ t = t.Elem()
+ }
+
+ if t.Kind() != reflect.Struct {
+ ensureLen(d, len(src))
+ for i, s := range src {
+ if s == nil {
+ continue
+ }
+ if err := convertAssignValue(d.Index(i), s); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
+
+ ss := structSpecForType(t)
+ fss := ss.l
+ if len(fieldNames) > 0 {
+ fss = make([]*fieldSpec, len(fieldNames))
+ for i, name := range fieldNames {
+ fss[i] = ss.m[name]
+ if fss[i] == nil {
+ return errors.New("redigo: ScanSlice bad field name " + name)
+ }
+ }
+ }
+
+ if len(fss) == 0 {
+ return errors.New("redigo: ScanSlice no struct fields")
+ }
+
+ n := len(src) / len(fss)
+ if n*len(fss) != len(src) {
+ return errors.New("redigo: ScanSlice length not a multiple of struct field count")
+ }
+
+ ensureLen(d, n)
+ for i := 0; i < n; i++ {
+ d := d.Index(i)
+ if isPtr {
+ if d.IsNil() {
+ d.Set(reflect.New(t))
+ }
+ d = d.Elem()
+ }
+ for j, fs := range fss {
+ s := src[i*len(fss)+j]
+ if s == nil {
+ continue
+ }
+ if err := convertAssignValue(d.FieldByIndex(fs.index), s); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+// Args is a helper for constructing command arguments from structured values.
+type Args []interface{}
+
+// Add returns the result of appending value to args.
+func (args Args) Add(value ...interface{}) Args {
+ return append(args, value...)
+}
+
+// AddFlat returns the result of appending the flattened value of v to args.
+//
+// Maps are flattened by appending the alternating keys and map values to args.
+//
+// Slices are flattened by appending the slice elements to args.
+//
+// Structs are flattened by appending the alternating names and values of
+// exported fields to args. If v is a nil struct pointer, then nothing is
+// appended. The 'redis' field tag overrides struct field names. See ScanStruct
+// for more information on the use of the 'redis' field tag.
+//
+// Other types are appended to args as is.
+func (args Args) AddFlat(v interface{}) Args {
+ rv := reflect.ValueOf(v)
+ switch rv.Kind() {
+ case reflect.Struct:
+ args = flattenStruct(args, rv)
+ case reflect.Slice:
+ for i := 0; i < rv.Len(); i++ {
+ args = append(args, rv.Index(i).Interface())
+ }
+ case reflect.Map:
+ for _, k := range rv.MapKeys() {
+ args = append(args, k.Interface(), rv.MapIndex(k).Interface())
+ }
+ case reflect.Ptr:
+ if rv.Type().Elem().Kind() == reflect.Struct {
+ if !rv.IsNil() {
+ args = flattenStruct(args, rv.Elem())
+ }
+ } else {
+ args = append(args, v)
+ }
+ default:
+ args = append(args, v)
+ }
+ return args
+}
+
+func flattenStruct(args Args, v reflect.Value) Args {
+ ss := structSpecForType(v.Type())
+ for _, fs := range ss.l {
+ fv := v.FieldByIndex(fs.index)
+ args = append(args, fs.name, fv.Interface())
+ }
+ return args
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan_test.go
new file mode 100644
index 000000000..b57dd8969
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan_test.go
@@ -0,0 +1,412 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "fmt"
+ "github.com/garyburd/redigo/redis"
+ "math"
+ "reflect"
+ "testing"
+)
+
+var scanConversionTests = []struct {
+ src interface{}
+ dest interface{}
+}{
+ {[]byte("-inf"), math.Inf(-1)},
+ {[]byte("+inf"), math.Inf(1)},
+ {[]byte("0"), float64(0)},
+ {[]byte("3.14159"), float64(3.14159)},
+ {[]byte("3.14"), float32(3.14)},
+ {[]byte("-100"), int(-100)},
+ {[]byte("101"), int(101)},
+ {int64(102), int(102)},
+ {[]byte("103"), uint(103)},
+ {int64(104), uint(104)},
+ {[]byte("105"), int8(105)},
+ {int64(106), int8(106)},
+ {[]byte("107"), uint8(107)},
+ {int64(108), uint8(108)},
+ {[]byte("0"), false},
+ {int64(0), false},
+ {[]byte("f"), false},
+ {[]byte("1"), true},
+ {int64(1), true},
+ {[]byte("t"), true},
+ {[]byte("hello"), "hello"},
+ {[]byte("world"), []byte("world")},
+ {[]interface{}{[]byte("foo")}, []interface{}{[]byte("foo")}},
+ {[]interface{}{[]byte("foo")}, []string{"foo"}},
+ {[]interface{}{[]byte("hello"), []byte("world")}, []string{"hello", "world"}},
+ {[]interface{}{[]byte("bar")}, [][]byte{[]byte("bar")}},
+ {[]interface{}{[]byte("1")}, []int{1}},
+ {[]interface{}{[]byte("1"), []byte("2")}, []int{1, 2}},
+ {[]interface{}{[]byte("1"), []byte("2")}, []float64{1, 2}},
+ {[]interface{}{[]byte("1")}, []byte{1}},
+ {[]interface{}{[]byte("1")}, []bool{true}},
+}
+
+func TestScanConversion(t *testing.T) {
+ for _, tt := range scanConversionTests {
+ values := []interface{}{tt.src}
+ dest := reflect.New(reflect.TypeOf(tt.dest))
+ values, err := redis.Scan(values, dest.Interface())
+ if err != nil {
+ t.Errorf("Scan(%v) returned error %v", tt, err)
+ continue
+ }
+ if !reflect.DeepEqual(tt.dest, dest.Elem().Interface()) {
+ t.Errorf("Scan(%v) returned %v, want %v", tt, dest.Elem().Interface(), tt.dest)
+ }
+ }
+}
+
+var scanConversionErrorTests = []struct {
+ src interface{}
+ dest interface{}
+}{
+ {[]byte("1234"), byte(0)},
+ {int64(1234), byte(0)},
+ {[]byte("-1"), byte(0)},
+ {int64(-1), byte(0)},
+ {[]byte("junk"), false},
+ {redis.Error("blah"), false},
+}
+
+func TestScanConversionError(t *testing.T) {
+ for _, tt := range scanConversionErrorTests {
+ values := []interface{}{tt.src}
+ dest := reflect.New(reflect.TypeOf(tt.dest))
+ values, err := redis.Scan(values, dest.Interface())
+ if err == nil {
+ t.Errorf("Scan(%v) did not return error", tt)
+ }
+ }
+}
+
+func ExampleScan() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ c.Send("HMSET", "album:1", "title", "Red", "rating", 5)
+ c.Send("HMSET", "album:2", "title", "Earthbound", "rating", 1)
+ c.Send("HMSET", "album:3", "title", "Beat")
+ c.Send("LPUSH", "albums", "1")
+ c.Send("LPUSH", "albums", "2")
+ c.Send("LPUSH", "albums", "3")
+ values, err := redis.Values(c.Do("SORT", "albums",
+ "BY", "album:*->rating",
+ "GET", "album:*->title",
+ "GET", "album:*->rating"))
+ if err != nil {
+ panic(err)
+ }
+
+ for len(values) > 0 {
+ var title string
+ rating := -1 // initialize to illegal value to detect nil.
+ values, err = redis.Scan(values, &title, &rating)
+ if err != nil {
+ panic(err)
+ }
+ if rating == -1 {
+ fmt.Println(title, "not-rated")
+ } else {
+ fmt.Println(title, rating)
+ }
+ }
+ // Output:
+ // Beat not-rated
+ // Earthbound 1
+ // Red 5
+}
+
+type s0 struct {
+ X int
+ Y int `redis:"y"`
+ Bt bool
+}
+
+type s1 struct {
+ X int `redis:"-"`
+ I int `redis:"i"`
+ U uint `redis:"u"`
+ S string `redis:"s"`
+ P []byte `redis:"p"`
+ B bool `redis:"b"`
+ Bt bool
+ Bf bool
+ s0
+}
+
+var scanStructTests = []struct {
+ title string
+ reply []string
+ 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}},
+ },
+}
+
+func TestScanStruct(t *testing.T) {
+ for _, tt := range scanStructTests {
+
+ var reply []interface{}
+ for _, v := range tt.reply {
+ reply = append(reply, []byte(v))
+ }
+
+ value := reflect.New(reflect.ValueOf(tt.value).Type().Elem())
+
+ if err := redis.ScanStruct(reply, value.Interface()); err != nil {
+ t.Fatalf("ScanStruct(%s) returned error %v", tt.title, err)
+ }
+
+ if !reflect.DeepEqual(value.Interface(), tt.value) {
+ t.Fatalf("ScanStruct(%s) returned %v, want %v", tt.title, value.Interface(), tt.value)
+ }
+ }
+}
+
+func TestBadScanStructArgs(t *testing.T) {
+ x := []interface{}{"A", "b"}
+ test := func(v interface{}) {
+ if err := redis.ScanStruct(x, v); err == nil {
+ t.Errorf("Expect error for ScanStruct(%T, %T)", x, v)
+ }
+ }
+
+ test(nil)
+
+ var v0 *struct{}
+ test(v0)
+
+ var v1 int
+ test(&v1)
+
+ x = x[:1]
+ v2 := struct{ A string }{}
+ test(&v2)
+}
+
+var scanSliceTests = []struct {
+ src []interface{}
+ fieldNames []string
+ ok bool
+ dest interface{}
+}{
+ {
+ []interface{}{[]byte("1"), nil, []byte("-1")},
+ nil,
+ true,
+ []int{1, 0, -1},
+ },
+ {
+ []interface{}{[]byte("1"), nil, []byte("2")},
+ nil,
+ true,
+ []uint{1, 0, 2},
+ },
+ {
+ []interface{}{[]byte("-1")},
+ nil,
+ false,
+ []uint{1},
+ },
+ {
+ []interface{}{[]byte("hello"), nil, []byte("world")},
+ nil,
+ true,
+ [][]byte{[]byte("hello"), nil, []byte("world")},
+ },
+ {
+ []interface{}{[]byte("hello"), nil, []byte("world")},
+ nil,
+ true,
+ []string{"hello", "", "world"},
+ },
+ {
+ []interface{}{[]byte("a1"), []byte("b1"), []byte("a2"), []byte("b2")},
+ nil,
+ true,
+ []struct{ A, B string }{{"a1", "b1"}, {"a2", "b2"}},
+ },
+ {
+ []interface{}{[]byte("a1"), []byte("b1")},
+ nil,
+ false,
+ []struct{ A, B, C string }{{"a1", "b1", ""}},
+ },
+ {
+ []interface{}{[]byte("a1"), []byte("b1"), []byte("a2"), []byte("b2")},
+ nil,
+ true,
+ []*struct{ A, B string }{{"a1", "b1"}, {"a2", "b2"}},
+ },
+ {
+ []interface{}{[]byte("a1"), []byte("b1"), []byte("a2"), []byte("b2")},
+ []string{"A", "B"},
+ true,
+ []struct{ A, C, B string }{{"a1", "", "b1"}, {"a2", "", "b2"}},
+ },
+ {
+ []interface{}{[]byte("a1"), []byte("b1"), []byte("a2"), []byte("b2")},
+ nil,
+ false,
+ []struct{}{},
+ },
+}
+
+func TestScanSlice(t *testing.T) {
+ for _, tt := range scanSliceTests {
+
+ typ := reflect.ValueOf(tt.dest).Type()
+ dest := reflect.New(typ)
+
+ err := redis.ScanSlice(tt.src, dest.Interface(), tt.fieldNames...)
+ if tt.ok != (err == nil) {
+ t.Errorf("ScanSlice(%v, []%s, %v) returned error %v", tt.src, typ, tt.fieldNames, err)
+ continue
+ }
+ if tt.ok && !reflect.DeepEqual(dest.Elem().Interface(), tt.dest) {
+ t.Errorf("ScanSlice(src, []%s) returned %#v, want %#v", typ, dest.Elem().Interface(), tt.dest)
+ }
+ }
+}
+
+func ExampleScanSlice() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ c.Send("HMSET", "album:1", "title", "Red", "rating", 5)
+ c.Send("HMSET", "album:2", "title", "Earthbound", "rating", 1)
+ c.Send("HMSET", "album:3", "title", "Beat", "rating", 4)
+ c.Send("LPUSH", "albums", "1")
+ c.Send("LPUSH", "albums", "2")
+ c.Send("LPUSH", "albums", "3")
+ values, err := redis.Values(c.Do("SORT", "albums",
+ "BY", "album:*->rating",
+ "GET", "album:*->title",
+ "GET", "album:*->rating"))
+ if err != nil {
+ panic(err)
+ }
+
+ var albums []struct {
+ Title string
+ Rating int
+ }
+ if err := redis.ScanSlice(values, &albums); err != nil {
+ panic(err)
+ }
+ fmt.Printf("%v\n", albums)
+ // Output:
+ // [{Earthbound 1} {Beat 4} {Red 5}]
+}
+
+var argsTests = []struct {
+ title string
+ actual redis.Args
+ expected redis.Args
+}{
+ {"struct ptr",
+ redis.Args{}.AddFlat(&struct {
+ I int `redis:"i"`
+ U uint `redis:"u"`
+ S string `redis:"s"`
+ P []byte `redis:"p"`
+ Bt bool
+ Bf bool
+ }{
+ -1234, 5678, "hello", []byte("world"), true, false,
+ }),
+ redis.Args{"i", int(-1234), "u", uint(5678), "s", "hello", "p", []byte("world"), "Bt", true, "Bf", false},
+ },
+ {"struct",
+ redis.Args{}.AddFlat(struct{ I int }{123}),
+ redis.Args{"I", 123},
+ },
+ {"slice",
+ redis.Args{}.Add(1).AddFlat([]string{"a", "b", "c"}).Add(2),
+ redis.Args{1, "a", "b", "c", 2},
+ },
+}
+
+func TestArgs(t *testing.T) {
+ for _, tt := range argsTests {
+ if !reflect.DeepEqual(tt.actual, tt.expected) {
+ t.Fatalf("%s is %v, want %v", tt.title, tt.actual, tt.expected)
+ }
+ }
+}
+
+func ExampleArgs() {
+ c, err := dial()
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ var p1, p2 struct {
+ Title string `redis:"title"`
+ Author string `redis:"author"`
+ Body string `redis:"body"`
+ }
+
+ p1.Title = "Example"
+ p1.Author = "Gary"
+ p1.Body = "Hello"
+
+ if _, err := c.Do("HMSET", redis.Args{}.Add("id1").AddFlat(&p1)...); err != nil {
+ panic(err)
+ }
+
+ m := map[string]string{
+ "title": "Example2",
+ "author": "Steve",
+ "body": "Map",
+ }
+
+ if _, err := c.Do("HMSET", redis.Args{}.Add("id2").AddFlat(m)...); err != nil {
+ panic(err)
+ }
+
+ for _, id := range []string{"id1", "id2"} {
+
+ v, err := redis.Values(c.Do("HGETALL", id))
+ if err != nil {
+ panic(err)
+ }
+
+ if err := redis.ScanStruct(v, &p2); err != nil {
+ panic(err)
+ }
+
+ fmt.Printf("%+v\n", p2)
+ }
+
+ // Output:
+ // {Title:Example Author:Gary Body:Hello}
+ // {Title:Example2 Author:Steve Body:Map}
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go
new file mode 100644
index 000000000..78605a90a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go
@@ -0,0 +1,86 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "crypto/sha1"
+ "encoding/hex"
+ "io"
+ "strings"
+)
+
+// Script encapsulates the source, hash and key count for a Lua script. See
+// http://redis.io/commands/eval for information on scripts in Redis.
+type Script struct {
+ keyCount int
+ src string
+ hash string
+}
+
+// NewScript returns a new script object. If keyCount is greater than or equal
+// to zero, then the count is automatically inserted in the EVAL command
+// argument list. If keyCount is less than zero, then the application supplies
+// the count as the first value in the keysAndArgs argument to the Do, Send and
+// SendHash methods.
+func NewScript(keyCount int, src string) *Script {
+ h := sha1.New()
+ io.WriteString(h, src)
+ return &Script{keyCount, src, hex.EncodeToString(h.Sum(nil))}
+}
+
+func (s *Script) args(spec string, keysAndArgs []interface{}) []interface{} {
+ var args []interface{}
+ if s.keyCount < 0 {
+ args = make([]interface{}, 1+len(keysAndArgs))
+ args[0] = spec
+ copy(args[1:], keysAndArgs)
+ } else {
+ args = make([]interface{}, 2+len(keysAndArgs))
+ args[0] = spec
+ args[1] = s.keyCount
+ copy(args[2:], keysAndArgs)
+ }
+ return args
+}
+
+// Do evaluates the script. Under the covers, Do optimistically evaluates the
+// script using the EVALSHA command. If the command fails because the script is
+// not loaded, then Do evaluates the script using the EVAL command (thus
+// causing the script to load).
+func (s *Script) Do(c Conn, keysAndArgs ...interface{}) (interface{}, error) {
+ v, err := c.Do("EVALSHA", s.args(s.hash, keysAndArgs)...)
+ if e, ok := err.(Error); ok && strings.HasPrefix(string(e), "NOSCRIPT ") {
+ v, err = c.Do("EVAL", s.args(s.src, keysAndArgs)...)
+ }
+ return v, err
+}
+
+// SendHash evaluates the script without waiting for the reply. The script is
+// evaluated with the EVALSHA command. The application must ensure that the
+// script is loaded by a previous call to Send, Do or Load methods.
+func (s *Script) SendHash(c Conn, keysAndArgs ...interface{}) error {
+ return c.Send("EVALSHA", s.args(s.hash, keysAndArgs)...)
+}
+
+// Send evaluates the script without waiting for the reply.
+func (s *Script) Send(c Conn, keysAndArgs ...interface{}) error {
+ return c.Send("EVAL", s.args(s.src, keysAndArgs)...)
+}
+
+// Load loads the script without evaluating it.
+func (s *Script) Load(c Conn) error {
+ _, err := c.Do("SCRIPT", "LOAD", s.src)
+ return err
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script_test.go
new file mode 100644
index 000000000..c9635bf08
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script_test.go
@@ -0,0 +1,93 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "fmt"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/garyburd/redigo/internal/redistest"
+ "github.com/garyburd/redigo/redis"
+)
+
+func ExampleScript(c redis.Conn, reply interface{}, err error) {
+ // Initialize a package-level variable with a script.
+ var getScript = redis.NewScript(1, `return redis.call('get', KEYS[1])`)
+
+ // In a function, use the script Do method to evaluate the script. The Do
+ // method optimistically uses the EVALSHA command. If the script is not
+ // loaded, then the Do method falls back to the EVAL command.
+ reply, err = getScript.Do(c, "foo")
+}
+
+func TestScript(t *testing.T) {
+ c, err := redistest.Dial()
+ if err != nil {
+ t.Fatalf("error connection to database, %v", err)
+ }
+ defer c.Close()
+
+ // To test fall back in Do, we make script unique by adding comment with current time.
+ script := fmt.Sprintf("--%d\nreturn {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", time.Now().UnixNano())
+ s := redis.NewScript(2, script)
+ reply := []interface{}{[]byte("key1"), []byte("key2"), []byte("arg1"), []byte("arg2")}
+
+ v, err := s.Do(c, "key1", "key2", "arg1", "arg2")
+ if err != nil {
+ t.Errorf("s.Do(c, ...) returned %v", err)
+ }
+
+ if !reflect.DeepEqual(v, reply) {
+ t.Errorf("s.Do(c, ..); = %v, want %v", v, reply)
+ }
+
+ err = s.Load(c)
+ if err != nil {
+ t.Errorf("s.Load(c) returned %v", err)
+ }
+
+ err = s.SendHash(c, "key1", "key2", "arg1", "arg2")
+ if err != nil {
+ t.Errorf("s.SendHash(c, ...) returned %v", err)
+ }
+
+ err = c.Flush()
+ if err != nil {
+ t.Errorf("c.Flush() returned %v", err)
+ }
+
+ v, err = c.Receive()
+ if !reflect.DeepEqual(v, reply) {
+ t.Errorf("s.SendHash(c, ..); c.Receive() = %v, want %v", v, reply)
+ }
+
+ err = s.Send(c, "key1", "key2", "arg1", "arg2")
+ if err != nil {
+ t.Errorf("s.Send(c, ...) returned %v", err)
+ }
+
+ err = c.Flush()
+ if err != nil {
+ t.Errorf("c.Flush() returned %v", err)
+ }
+
+ v, err = c.Receive()
+ if !reflect.DeepEqual(v, reply) {
+ t.Errorf("s.Send(c, ..); c.Receive() = %v, want %v", v, reply)
+ }
+
+}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/test_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/test_test.go
new file mode 100644
index 000000000..b959a11f4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/test_test.go
@@ -0,0 +1,38 @@
+// Copyright 2012 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis
+
+import (
+ "bufio"
+ "net"
+ "time"
+)
+
+func SetNowFunc(f func() time.Time) {
+ nowFunc = f
+}
+
+type nopCloser struct{ net.Conn }
+
+func (nopCloser) Close() error { return nil }
+
+// NewConnBufio is a hook for tests.
+func NewConnBufio(rw bufio.ReadWriter) Conn {
+ return &conn{br: rw.Reader, bw: rw.Writer, conn: nopCloser{}}
+}
+
+var (
+ ErrNegativeInt = errNegativeInt
+)
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/zpop_example_test.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/zpop_example_test.go
new file mode 100644
index 000000000..1d86ee6ce
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/zpop_example_test.go
@@ -0,0 +1,113 @@
+// Copyright 2013 Gary Burd
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package redis_test
+
+import (
+ "fmt"
+ "github.com/garyburd/redigo/redis"
+)
+
+// zpop pops a value from the ZSET key using WATCH/MULTI/EXEC commands.
+func zpop(c redis.Conn, key string) (result string, err error) {
+
+ defer func() {
+ // Return connection to normal state on error.
+ if err != nil {
+ c.Do("DISCARD")
+ }
+ }()
+
+ // Loop until transaction is successful.
+ for {
+ if _, err := c.Do("WATCH", key); err != nil {
+ return "", err
+ }
+
+ members, err := redis.Strings(c.Do("ZRANGE", key, 0, 0))
+ if err != nil {
+ return "", err
+ }
+ if len(members) != 1 {
+ return "", redis.ErrNil
+ }
+
+ c.Send("MULTI")
+ c.Send("ZREM", key, members[0])
+ queued, err := c.Do("EXEC")
+ if err != nil {
+ return "", err
+ }
+
+ if queued != nil {
+ result = members[0]
+ break
+ }
+ }
+
+ return result, nil
+}
+
+// zpopScript pops a value from a ZSET.
+var zpopScript = redis.NewScript(1, `
+ local r = redis.call('ZRANGE', KEYS[1], 0, 0)
+ if r ~= nil then
+ r = r[1]
+ redis.call('ZREM', KEYS[1], r)
+ end
+ return r
+`)
+
+// This example implements ZPOP as described at
+// http://redis.io/topics/transactions using WATCH/MULTI/EXEC and scripting.
+func Example_zpop() {
+ c, err := dial()
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+ defer c.Close()
+
+ // Add test data using a pipeline.
+
+ for i, member := range []string{"red", "blue", "green"} {
+ c.Send("ZADD", "zset", i, member)
+ }
+ if _, err := c.Do(""); err != nil {
+ fmt.Println(err)
+ return
+ }
+
+ // Pop using WATCH/MULTI/EXEC
+
+ v, err := zpop(c, "zset")
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+ fmt.Println(v)
+
+ // Pop using a script.
+
+ v, err = redis.String(zpopScript.Do(c, "zset"))
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+ fmt.Println(v)
+
+ // Output:
+ // red
+ // blue
+}
diff --git a/Godeps/_workspace/src/github.com/golang/groupcache/lru/lru.go b/Godeps/_workspace/src/github.com/golang/groupcache/lru/lru.go
new file mode 100644
index 000000000..cdfe2991f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/golang/groupcache/lru/lru.go
@@ -0,0 +1,121 @@
+/*
+Copyright 2013 Google Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Package lru implements an LRU cache.
+package lru
+
+import "container/list"
+
+// Cache is an LRU cache. It is not safe for concurrent access.
+type Cache struct {
+ // MaxEntries is the maximum number of cache entries before
+ // an item is evicted. Zero means no limit.
+ MaxEntries int
+
+ // OnEvicted optionally specificies a callback function to be
+ // executed when an entry is purged from the cache.
+ OnEvicted func(key Key, value interface{})
+
+ ll *list.List
+ cache map[interface{}]*list.Element
+}
+
+// A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
+type Key interface{}
+
+type entry struct {
+ key Key
+ value interface{}
+}
+
+// New creates a new Cache.
+// If maxEntries is zero, the cache has no limit and it's assumed
+// that eviction is done by the caller.
+func New(maxEntries int) *Cache {
+ return &Cache{
+ MaxEntries: maxEntries,
+ ll: list.New(),
+ cache: make(map[interface{}]*list.Element),
+ }
+}
+
+// Add adds a value to the cache.
+func (c *Cache) Add(key Key, value interface{}) {
+ if c.cache == nil {
+ c.cache = make(map[interface{}]*list.Element)
+ c.ll = list.New()
+ }
+ if ee, ok := c.cache[key]; ok {
+ c.ll.MoveToFront(ee)
+ ee.Value.(*entry).value = value
+ return
+ }
+ ele := c.ll.PushFront(&entry{key, value})
+ c.cache[key] = ele
+ if c.MaxEntries != 0 && c.ll.Len() > c.MaxEntries {
+ c.RemoveOldest()
+ }
+}
+
+// Get looks up a key's value from the cache.
+func (c *Cache) Get(key Key) (value interface{}, ok bool) {
+ if c.cache == nil {
+ return
+ }
+ if ele, hit := c.cache[key]; hit {
+ c.ll.MoveToFront(ele)
+ return ele.Value.(*entry).value, true
+ }
+ return
+}
+
+// Remove removes the provided key from the cache.
+func (c *Cache) Remove(key Key) {
+ if c.cache == nil {
+ return
+ }
+ if ele, hit := c.cache[key]; hit {
+ c.removeElement(ele)
+ }
+}
+
+// RemoveOldest removes the oldest item from the cache.
+func (c *Cache) RemoveOldest() {
+ if c.cache == nil {
+ return
+ }
+ ele := c.ll.Back()
+ if ele != nil {
+ c.removeElement(ele)
+ }
+}
+
+func (c *Cache) removeElement(e *list.Element) {
+ c.ll.Remove(e)
+ kv := e.Value.(*entry)
+ delete(c.cache, kv.key)
+ if c.OnEvicted != nil {
+ c.OnEvicted(kv.key, kv.value)
+ }
+}
+
+// Len returns the number of items in the cache.
+func (c *Cache) Len() int {
+ if c.cache == nil {
+ return 0
+ }
+ return c.ll.Len()
+}
diff --git a/Godeps/_workspace/src/github.com/golang/groupcache/lru/lru_test.go b/Godeps/_workspace/src/github.com/golang/groupcache/lru/lru_test.go
new file mode 100644
index 000000000..98a2656e8
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/golang/groupcache/lru/lru_test.go
@@ -0,0 +1,73 @@
+/*
+Copyright 2013 Google Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package lru
+
+import (
+ "testing"
+)
+
+type simpleStruct struct {
+ int
+ string
+}
+
+type complexStruct struct {
+ int
+ simpleStruct
+}
+
+var getTests = []struct {
+ name string
+ keyToAdd interface{}
+ keyToGet interface{}
+ expectedOk bool
+}{
+ {"string_hit", "myKey", "myKey", true},
+ {"string_miss", "myKey", "nonsense", false},
+ {"simple_struct_hit", simpleStruct{1, "two"}, simpleStruct{1, "two"}, true},
+ {"simeple_struct_miss", simpleStruct{1, "two"}, simpleStruct{0, "noway"}, false},
+ {"complex_struct_hit", complexStruct{1, simpleStruct{2, "three"}},
+ complexStruct{1, simpleStruct{2, "three"}}, true},
+}
+
+func TestGet(t *testing.T) {
+ for _, tt := range getTests {
+ lru := New(0)
+ lru.Add(tt.keyToAdd, 1234)
+ val, ok := lru.Get(tt.keyToGet)
+ if ok != tt.expectedOk {
+ t.Fatalf("%s: cache hit = %v; want %v", tt.name, ok, !ok)
+ } else if ok && val != 1234 {
+ t.Fatalf("%s expected get to return 1234 but got %v", tt.name, val)
+ }
+ }
+}
+
+func TestRemove(t *testing.T) {
+ lru := New(0)
+ lru.Add("myKey", 1234)
+ if val, ok := lru.Get("myKey"); !ok {
+ t.Fatal("TestRemove returned no match")
+ } else if val != 1234 {
+ t.Fatalf("TestRemove failed. Expected %d, got %v", 1234, val)
+ }
+
+ lru.Remove("myKey")
+ if _, ok := lru.Get("myKey"); ok {
+ t.Fatal("TestRemove returned a removed entry")
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/.gitignore b/Godeps/_workspace/src/github.com/throttled/throttled/.gitignore
new file mode 100644
index 000000000..c2a6499b4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/.gitignore
@@ -0,0 +1,10 @@
+.DS_Store
+*.swp
+*.swo
+*.test
+examples/interval/interval
+examples/interval-vary/interval-vary
+examples/interval-many/interval-many
+examples/memstats/memstats
+examples/rate-limit/rate-limit
+examples/custom/custom
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/.travis.yml b/Godeps/_workspace/src/github.com/throttled/throttled/.travis.yml
new file mode 100644
index 000000000..1b2427202
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/.travis.yml
@@ -0,0 +1,10 @@
+sudo: false
+language: go
+
+go:
+ - 1.2
+ - tip
+
+install: go get -t ./...
+
+script: go test -v -short ./...
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/LICENSE b/Godeps/_workspace/src/github.com/throttled/throttled/LICENSE
new file mode 100644
index 000000000..f9616483e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/LICENSE
@@ -0,0 +1,12 @@
+Copyright (c) 2014, Martin Angers and Contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/README.md b/Godeps/_workspace/src/github.com/throttled/throttled/README.md
new file mode 100644
index 000000000..0954c808a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/README.md
@@ -0,0 +1,80 @@
+# Throttled [![build status](https://secure.travis-ci.org/throttled/throttled.png)](http://travis-ci.org/throttled/throttled) [![GoDoc](https://godoc.org/github.com/throttled/throttled?status.png)](http://godoc.org/github.com/throttled/throttled)
+
+Package throttled implements different throttling strategies for controlling
+access to HTTP handlers.
+
+*As of July 27, 2015, the package is now located under its own GitHub organization, please adjust your imports to `github.com/throttled/throttled`.*
+
+## Installation
+
+`go get github.com/throttled/throttled/...`
+
+## Interval
+
+The Interval function creates a throttler that allows requests to go through at
+a controlled, constant interval. The interval may be applied to all requests
+(vary argument == nil) or independently based on vary-by criteria.
+
+For example:
+
+ th := throttled.Interval(throttled.PerSec(10), 100, &throttled.VaryBy{Path: true}, 50)
+ h := th.Throttle(myHandler)
+ http.ListenAndServe(":9000", h)
+
+Creates a throttler that will allow a request each 100ms (10 requests per second), with
+a buffer of 100 exceeding requests before dropping requests with a status code 429 (by
+default, configurable using th.DeniedHandler or the package-global DefaultDeniedHandler
+variable). Different paths will be throttled independently, so that /path_a and /path_b
+both can serve 10 requests per second. The last argument, 50, indicates the maximum number
+of keys that the throttler will keep in memory.
+
+## MemStats
+
+The MemStats function creates a throttler that allows requests to go through only if
+the memory statistics of the current process are below specified thresholds.
+
+For example:
+
+ th := throttled.MemStats(throttled.MemThresholds(&runtime.MemStats{NumGC: 10}, 10*time.Millisecond)
+ h := th.Throttle(myHandler)
+ http.ListenAndServe(":9000", h)
+
+Creates a throttler that will allow requests to go through until the number of garbage
+collections reaches the initial number + 10 (the MemThresholds function creates absolute
+memory stats thresholds from offsets). The second argument, 10ms, indicates the refresh
+rate of the memory stats.
+
+## RateLimit
+
+The RateLimit function creates a throttler that allows a certain number of requests in
+a given time window, as is often implemented in public RESTful APIs.
+
+For example:
+
+ th := throttled.RateLimit(throttled.PerMin(30), &throttled.VaryBy{RemoteAddr: true}, store.NewMemStore(1000))
+ h := th.Throttle(myHandler)
+ http.ListenAndServe(":9000", h)
+
+Creates a throttler that will limit requests to 30 per minute, based on the remote address
+of the client, and will store the counter and remaining time of the current window in the
+provided memory store, limiting the number of keys to keep in memory to 1000. The store
+sub-package also provides a Redis-based Store implementations.
+
+The RateLimit throttler sets the expected X-RateLimit-* headers on the response, and
+also sets a Retry-After header when the limit is exceeded.
+
+## Documentation
+
+The API documentation is available as usual on [godoc.org][doc].
+
+There is also a [blog post explaining the package's usage on 0value.com][blog].
+
+Finally, many examples are provided in the /examples sub-folder of the repository.
+
+## License
+
+The [BSD 3-clause license][bsd]. Copyright (c) 2014 Martin Angers and Contributors.
+
+[doc]: http://godoc.org/github.com/throttled/throttled
+[blog]: http://0value.com/throttled--guardian-of-the-web-server
+[bsd]: http://opensource.org/licenses/BSD-3-Clause
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/common_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/common_test.go
new file mode 100644
index 000000000..ddb57fb1c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/common_test.go
@@ -0,0 +1,65 @@
+package throttled
+
+import (
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "sync"
+ "time"
+
+ "github.com/PuerkitoBio/boom/commands"
+)
+
+type stats struct {
+ sync.Mutex
+ ok int
+ dropped int
+ ts []time.Time
+
+ body func()
+}
+
+func (s *stats) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if s.body != nil {
+ s.body()
+ }
+ s.Lock()
+ defer s.Unlock()
+ s.ts = append(s.ts, time.Now())
+ s.ok++
+ w.WriteHeader(200)
+}
+
+func (s *stats) DeniedHTTP(w http.ResponseWriter, r *http.Request) {
+ s.Lock()
+ defer s.Unlock()
+ s.dropped++
+ w.WriteHeader(deniedStatus)
+}
+
+func (s *stats) Stats() (int, int, []time.Time) {
+ s.Lock()
+ defer s.Unlock()
+ return s.ok, s.dropped, s.ts
+}
+
+func runTest(h http.Handler, b ...commands.Boom) []*commands.Report {
+ srv := httptest.NewServer(h)
+ defer srv.Close()
+
+ var rpts []*commands.Report
+ var wg sync.WaitGroup
+ var mu sync.Mutex
+ wg.Add(len(b))
+ for i, bo := range b {
+ bo.Req.Url = srv.URL + fmt.Sprintf("/%d", i)
+ go func(bo commands.Boom) {
+ mu.Lock()
+ defer mu.Unlock()
+ rpts = append(rpts, bo.Run())
+ wg.Done()
+ }(bo)
+ }
+ wg.Wait()
+ return rpts
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/delayer.go b/Godeps/_workspace/src/github.com/throttled/throttled/delayer.go
new file mode 100644
index 000000000..e62ec9e86
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/delayer.go
@@ -0,0 +1,109 @@
+package throttled
+
+import "time"
+
+// The Quota interface defines the method to implement to describe
+// a time-window quota, as required by the RateLimit throttler.
+type Quota interface {
+ // Quota returns a number of requests allowed, and a duration.
+ Quota() (int, time.Duration)
+}
+
+// The Delayer interface defines the method to implement to describe
+// a delay as required by the Interval throttler.
+type Delayer interface {
+ // Delay returns a duration.
+ Delay() time.Duration
+}
+
+// PerSec represents a number of requests per second.
+type PerSec int
+
+// Delay returns the duration to wait before the next request can go through,
+// so that PerSec(n) == n requests per second at regular intervals.
+func (ps PerSec) Delay() time.Duration {
+ if ps <= 0 {
+ return 0
+ }
+ return time.Duration(1.0 / float64(ps) * float64(time.Second))
+}
+
+// Quota returns the number of requests allowed in a 1 second time window,
+// so that PerSec(n) == n requests allowed per second.
+func (ps PerSec) Quota() (int, time.Duration) {
+ return int(ps), time.Second
+}
+
+// PerMin represents a number of requests per minute.
+type PerMin int
+
+// Delay returns the duration to wait before the next request can go through,
+// so that PerMin(n) == n requests per minute at regular intervals.
+func (pm PerMin) Delay() time.Duration {
+ if pm <= 0 {
+ return 0
+ }
+ return time.Duration(1.0 / float64(pm) * float64(time.Minute))
+}
+
+// Quota returns the number of requests allowed in a 1 minute time window,
+// so that PerMin(n) == n requests allowed per minute.
+func (pm PerMin) Quota() (int, time.Duration) {
+ return int(pm), time.Minute
+}
+
+// PerHour represents a number of requests per hour.
+type PerHour int
+
+// Delay returns the duration to wait before the next request can go through,
+// so that PerHour(n) == n requests per hour at regular intervals.
+func (ph PerHour) Delay() time.Duration {
+ if ph <= 0 {
+ return 0
+ }
+ return time.Duration(1.0 / float64(ph) * float64(time.Hour))
+}
+
+// Quota returns the number of requests allowed in a 1 hour time window,
+// so that PerHour(n) == n requests allowed per hour.
+func (ph PerHour) Quota() (int, time.Duration) {
+ return int(ph), time.Hour
+}
+
+// PerDay represents a number of requests per day.
+type PerDay int
+
+// Delay returns the duration to wait before the next request can go through,
+// so that PerDay(n) == n requests per day at regular intervals.
+func (pd PerDay) Delay() time.Duration {
+ if pd <= 0 {
+ return 0
+ }
+ return time.Duration(1.0 / float64(pd) * float64(24*time.Hour))
+}
+
+// Quota returns the number of requests allowed in a 1 day time window,
+// so that PerDay(n) == n requests allowed per day.
+func (pd PerDay) Quota() (int, time.Duration) {
+ return int(pd), 24 * time.Hour
+}
+
+// D represents a custom delay.
+type D time.Duration
+
+// Delay returns the duration to wait before the next request can go through,
+// which is the custom duration represented by the D value.
+func (d D) Delay() time.Duration {
+ return time.Duration(d)
+}
+
+// Q represents a custom quota.
+type Q struct {
+ Requests int
+ Window time.Duration
+}
+
+// Quota returns the number of requests allowed and the custom time window.
+func (q Q) Quota() (int, time.Duration) {
+ return q.Requests, q.Window
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/delayer_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/delayer_test.go
new file mode 100644
index 000000000..822978e5d
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/delayer_test.go
@@ -0,0 +1,65 @@
+package throttled
+
+import (
+ "testing"
+ "time"
+)
+
+func TestDelayer(t *testing.T) {
+ cases := []struct {
+ in Delayer
+ out time.Duration
+ }{
+ 0: {PerSec(1), time.Second},
+ 1: {PerSec(2), 500 * time.Millisecond},
+ 2: {PerSec(4), 250 * time.Millisecond},
+ 3: {PerSec(5), 200 * time.Millisecond},
+ 4: {PerSec(10), 100 * time.Millisecond},
+ 5: {PerSec(100), 10 * time.Millisecond},
+ 6: {PerSec(3), 333333333 * time.Nanosecond},
+ 7: {PerMin(1), time.Minute},
+ 8: {PerMin(2), 30 * time.Second},
+ 9: {PerMin(4), 15 * time.Second},
+ 10: {PerMin(5), 12 * time.Second},
+ 11: {PerMin(10), 6 * time.Second},
+ 12: {PerMin(60), time.Second},
+ 13: {PerHour(1), time.Hour},
+ 14: {PerHour(2), 30 * time.Minute},
+ 15: {PerHour(4), 15 * time.Minute},
+ 16: {PerHour(60), time.Minute},
+ 17: {PerHour(120), 30 * time.Second},
+ 18: {D(time.Second), time.Second},
+ 19: {D(5 * time.Minute), 5 * time.Minute},
+ 20: {PerSec(200), 5 * time.Millisecond},
+ 21: {PerDay(24), time.Hour},
+ }
+ for i, c := range cases {
+ got := c.in.Delay()
+ if got != c.out {
+ t.Errorf("%d: expected %s, got %s", i, c.out, got)
+ }
+ }
+}
+
+func TestQuota(t *testing.T) {
+ cases := []struct {
+ q Quota
+ reqs int
+ win time.Duration
+ }{
+ 0: {PerSec(10), 10, time.Second},
+ 1: {PerMin(30), 30, time.Minute},
+ 2: {PerHour(124), 124, time.Hour},
+ 3: {PerDay(1), 1, 24 * time.Hour},
+ 4: {Q{148, 17 * time.Second}, 148, 17 * time.Second},
+ }
+ for i, c := range cases {
+ r, w := c.q.Quota()
+ if r != c.reqs {
+ t.Errorf("%d: expected %d requests, got %d", i, c.reqs, r)
+ }
+ if w != c.win {
+ t.Errorf("%d: expected %s window, got %s", i, c.win, w)
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/doc.go b/Godeps/_workspace/src/github.com/throttled/throttled/doc.go
new file mode 100644
index 000000000..a83b0aca4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/doc.go
@@ -0,0 +1,77 @@
+// Package throttled implements different throttling strategies for controlling
+// access to HTTP handlers.
+//
+// Installation
+//
+// go get github.com/throttled/throttled/...
+//
+// Inverval
+//
+// The Interval function creates a throttler that allows requests to go through at
+// a controlled, constant interval. The interval may be applied to all requests
+// (vary argument == nil) or independently based on vary-by criteria.
+//
+// For example:
+//
+// th := throttled.Interval(throttled.PerSec(10), 100, &throttled.VaryBy{Path: true}, 50)
+// h := th.Throttle(myHandler)
+// http.ListenAndServe(":9000", h)
+//
+// Creates a throttler that will allow a request each 100ms (10 requests per second), with
+// a buffer of 100 exceeding requests before dropping requests with a status code 429 (by
+// default, configurable using th.DeniedHandler or the package-global DefaultDeniedHandler
+// variable). Different paths will be throttled independently, so that /path_a and /path_b
+// both can serve 10 requests per second. The last argument, 50, indicates the maximum number
+// of keys that the throttler will keep in memory.
+//
+// MemStats
+//
+// The MemStats function creates a throttler that allows requests to go through only if
+// the memory statistics of the current process are below specified thresholds.
+//
+// For example:
+//
+// th := throttled.MemStats(throttled.MemThresholds(&runtime.MemStats{NumGC: 10}, 10*time.Millisecond)
+// h := th.Throttle(myHandler)
+// http.ListenAndServe(":9000", h)
+//
+// Creates a throttler that will allow requests to go through until the number of garbage
+// collections reaches the initial number + 10 (the MemThresholds function creates absolute
+// memory stats thresholds from offsets). The second argument, 10ms, indicates the refresh
+// rate of the memory stats.
+//
+// RateLimit
+//
+// The RateLimit function creates a throttler that allows a certain number of requests in
+// a given time window, as is often implemented in public RESTful APIs.
+//
+// For example:
+//
+// th := throttled.RateLimit(throttled.PerMin(30), &throttled.VaryBy{RemoteAddr: true}, store.NewMemStore(1000))
+// h := th.Throttle(myHandler)
+// http.ListenAndServe(":9000", h)
+//
+// Creates a throttler that will limit requests to 30 per minute, based on the remote address
+// of the client, and will store the counter and remaining time of the current window in the
+// provided memory store, limiting the number of keys to keep in memory to 1000. The store
+// sub-package also provides a Redis-based Store implementations.
+//
+// The RateLimit throttler sets the expected X-RateLimit-* headers on the response, and
+// also sets a Retry-After header when the limit is exceeded.
+//
+// Documentation
+//
+// The API documentation is available as usual on godoc.org:
+// http://godoc.org/github.com/throttled/throttled
+//
+// There is also a blog post explaining the package's usage on 0value.com:
+// http://0value.com/throttled--guardian-of-the-web-server
+//
+// Finally, many examples are provided in the /examples sub-folder of the repository.
+//
+// License
+//
+// The BSD 3-clause license. Copyright (c) 2014 Martin Angers and Contributors.
+// http://opensource.org/licenses/BSD-3-Clause
+//
+package throttled
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/README.md b/Godeps/_workspace/src/github.com/throttled/throttled/examples/README.md
new file mode 100644
index 000000000..6b12dad20
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/README.md
@@ -0,0 +1,12 @@
+# Examples
+
+This directory contains examples for all the throttlers implemented by the throttled package, as well as an example of a custom limiter.
+
+* custom/ : implements a custom limiter that allows requests to path /a on even seconds, and on path /b on odd seconds.
+* interval-many/ : implements a common interval throttler to control two different handlers, one for path /a and another for path /b, so that requests to any one of the handlers go through at the specified interval.
+* interval-vary/ : implements an interval throttler that varies by path, so that requests to each different path goes through at the specified interval.
+* interval/ : implements an interval throttler so that any request goes through at the specified interval, regardless of path or any other criteria.
+* memstats/ : implements a memory-usage throttler that limits access based on current memory statistics.
+* rate-limit/ : implements a rate-limiter throttler that varies by path, so that the number of requests allowed are counted based on the requested path.
+
+Each example app supports a number of command-line flags. Run the example with the -h flag to display usage and defaults.
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/custom/main.go b/Godeps/_workspace/src/github.com/throttled/throttled/examples/custom/main.go
new file mode 100644
index 000000000..4a3fe119c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/custom/main.go
@@ -0,0 +1,90 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "math/rand"
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/throttled/throttled"
+)
+
+var (
+ delayRes = flag.Duration("delay-response", 0, "delay the response by a random duration between 0 and this value")
+ output = flag.String("output", "v", "type of output, one of `v`erbose, `q`uiet, `ok`-only, `ko`-only")
+)
+
+// Custom limiter: allow requests to the /a path on even seconds only, and
+// allow access to the /b path on odd seconds only.
+//
+// Yes this is absurd. A more realistic case could be to allow requests to some
+// contest page only during a limited time window.
+type customLimiter struct {
+}
+
+func (c *customLimiter) Start() {
+ // No-op
+}
+
+func (c *customLimiter) Limit(w http.ResponseWriter, r *http.Request) (<-chan bool, error) {
+ s := time.Now().Second()
+ ch := make(chan bool, 1)
+ ok := (r.URL.Path == "/a" && s%2 == 0) || (r.URL.Path == "/b" && s%2 != 0)
+ ch <- ok
+ if *output == "v" {
+ log.Printf("Custom Limiter: Path=%s, Second=%d; ok? %v", r.URL.Path, s, ok)
+ }
+ return ch, nil
+}
+
+func main() {
+ flag.Parse()
+
+ var h http.Handler
+ var ok, ko int
+ var mu sync.Mutex
+
+ // Keep the start time to print since-time
+ start := time.Now()
+ // Create the custom throttler using our custom limiter
+ t := throttled.Custom(&customLimiter{})
+ // Set its denied handler
+ t.DeniedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ko" {
+ log.Printf("KO: %s", time.Since(start))
+ }
+ throttled.DefaultDeniedHandler.ServeHTTP(w, r)
+ mu.Lock()
+ defer mu.Unlock()
+ ko++
+ })
+ // Throttle the OK handler
+ rand.Seed(time.Now().Unix())
+ h = t.Throttle(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ok" {
+ log.Printf("ok: %s", time.Since(start))
+ }
+ if *delayRes > 0 {
+ wait := time.Duration(rand.Intn(int(*delayRes)))
+ time.Sleep(wait)
+ }
+ w.WriteHeader(200)
+ mu.Lock()
+ defer mu.Unlock()
+ ok++
+ }))
+
+ // Print stats once in a while
+ go func() {
+ for _ = range time.Tick(10 * time.Second) {
+ mu.Lock()
+ log.Printf("ok: %d, ko: %d", ok, ko)
+ mu.Unlock()
+ }
+ }()
+ fmt.Println("server listening on port 9000")
+ http.ListenAndServe(":9000", h)
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-many/main.go b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-many/main.go
new file mode 100644
index 000000000..d0add9fb2
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-many/main.go
@@ -0,0 +1,79 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "math/rand"
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/throttled/throttled"
+)
+
+var (
+ delay = flag.Duration("delay", 200*time.Millisecond, "delay between calls")
+ bursts = flag.Int("bursts", 10, "number of bursts allowed")
+ delayRes = flag.Duration("delay-response", 0, "delay the response by a random duration between 0 and this value")
+ output = flag.String("output", "v", "type of output, one of `v`erbose, `q`uiet, `ok`-only, `ko`-only")
+)
+
+func main() {
+ flag.Parse()
+
+ var ok, ko int
+ var mu sync.Mutex
+
+ // Keep start time to log since-time
+ start := time.Now()
+
+ // Create the interval throttle
+ t := throttled.Interval(throttled.D(*delay), *bursts, nil, 0)
+ // Set its denied handler
+ t.DeniedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ko" {
+ log.Printf("%s: KO: %s", r.URL.Path, time.Since(start))
+ }
+ throttled.DefaultDeniedHandler.ServeHTTP(w, r)
+ mu.Lock()
+ defer mu.Unlock()
+ ko++
+ })
+ // Create OK handlers
+ rand.Seed(time.Now().Unix())
+ makeHandler := func(ix int) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ok" {
+ log.Printf("handler %d: %s: ok: %s", ix, r.URL.Path, time.Since(start))
+ }
+ if *delayRes > 0 {
+ wait := time.Duration(rand.Intn(int(*delayRes)))
+ time.Sleep(wait)
+ }
+ w.WriteHeader(200)
+ mu.Lock()
+ defer mu.Unlock()
+ ok++
+ })
+ }
+ // Throttle them using the same interval throttler
+ h1 := t.Throttle(makeHandler(1))
+ h2 := t.Throttle(makeHandler(2))
+
+ // Handle two paths
+ mux := http.NewServeMux()
+ mux.Handle("/a", h1)
+ mux.Handle("/b", h2)
+
+ // Print stats once in a while
+ go func() {
+ for _ = range time.Tick(10 * time.Second) {
+ mu.Lock()
+ log.Printf("ok: %d, ko: %d", ok, ko)
+ mu.Unlock()
+ }
+ }()
+ fmt.Println("server listening on port 9000")
+ http.ListenAndServe(":9000", mux)
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/main.go b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/main.go
new file mode 100644
index 000000000..439d4ad8b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/main.go
@@ -0,0 +1,74 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "math/rand"
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/throttled/throttled"
+)
+
+var (
+ delay = flag.Duration("delay", 200*time.Millisecond, "delay between calls")
+ bursts = flag.Int("bursts", 10, "number of bursts allowed")
+ maxkeys = flag.Int("max-keys", 1000, "maximum number of keys")
+ delayRes = flag.Duration("delay-response", 0, "delay the response by a random duration between 0 and this value")
+ output = flag.String("output", "v", "type of output, one of `v`erbose, `q`uiet, `ok`-only, `ko`-only")
+)
+
+func main() {
+ flag.Parse()
+
+ var h http.Handler
+ var ok, ko int
+ var mu sync.Mutex
+
+ // Keep the start time to print since-time
+ start := time.Now()
+
+ // Create the interval throttler
+ t := throttled.Interval(throttled.D(*delay), *bursts, &throttled.VaryBy{
+ Path: true,
+ }, *maxkeys)
+ // Set the denied handler
+ t.DeniedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ko" {
+ log.Printf("KO: %s", time.Since(start))
+ }
+ throttled.DefaultDeniedHandler.ServeHTTP(w, r)
+ mu.Lock()
+ defer mu.Unlock()
+ ko++
+ })
+
+ // Throttle the OK handler
+ rand.Seed(time.Now().Unix())
+ h = t.Throttle(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ok" {
+ log.Printf("%s: ok: %s", r.URL.Path, time.Since(start))
+ }
+ if *delayRes > 0 {
+ wait := time.Duration(rand.Intn(int(*delayRes)))
+ time.Sleep(wait)
+ }
+ w.WriteHeader(200)
+ mu.Lock()
+ defer mu.Unlock()
+ ok++
+ }))
+
+ // Print stats once in a while
+ go func() {
+ for _ = range time.Tick(10 * time.Second) {
+ mu.Lock()
+ log.Printf("ok: %d, ko: %d", ok, ko)
+ mu.Unlock()
+ }
+ }()
+ fmt.Println("server listening on port 9000")
+ http.ListenAndServe(":9000", h)
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/siege-urls b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/siege-urls
new file mode 100644
index 000000000..9a2d0d312
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval-vary/siege-urls
@@ -0,0 +1,4 @@
+http://localhost:9000/a
+http://localhost:9000/b
+http://localhost:9000/c
+
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval/main.go b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval/main.go
new file mode 100644
index 000000000..7c6473346
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/interval/main.go
@@ -0,0 +1,69 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "math/rand"
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/throttled/throttled"
+)
+
+var (
+ delay = flag.Duration("delay", 200*time.Millisecond, "delay between calls")
+ bursts = flag.Int("bursts", 10, "number of bursts allowed")
+ delayRes = flag.Duration("delay-response", 0, "delay the response by a random duration between 0 and this value")
+ output = flag.String("output", "v", "type of output, one of `v`erbose, `q`uiet, `ok`-only, `ko`-only")
+)
+
+func main() {
+ flag.Parse()
+
+ var h http.Handler
+ var ok, ko int
+ var mu sync.Mutex
+
+ // Keep the start time to print since-time
+ start := time.Now()
+ // Create the interval throttler
+ t := throttled.Interval(throttled.D(*delay), *bursts, nil, 0)
+ // Set its denied handler
+ t.DeniedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ko" {
+ log.Printf("KO: %s", time.Since(start))
+ }
+ throttled.DefaultDeniedHandler.ServeHTTP(w, r)
+ mu.Lock()
+ defer mu.Unlock()
+ ko++
+ })
+ // Throttle the OK handler
+ rand.Seed(time.Now().Unix())
+ h = t.Throttle(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ok" {
+ log.Printf("ok: %s", time.Since(start))
+ }
+ if *delayRes > 0 {
+ wait := time.Duration(rand.Intn(int(*delayRes)))
+ time.Sleep(wait)
+ }
+ w.WriteHeader(200)
+ mu.Lock()
+ defer mu.Unlock()
+ ok++
+ }))
+
+ // Print stats once in a while
+ go func() {
+ for _ = range time.Tick(10 * time.Second) {
+ mu.Lock()
+ log.Printf("ok: %d, ko: %d", ok, ko)
+ mu.Unlock()
+ }
+ }()
+ fmt.Println("server listening on port 9000")
+ http.ListenAndServe(":9000", h)
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/main.go b/Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/main.go
new file mode 100644
index 000000000..719fea01b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/main.go
@@ -0,0 +1,97 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "math/rand"
+ "net/http"
+ "runtime"
+ "sync"
+ "time"
+
+ "github.com/throttled/throttled"
+)
+
+var (
+ numgc = flag.Int("gc", 0, "number of GC runs")
+ mallocs = flag.Int("mallocs", 0, "number of mallocs")
+ total = flag.Int("total", 0, "total number of bytes allocated")
+ allocs = flag.Int("allocs", 0, "number of bytes allocated")
+ refrate = flag.Duration("refresh", 0, "refresh rate of the memory stats")
+ delayRes = flag.Duration("delay-response", 0, "delay the response by a random duration between 0 and this value")
+ output = flag.String("output", "v", "type of output, one of `v`erbose, `q`uiet, `ok`-only, `ko`-only")
+)
+
+func main() {
+ flag.Parse()
+
+ var h http.Handler
+ var ok, ko int
+ var mu sync.Mutex
+
+ // Keep the start time to print since-time
+ start := time.Now()
+ // Create the thresholds struct
+ thresh := throttled.MemThresholds(&runtime.MemStats{
+ NumGC: uint32(*numgc),
+ Mallocs: uint64(*mallocs),
+ TotalAlloc: uint64(*total),
+ Alloc: uint64(*allocs),
+ })
+ if *output != "q" {
+ log.Printf("thresholds: NumGC: %d, Mallocs: %d, Alloc: %dKb, Total: %dKb", thresh.NumGC, thresh.Mallocs, thresh.Alloc/1024, thresh.TotalAlloc/1024)
+ }
+ // Create the MemStats throttler
+ t := throttled.MemStats(thresh, *refrate)
+ // Set its denied handler
+ t.DeniedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ko" {
+ log.Printf("KO: %s", time.Since(start))
+ }
+ throttled.DefaultDeniedHandler.ServeHTTP(w, r)
+ mu.Lock()
+ defer mu.Unlock()
+ ko++
+ })
+
+ // Throttle the OK handler
+ rand.Seed(time.Now().Unix())
+ h = t.Throttle(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ok" {
+ log.Printf("ok: %s", time.Since(start))
+ }
+ if *delayRes > 0 {
+ wait := time.Duration(rand.Intn(int(*delayRes)))
+ time.Sleep(wait)
+ }
+ // Read the whole file in memory, to actually use 64Kb (instead of streaming to w)
+ b, err := ioutil.ReadFile("test-file")
+ if err != nil {
+ throttled.Error(w, r, err)
+ return
+ }
+ _, err = w.Write(b)
+ if err != nil {
+ throttled.Error(w, r, err)
+ }
+ mu.Lock()
+ defer mu.Unlock()
+ ok++
+ }))
+
+ // Print stats once in a while
+ go func() {
+ var mem runtime.MemStats
+ for _ = range time.Tick(10 * time.Second) {
+ mu.Lock()
+ runtime.ReadMemStats(&mem)
+ log.Printf("ok: %d, ko: %d", ok, ko)
+ log.Printf("TotalAllocs: %d Kb, Allocs: %d Kb, Mallocs: %d, NumGC: %d", mem.TotalAlloc/1024, mem.Alloc/1024, mem.Mallocs, mem.NumGC)
+ mu.Unlock()
+ }
+ }()
+ fmt.Println("server listening on port 9000")
+ http.ListenAndServe(":9000", h)
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/test-file b/Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/test-file
new file mode 100644
index 000000000..c97c12f9b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/memstats/test-file
Binary files differ
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/examples/rate-limit/main.go b/Godeps/_workspace/src/github.com/throttled/throttled/examples/rate-limit/main.go
new file mode 100644
index 000000000..b7b31529a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/examples/rate-limit/main.go
@@ -0,0 +1,101 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "math/rand"
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/garyburd/redigo/redis"
+ "github.com/throttled/throttled"
+ "github.com/throttled/throttled/store"
+)
+
+var (
+ requests = flag.Int("requests", 10, "number of requests allowed in the time window")
+ window = flag.Duration("window", time.Minute, "time window for the limit of requests")
+ storeType = flag.String("store", "mem", "store to use, one of `mem` or `redis` (on default localhost port)")
+ delayRes = flag.Duration("delay-response", 0, "delay the response by a random duration between 0 and this value")
+ output = flag.String("output", "v", "type of output, one of `v`erbose, `q`uiet, `ok`-only, `ko`-only")
+)
+
+func main() {
+ flag.Parse()
+
+ var h http.Handler
+ var ok, ko int
+ var mu sync.Mutex
+ var st throttled.Store
+
+ // Keep the start time to print since-time
+ start := time.Now()
+ // Create the rate-limit store
+ switch *storeType {
+ case "mem":
+ st = store.NewMemStore(0)
+ case "redis":
+ st = store.NewRedisStore(setupRedis(), "throttled:", 0)
+ default:
+ log.Fatalf("unsupported store: %s", *storeType)
+ }
+ // Create the rate-limit throttler, varying on path
+ t := throttled.RateLimit(throttled.Q{Requests: *requests, Window: *window}, &throttled.VaryBy{
+ Path: true,
+ }, st)
+
+ // Set its denied handler
+ t.DeniedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ko" {
+ log.Printf("KO: %s", time.Since(start))
+ }
+ throttled.DefaultDeniedHandler.ServeHTTP(w, r)
+ mu.Lock()
+ defer mu.Unlock()
+ ko++
+ })
+
+ // Throttle the OK handler
+ rand.Seed(time.Now().Unix())
+ h = t.Throttle(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if *output == "v" || *output == "ok" {
+ log.Printf("ok: %s", time.Since(start))
+ }
+ if *delayRes > 0 {
+ wait := time.Duration(rand.Intn(int(*delayRes)))
+ time.Sleep(wait)
+ }
+ w.WriteHeader(200)
+ mu.Lock()
+ defer mu.Unlock()
+ ok++
+ }))
+
+ // Print stats once in a while
+ go func() {
+ for _ = range time.Tick(10 * time.Second) {
+ mu.Lock()
+ log.Printf("ok: %d, ko: %d", ok, ko)
+ mu.Unlock()
+ }
+ }()
+ fmt.Println("server listening on port 9000")
+ http.ListenAndServe(":9000", h)
+}
+
+func setupRedis() *redis.Pool {
+ pool := &redis.Pool{
+ MaxIdle: 3,
+ IdleTimeout: 30 * time.Second,
+ Dial: func() (redis.Conn, error) {
+ return redis.Dial("tcp", ":6379")
+ },
+ TestOnBorrow: func(c redis.Conn, t time.Time) error {
+ _, err := c.Do("PING")
+ return err
+ },
+ }
+ return pool
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/interval.go b/Godeps/_workspace/src/github.com/throttled/throttled/interval.go
new file mode 100644
index 000000000..628a5593e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/interval.go
@@ -0,0 +1,164 @@
+package throttled
+
+import (
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/golang/groupcache/lru"
+)
+
+// Static check to ensure that the interval limiters implement the Limiter interface.
+var _ Limiter = (*intervalVaryByLimiter)(nil)
+var _ Limiter = (*intervalLimiter)(nil)
+
+// Interval creates a throttler that controls the requests so that they
+// go through at a constant interval. The interval is specified by the
+// delay argument, and convenience types such as PerSec can be used to
+// express the interval in a more expressive way, i.e. PerSec(10) means
+// 10 requests per second or one request each 100ms, PerMin(30) means
+// 30 requests per minute or on request each 2s, etc.
+//
+// The bursts argument indicates the number of exceeding requests that may
+// be queued up waiting to be processed. Requests that overflow the queue
+// are dropped and go through the denied handler, which may be specified
+// on the Throttler and that defaults to the package-global variable
+// DefaultDeniedHandler.
+//
+// The vary argument indicates the criteria to use to group the requests,
+// so that the interval applies to the requests in the same group (e.g. based on
+// the path, or the remote IP address, etc.). If this argument is nil, the
+// interval applies to all requests going through this throttler.
+//
+// The maxKeys indicates the maximum number of keys to keep in memory to apply the interval,
+// when a vary argument is specified. A LRU algorithm is used to remove older keys.
+//
+func Interval(delay Delayer, bursts int, vary *VaryBy, maxKeys int) *Throttler {
+ var l Limiter
+ if vary != nil {
+ if maxKeys < 1 {
+ maxKeys = 1
+ }
+ l = &intervalVaryByLimiter{
+ delay: delay.Delay(),
+ bursts: bursts,
+ vary: vary,
+ maxKeys: maxKeys,
+ }
+ } else {
+ l = &intervalLimiter{
+ delay: delay.Delay(),
+ bursts: bursts,
+ }
+ }
+ return &Throttler{
+ limiter: l,
+ }
+}
+
+// The intervalLimiter struct implements an interval limiter with no vary-by
+// criteria.
+type intervalLimiter struct {
+ delay time.Duration
+ bursts int
+
+ bucket chan chan bool
+}
+
+// Start initializes the limiter for execution.
+func (il *intervalLimiter) Start() {
+ if il.bursts < 0 {
+ il.bursts = 0
+ }
+ il.bucket = make(chan chan bool, il.bursts)
+ go process(il.bucket, il.delay)
+}
+
+// Limit is called for each request to the throttled handler. It tries to
+// queue the request to allow it to run at the given interval, but if the
+// queue is full, the request is denied access.
+func (il *intervalLimiter) Limit(w http.ResponseWriter, r *http.Request) (<-chan bool, error) {
+ ch := make(chan bool, 1)
+ select {
+ case il.bucket <- ch:
+ return ch, nil
+ default:
+ ch <- false
+ return ch, nil
+ }
+}
+
+// The intervalVaryByLimiter struct implements an interval limiter with a vary-by
+// criteria.
+type intervalVaryByLimiter struct {
+ delay time.Duration
+ bursts int
+ vary *VaryBy
+
+ lock sync.RWMutex
+ keys *lru.Cache
+ maxKeys int
+}
+
+// Start initializes the limiter for execution.
+func (il *intervalVaryByLimiter) Start() {
+ if il.bursts < 0 {
+ il.bursts = 0
+ }
+ il.keys = lru.New(il.maxKeys)
+ il.keys.OnEvicted = il.stopProcess
+}
+
+// Limit is called for each request to the throttled handler. It tries to
+// queue the request for the vary-by key to allow it to run at the given interval,
+// but if the queue is full, the request is denied access.
+func (il *intervalVaryByLimiter) Limit(w http.ResponseWriter, r *http.Request) (<-chan bool, error) {
+ ch := make(chan bool, 1)
+ key := il.vary.Key(r)
+
+ il.lock.RLock()
+ item, ok := il.keys.Get(key)
+ if !ok {
+ // Create the key, bucket, start goroutine
+ // First release the read lock and acquire a write lock
+ il.lock.RUnlock()
+ il.lock.Lock()
+ // Create the bucket, add the key
+ bucket := make(chan chan bool, il.bursts)
+ il.keys.Add(key, bucket)
+ // Start the goroutine to process this bucket
+ go process(bucket, il.delay)
+ item = bucket
+ // Release the write lock, acquire the read lock
+ il.lock.Unlock()
+ il.lock.RLock()
+ }
+ defer il.lock.RUnlock()
+ bucket := item.(chan chan bool)
+ select {
+ case bucket <- ch:
+ return ch, nil
+ default:
+ ch <- false
+ return ch, nil
+ }
+}
+
+// process loops through the queued requests for a key's bucket, and sends
+// requests through at the given interval.
+func process(bucket chan chan bool, delay time.Duration) {
+ after := time.After(0)
+ for v := range bucket {
+ <-after
+ // Let the request go through
+ v <- true
+ // Wait the required duration
+ after = time.After(delay)
+ }
+}
+
+// stopProcess is called when a key is removed from the LRU cache so that its
+// accompanying goroutine is correctly released.
+func (il *intervalVaryByLimiter) stopProcess(key lru.Key, value interface{}) {
+ close(value.(chan chan bool))
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/interval_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/interval_test.go
new file mode 100644
index 000000000..bc584e134
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/interval_test.go
@@ -0,0 +1,114 @@
+package throttled
+
+import (
+ "net/http"
+ "testing"
+
+ "github.com/PuerkitoBio/boom/commands"
+)
+
+func TestInterval(t *testing.T) {
+ if testing.Short() {
+ t.Skip()
+ }
+ cases := []struct {
+ n int
+ c int
+ rps int
+ bursts int
+ }{
+ 0: {60, 10, 20, 100},
+ 1: {300, 20, 100, 100},
+ 2: {10, 10, 1, 10},
+ 3: {1000, 100, 1000, 100},
+ }
+ for i, c := range cases {
+ // Setup the stats handler
+ st := &stats{}
+ // Create the throttler
+ th := Interval(PerSec(c.rps), c.bursts, nil, 0)
+ th.DeniedHandler = http.HandlerFunc(st.DeniedHTTP)
+ b := commands.Boom{
+ Req: &commands.ReqOpts{},
+ N: c.n,
+ C: c.c,
+ Output: "quiet",
+ }
+ // Run the test
+ rpts := runTest(th.Throttle(st), b)
+ // Assert results
+ for _, rpt := range rpts {
+ assertRPS(t, i, c.rps, rpt)
+ }
+ assertStats(t, i, st, rpts)
+ }
+}
+
+func TestIntervalVary(t *testing.T) {
+ if testing.Short() {
+ t.Skip()
+ }
+ cases := []struct {
+ n int
+ c int
+ urls int
+ rps int
+ bursts int
+ }{
+ 0: {60, 10, 3, 20, 100},
+ 1: {300, 20, 3, 100, 100},
+ 2: {10, 10, 3, 1, 10},
+ 3: {500, 10, 2, 1000, 100},
+ }
+ for i, c := range cases {
+ // Setup the stats handler
+ st := &stats{}
+ // Create the throttler
+ th := Interval(PerSec(c.rps), c.bursts, nil, 0)
+ th.DeniedHandler = http.HandlerFunc(st.DeniedHTTP)
+ var booms []commands.Boom
+ for j := 0; j < c.urls; j++ {
+ booms = append(booms, commands.Boom{
+ Req: &commands.ReqOpts{},
+ N: c.n,
+ C: c.c,
+ Output: "quiet",
+ })
+ }
+ // Run the test
+ rpts := runTest(th.Throttle(st), booms...)
+ // Assert results
+ for _, rpt := range rpts {
+ assertRPS(t, i, c.rps, rpt)
+ }
+ assertStats(t, i, st, rpts)
+ }
+}
+
+func assertRPS(t *testing.T, ix int, exp int, rpt *commands.Report) {
+ wigglef := 0.2 * float64(exp)
+ if rpt.SuccessRPS < float64(exp)-wigglef || rpt.SuccessRPS > float64(exp)+wigglef {
+ t.Errorf("%d: expected RPS to be around %d, got %f", ix, exp, rpt.SuccessRPS)
+ }
+}
+
+func assertStats(t *testing.T, ix int, st *stats, rpts []*commands.Report) {
+ ok, ko, _ := st.Stats()
+ var twos, fives, max int
+ for _, rpt := range rpts {
+ twos += rpt.StatusCodeDist[200]
+ fives += rpt.StatusCodeDist[deniedStatus]
+ if len(rpt.StatusCodeDist) > max {
+ max = len(rpt.StatusCodeDist)
+ }
+ }
+ if ok != twos {
+ t.Errorf("%d: expected %d status 200, got %d", ix, twos, ok)
+ }
+ if ko != fives {
+ t.Errorf("%d: expected %d status 429, got %d", ix, fives, ok)
+ }
+ if max > 2 {
+ t.Errorf("%d: expected at most 2 different status codes, got %d", ix, max)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/memstats.go b/Godeps/_workspace/src/github.com/throttled/throttled/memstats.go
new file mode 100644
index 000000000..bd2765630
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/memstats.go
@@ -0,0 +1,214 @@
+package throttled
+
+import (
+ "net/http"
+ "runtime"
+ "sync"
+ "time"
+)
+
+// Static check to ensure that memStatsLimiter implements Limiter.
+var _ Limiter = (*memStatsLimiter)(nil)
+
+// The memStatsLimiter struct implements a limiter based on the memory statistics
+// of the current process.
+type memStatsLimiter struct {
+ thresholds *runtime.MemStats
+ refreshRate time.Duration
+
+ lockStats sync.RWMutex
+ stats runtime.MemStats
+}
+
+// MemStats creates a Throttler based on the memory statistics of the current process.
+// Any combination of any (non-array) integer field of Go's runtime.MemStats structure
+// can be used as thresholds to deny a request.
+//
+// As soon as one threshold value is reached, the access is denied. If the value can
+// decrease, access will be allowed again once it gets back under the threshold value.
+// Denied requests go through the denied handler, which may be specified on the Throttler
+// and that defaults to the package-global variable DefaultDeniedHandler.
+//
+// Thresholds must be specified in absolute numbers (i.e. NumGC = 10 means stop once the
+// NumGC reaches 10, not when the current value increments by 10), and zero values are
+// ignored.
+//
+// The refreshRate indicates the frequency at which the process' memory stats are refreshed,
+// and 0 means on each request.
+//
+func MemStats(thresholds *runtime.MemStats, refreshRate time.Duration) *Throttler {
+ return &Throttler{
+ limiter: &memStatsLimiter{
+ thresholds: thresholds,
+ refreshRate: refreshRate,
+ },
+ }
+}
+
+// Start initialized the limiter for execution.
+func (m *memStatsLimiter) Start() {
+ // Make sure there is an initial MemStats reading
+ runtime.ReadMemStats(&m.stats)
+ if m.refreshRate > 0 {
+ go m.refresh()
+ }
+}
+
+// refresh runs in a separate goroutine and refreshes the memory statistics
+// at regular intervals.
+func (m *memStatsLimiter) refresh() {
+ c := time.Tick(m.refreshRate)
+ for _ = range c {
+ m.lockStats.Lock()
+ runtime.ReadMemStats(&m.stats)
+ m.lockStats.Unlock()
+ }
+}
+
+// Limit is called for each request to the throttled handler. It checks if
+// the request can go through by checking the memory thresholds, and signals it
+// via the returned channel.
+func (m *memStatsLimiter) Limit(w http.ResponseWriter, r *http.Request) (<-chan bool, error) {
+ ch := make(chan bool, 1)
+ // Check if memory thresholds are reached
+ ch <- m.allow()
+ return ch, nil
+}
+
+// allow compares the current memory stats with the thresholds, and returns
+// false if any threshold is reached.
+func (m *memStatsLimiter) allow() bool {
+ m.lockStats.RLock()
+ mem := m.stats
+ m.lockStats.RUnlock()
+ // If refreshRate == 0, then read on every request.
+ if m.refreshRate == 0 {
+ runtime.ReadMemStats(&mem)
+ }
+ ok := true
+ checkStat(m.thresholds.Alloc, mem.Alloc, &ok)
+ checkStat(m.thresholds.BuckHashSys, mem.BuckHashSys, &ok)
+ checkStat(m.thresholds.Frees, mem.Frees, &ok)
+ checkStat(m.thresholds.GCSys, mem.GCSys, &ok)
+ checkStat(m.thresholds.HeapAlloc, mem.HeapAlloc, &ok)
+ checkStat(m.thresholds.HeapIdle, mem.HeapIdle, &ok)
+ checkStat(m.thresholds.HeapInuse, mem.HeapInuse, &ok)
+ checkStat(m.thresholds.HeapObjects, mem.HeapObjects, &ok)
+ checkStat(m.thresholds.HeapReleased, mem.HeapReleased, &ok)
+ checkStat(m.thresholds.HeapSys, mem.HeapSys, &ok)
+ checkStat(m.thresholds.LastGC, mem.LastGC, &ok)
+ checkStat(m.thresholds.Lookups, mem.Lookups, &ok)
+ checkStat(m.thresholds.MCacheInuse, mem.MCacheInuse, &ok)
+ checkStat(m.thresholds.MCacheSys, mem.MCacheSys, &ok)
+ checkStat(m.thresholds.MSpanInuse, mem.MSpanInuse, &ok)
+ checkStat(m.thresholds.MSpanSys, mem.MSpanSys, &ok)
+ checkStat(m.thresholds.Mallocs, mem.Mallocs, &ok)
+ checkStat(m.thresholds.NextGC, mem.NextGC, &ok)
+ checkStat(uint64(m.thresholds.NumGC), uint64(mem.NumGC), &ok)
+ checkStat(m.thresholds.OtherSys, mem.OtherSys, &ok)
+ checkStat(m.thresholds.PauseTotalNs, mem.PauseTotalNs, &ok)
+ checkStat(m.thresholds.StackInuse, mem.StackInuse, &ok)
+ checkStat(m.thresholds.StackSys, mem.StackSys, &ok)
+ checkStat(m.thresholds.Sys, mem.Sys, &ok)
+ checkStat(m.thresholds.TotalAlloc, mem.TotalAlloc, &ok)
+ return ok
+}
+
+// Checks the threshold value against the actual value, and assigns false
+// to the boolean pointer if the threshold is reached.
+func checkStat(threshold, actual uint64, ok *bool) {
+ if !*ok {
+ return
+ }
+ if threshold > 0 {
+ if actual >= threshold {
+ *ok = false
+ }
+ }
+}
+
+// MemThresholds is a convenience function to create a thresholds memory stats from
+// offsets to apply to the current memory stats. Zero values in the offset stats
+// are left to 0 in the resulting thresholds memory stats value.
+//
+// The return value may be used as thresholds argument to the MemStats function.
+func MemThresholds(offset *runtime.MemStats) *runtime.MemStats {
+ var mem, thr runtime.MemStats
+ runtime.ReadMemStats(&mem)
+ if offset.Alloc > 0 {
+ thr.Alloc = mem.Alloc + offset.Alloc
+ }
+ if offset.BuckHashSys > 0 {
+ thr.BuckHashSys = mem.BuckHashSys + offset.BuckHashSys
+ }
+ if offset.Frees > 0 {
+ thr.Frees = mem.Frees + offset.Frees
+ }
+ if offset.GCSys > 0 {
+ thr.GCSys = mem.GCSys + offset.GCSys
+ }
+ if offset.HeapAlloc > 0 {
+ thr.HeapAlloc = mem.HeapAlloc + offset.HeapAlloc
+ }
+ if offset.HeapIdle > 0 {
+ thr.HeapIdle = mem.HeapIdle + offset.HeapIdle
+ }
+ if offset.HeapInuse > 0 {
+ thr.HeapInuse = mem.HeapInuse + offset.HeapInuse
+ }
+ if offset.HeapObjects > 0 {
+ thr.HeapObjects = mem.HeapObjects + offset.HeapObjects
+ }
+ if offset.HeapReleased > 0 {
+ thr.HeapReleased = mem.HeapReleased + offset.HeapReleased
+ }
+ if offset.HeapSys > 0 {
+ thr.HeapSys = mem.HeapSys + offset.HeapSys
+ }
+ if offset.LastGC > 0 {
+ thr.LastGC = mem.LastGC + offset.LastGC
+ }
+ if offset.Lookups > 0 {
+ thr.Lookups = mem.Lookups + offset.Lookups
+ }
+ if offset.MCacheInuse > 0 {
+ thr.MCacheInuse = mem.MCacheInuse + offset.MCacheInuse
+ }
+ if offset.MCacheSys > 0 {
+ thr.MCacheSys = mem.MCacheSys + offset.MCacheSys
+ }
+ if offset.MSpanInuse > 0 {
+ thr.MSpanInuse = mem.MSpanInuse + offset.MSpanInuse
+ }
+ if offset.MSpanSys > 0 {
+ thr.MSpanSys = mem.MSpanSys + offset.MSpanSys
+ }
+ if offset.Mallocs > 0 {
+ thr.Mallocs = mem.Mallocs + offset.Mallocs
+ }
+ if offset.NextGC > 0 {
+ thr.NextGC = mem.NextGC + offset.NextGC
+ }
+ if offset.NumGC > 0 {
+ thr.NumGC = mem.NumGC + offset.NumGC
+ }
+ if offset.OtherSys > 0 {
+ thr.OtherSys = mem.OtherSys + offset.OtherSys
+ }
+ if offset.PauseTotalNs > 0 {
+ thr.PauseTotalNs = mem.PauseTotalNs + offset.PauseTotalNs
+ }
+ if offset.StackInuse > 0 {
+ thr.StackInuse = mem.StackInuse + offset.StackInuse
+ }
+ if offset.StackSys > 0 {
+ thr.StackSys = mem.StackSys + offset.StackSys
+ }
+ if offset.Sys > 0 {
+ thr.Sys = mem.Sys + offset.Sys
+ }
+ if offset.TotalAlloc > 0 {
+ thr.TotalAlloc = mem.TotalAlloc + offset.TotalAlloc
+ }
+ return &thr
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/memstats_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/memstats_test.go
new file mode 100644
index 000000000..2b8faa721
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/memstats_test.go
@@ -0,0 +1,64 @@
+package throttled
+
+import (
+ "net/http"
+ "runtime"
+ "testing"
+ "time"
+
+ "github.com/PuerkitoBio/boom/commands"
+)
+
+func TestMemStats(t *testing.T) {
+ if testing.Short() {
+ t.Skip()
+ }
+ cases := []struct {
+ n int
+ c int
+ gc uint32
+ total uint64
+ rate time.Duration
+ }{
+ 0: {1000, 10, 3, 0, 0},
+ 1: {200, 10, 0, 600000, 0},
+ 2: {500, 10, 2, 555555, 10 * time.Millisecond},
+ }
+ for i, c := range cases {
+ // Setup the stats handler
+ st := &stats{}
+ // Create the throttler
+ limit := MemThresholds(&runtime.MemStats{NumGC: c.gc, TotalAlloc: c.total})
+ th := MemStats(limit, c.rate)
+ th.DeniedHandler = http.HandlerFunc(st.DeniedHTTP)
+ // Run the test
+ b := commands.Boom{
+ Req: &commands.ReqOpts{},
+ N: c.n,
+ C: c.c,
+ Output: "quiet",
+ }
+ rpts := runTest(th.Throttle(st), b)
+ // Assert results
+ assertStats(t, i, st, rpts)
+ assertMem(t, i, limit)
+ }
+}
+
+func assertMem(t *testing.T, ix int, limit *runtime.MemStats) {
+ var mem runtime.MemStats
+ runtime.ReadMemStats(&mem)
+ if mem.NumGC < limit.NumGC {
+ t.Errorf("%d: expected gc to be at least %d, got %d", ix, limit.NumGC, mem.NumGC)
+ }
+ if mem.TotalAlloc < limit.TotalAlloc {
+ t.Errorf("%d: expected total alloc to be at least %dKb, got %dKb", ix, limit.TotalAlloc/1024, mem.TotalAlloc/1024)
+ }
+}
+
+func BenchmarkReadMemStats(b *testing.B) {
+ var mem runtime.MemStats
+ for i := 0; i < b.N; i++ {
+ runtime.ReadMemStats(&mem)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/misc/pre-commit b/Godeps/_workspace/src/github.com/throttled/throttled/misc/pre-commit
new file mode 100644
index 000000000..88b61bfde
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/misc/pre-commit
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright 2012 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# git gofmt pre-commit hook
+#
+# To use, store as .git/hooks/pre-commit inside your repository and make sure
+# it has execute permissions.
+#
+# This script does not handle file names that contain spaces.
+
+# golint is purely informational, it doesn't fail with exit code != 0 if it finds something,
+# because it may find a lot of false positives. Just print out its result for information.
+echo "lint result (informational only):"
+echo
+golint .
+
+# go vet returns 1 if an error was found. Exit the hook with this exit code.
+go vet ./...
+vetres=$?
+
+# Check for gofmt problems and report if any.
+gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
+[ -z "$gofiles" ] && echo "EXIT $vetres" && exit $vetres
+
+unformatted=$(gofmt -l $gofiles)
+[ -z "$unformatted" ] && echo "EXIT $vetres" && exit $vetres
+
+# Some files are not gofmt'd. Print message and fail.
+
+echo >&2 "Go files must be formatted with gofmt. Please run:"
+for fn in $unformatted; do
+ echo >&2 " gofmt -w $PWD/$fn"
+done
+
+echo "EXIT 1"
+exit 1
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/rate.go b/Godeps/_workspace/src/github.com/throttled/throttled/rate.go
new file mode 100644
index 000000000..d7a7de6d7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/rate.go
@@ -0,0 +1,116 @@
+package throttled
+
+import (
+ "math"
+ "net/http"
+ "strconv"
+ "time"
+)
+
+// Static check to ensure that rateLimiter implements Limiter.
+var _ Limiter = (*rateLimiter)(nil)
+
+// RateLimit creates a throttler that limits the number of requests allowed
+// in a certain time window defined by the Quota q. The q parameter specifies
+// the requests per time window, and it is silently set to at least 1 request
+// and at least a 1 second window if it is less than that. The time window
+// starts when the first request is made outside an existing window. Fractions
+// of seconds are not supported, they are truncated.
+//
+// The vary parameter indicates what criteria should be used to group requests
+// for which the limit must be applied (ex.: rate limit based on the remote address).
+// See varyby.go for the various options.
+//
+// The specified store is used to keep track of the request count and the
+// time remaining in the window. The throttled package comes with some stores
+// in the throttled/store package. Custom stores can be created too, by implementing
+// the Store interface.
+//
+// Requests that bust the rate limit are denied access and go through the denied handler,
+// which may be specified on the Throttler and that defaults to the package-global
+// variable DefaultDeniedHandler.
+//
+// The rate limit throttler sets the following headers on the response:
+//
+// X-RateLimit-Limit : quota
+// X-RateLimit-Remaining : number of requests remaining in the current window
+// X-RateLimit-Reset : seconds before a new window
+//
+// Additionally, if the request was denied access, the following header is added:
+//
+// Retry-After : seconds before the caller should retry
+//
+func RateLimit(q Quota, vary *VaryBy, store Store) *Throttler {
+ // Extract requests and window
+ reqs, win := q.Quota()
+
+ // Create and return the throttler
+ return &Throttler{
+ limiter: &rateLimiter{
+ reqs: reqs,
+ window: win,
+ vary: vary,
+ store: store,
+ },
+ }
+}
+
+// The rate limiter implements limiting the request to a certain quota
+// based on the vary-by criteria. State is saved in the store.
+type rateLimiter struct {
+ reqs int
+ window time.Duration
+ vary *VaryBy
+ store Store
+}
+
+// Start initializes the limiter for execution.
+func (r *rateLimiter) Start() {
+ if r.reqs < 1 {
+ r.reqs = 1
+ }
+ if r.window < time.Second {
+ r.window = time.Second
+ }
+}
+
+// Limit is called for each request to the throttled handler. It checks if
+// the request can go through and signals it via the returned channel.
+// It returns an error if the operation fails.
+func (r *rateLimiter) Limit(w http.ResponseWriter, req *http.Request) (<-chan bool, error) {
+ // Create return channel and initialize
+ ch := make(chan bool, 1)
+ ok := true
+ key := r.vary.Key(req)
+
+ // Get the current count and remaining seconds
+ cnt, secs, err := r.store.Incr(key, r.window)
+ // Handle the possible situations: error, begin new window, or increment current window.
+ switch {
+ case err != nil && err != ErrNoSuchKey:
+ // An unexpected error occurred
+ return nil, err
+ case err == ErrNoSuchKey || secs <= 0:
+ // Reset counter
+ if err := r.store.Reset(key, r.window); err != nil {
+ return nil, err
+ }
+ cnt = 1
+ secs = int(r.window.Seconds())
+ default:
+ // If the limit is reached, deny access
+ if cnt > r.reqs {
+ ok = false
+ }
+ }
+ // Set rate-limit headers
+ w.Header().Add("X-RateLimit-Limit", strconv.Itoa(r.reqs))
+ w.Header().Add("X-RateLimit-Remaining", strconv.Itoa(int(math.Max(float64(r.reqs-cnt), 0))))
+ w.Header().Add("X-RateLimit-Reset", strconv.Itoa(secs))
+ if !ok {
+ w.Header().Add("Retry-After", strconv.Itoa(secs))
+ }
+ // Send response via the return channel
+ ch <- ok
+ return ch, nil
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/rate_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/rate_test.go
new file mode 100644
index 000000000..67dea74b1
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/rate_test.go
@@ -0,0 +1,101 @@
+package throttled
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "strconv"
+ "testing"
+ "time"
+)
+
+const deniedStatus = 429
+
+// Simple memory store for tests, unsafe for concurrent access
+type mapStore struct {
+ cnt map[string]int
+ ts map[string]time.Time
+}
+
+func newMapStore() *mapStore {
+ return &mapStore{
+ make(map[string]int),
+ make(map[string]time.Time),
+ }
+}
+func (ms *mapStore) Incr(key string, window time.Duration) (int, int, error) {
+ if _, ok := ms.cnt[key]; !ok {
+ return 0, 0, ErrNoSuchKey
+ }
+ ms.cnt[key]++
+ ts := ms.ts[key]
+ return ms.cnt[key], RemainingSeconds(ts, window), nil
+}
+func (ms *mapStore) Reset(key string, win time.Duration) error {
+ ms.cnt[key] = 1
+ ms.ts[key] = time.Now().UTC()
+ return nil
+}
+
+func TestRateLimit(t *testing.T) {
+ quota := Q{5, 5 * time.Second}
+ cases := []struct {
+ limit, remain, reset, status int
+ }{
+ 0: {5, 4, 5, 200},
+ 1: {5, 3, 4, 200},
+ 2: {5, 2, 4, 200},
+ 3: {5, 1, 3, 200},
+ 4: {5, 0, 3, 200},
+ 5: {5, 0, 2, deniedStatus},
+ }
+ // Limit the requests to 2 per second
+ th := Interval(PerSec(2), 0, nil, 0)
+ // Rate limit
+ rl := RateLimit(quota, nil, newMapStore())
+ // Create the stats
+ st := &stats{}
+ // Create the handler
+ h := th.Throttle(rl.Throttle(st))
+
+ // Start the server
+ srv := httptest.NewServer(h)
+ defer srv.Close()
+ for i, c := range cases {
+ callRateLimited(t, i, c.limit, c.remain, c.reset, c.status, srv.URL)
+ }
+ // Wait 3 seconds and call again, should start a new window
+ time.Sleep(3 * time.Second)
+ callRateLimited(t, len(cases), 5, 4, 5, 200, srv.URL)
+}
+
+func callRateLimited(t *testing.T, i, limit, remain, reset, status int, url string) {
+ res, err := http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer res.Body.Close()
+ // Assert status code
+ if status != res.StatusCode {
+ t.Errorf("%d: expected status %d, got %d", i, status, res.StatusCode)
+ }
+ // Assert headers
+ if v := res.Header.Get("X-RateLimit-Limit"); v != strconv.Itoa(limit) {
+ t.Errorf("%d: expected limit header to be %d, got %s", i, limit, v)
+ }
+ if v := res.Header.Get("X-RateLimit-Remaining"); v != strconv.Itoa(remain) {
+ t.Errorf("%d: expected remain header to be %d, got %s", i, remain, v)
+ }
+ // Allow 1 second wiggle room
+ v := res.Header.Get("X-RateLimit-Reset")
+ vi, _ := strconv.Atoi(v)
+ if vi < reset-1 || vi > reset+1 {
+ t.Errorf("%d: expected reset header to be close to %d, got %d", i, reset, vi)
+ }
+ if status == deniedStatus {
+ v := res.Header.Get("Retry-After")
+ vi, _ := strconv.Atoi(v)
+ if vi < reset-1 || vi > reset+1 {
+ t.Errorf("%d: expected retry after header to be close to %d, got %d", i, reset, vi)
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/store.go b/Godeps/_workspace/src/github.com/throttled/throttled/store.go
new file mode 100644
index 000000000..760fe2b69
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/store.go
@@ -0,0 +1,31 @@
+package throttled
+
+import (
+ "errors"
+ "time"
+)
+
+// The error returned if the key does not exist in the Store.
+var ErrNoSuchKey = errors.New("throttled: no such key")
+
+// Store is the interface to implement to store the RateLimit state (number
+// of requests per key, time-to-live or creation timestamp).
+type Store interface {
+ // Incr increments the count for the specified key and returns the new value along
+ // with the number of seconds remaining. It may return an error
+ // if the operation fails.
+ //
+ // The method may return ErrNoSuchKey if the key to increment does not exist,
+ // in which case Reset will be called to initialize the value.
+ Incr(string, time.Duration) (int, int, error)
+
+ // Reset resets the key to 1 with the specified window duration. It must create the
+ // key if it doesn't exist. It returns an error if it fails.
+ Reset(string, time.Duration) error
+}
+
+// RemainingSeconds is a helper function that returns the number of seconds
+// remaining from an absolute timestamp in UTC.
+func RemainingSeconds(ts time.Time, window time.Duration) int {
+ return int((window - time.Now().UTC().Sub(ts)).Seconds())
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/store/doc.go b/Godeps/_workspace/src/github.com/throttled/throttled/store/doc.go
new file mode 100644
index 000000000..adb4618d3
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/store/doc.go
@@ -0,0 +1,2 @@
+// Package store offers a memory-based and a Redis-based throttled.Store implementation.
+package store
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/store/mem.go b/Godeps/_workspace/src/github.com/throttled/throttled/store/mem.go
new file mode 100644
index 000000000..e220dfe81
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/store/mem.go
@@ -0,0 +1,90 @@
+package store
+
+import (
+ "sync"
+ "time"
+
+ "github.com/golang/groupcache/lru"
+ "github.com/throttled/throttled"
+)
+
+// memStore implements an in-memory Store.
+type memStore struct {
+ sync.Mutex
+ keys *lru.Cache
+ m map[string]*counter
+}
+
+// NewMemStore creates a new MemStore. If maxKeys > 0, the number of different keys
+// is restricted to the specified amount. In this case, it uses an LRU algorithm to
+// evict older keys to make room for newer ones. If a request is made for a key that
+// has been evicted, it will be processed as if its count was 0, possibly allowing requests
+// that should be denied.
+//
+// If maxKeys <= 0, there is no limit on the number of keys, which may use an unbounded amount of
+// memory depending on the server's load.
+//
+// The MemStore is only for single-process rate-limiting. To share the rate limit state
+// among multiple instances of the web server, use a database- or key-value-based
+// store.
+//
+func NewMemStore(maxKeys int) throttled.Store {
+ var m *memStore
+ if maxKeys > 0 {
+ m = &memStore{
+ keys: lru.New(maxKeys),
+ }
+ } else {
+ m = &memStore{
+ m: make(map[string]*counter),
+ }
+ }
+ return m
+}
+
+// A counter represents a single entry in the MemStore.
+type counter struct {
+ n int
+ ts time.Time
+}
+
+// Incr increments the counter for the specified key. It returns the new
+// count value and the remaining number of seconds, or an error.
+func (ms *memStore) Incr(key string, window time.Duration) (int, int, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ var c *counter
+ if ms.keys != nil {
+ v, _ := ms.keys.Get(key)
+ if v != nil {
+ c = v.(*counter)
+ }
+ } else {
+ c = ms.m[key]
+ }
+ if c == nil {
+ c = &counter{0, time.Now().UTC()}
+ }
+ c.n++
+ if ms.keys != nil {
+ ms.keys.Add(key, c)
+ } else {
+ ms.m[key] = c
+ }
+ return c.n, throttled.RemainingSeconds(c.ts, window), nil
+}
+
+// Reset resets the counter for the specified key. It sets the count
+// to 1 and initializes the timestamp with the current time, in UTC.
+// It returns an error if the operation fails.
+func (ms *memStore) Reset(key string, win time.Duration) error {
+ ms.Lock()
+ defer ms.Unlock()
+ c := &counter{1, time.Now().UTC()}
+ if ms.keys != nil {
+ ms.keys.Add(key, c)
+ } else {
+ ms.m[key] = c
+ }
+ return nil
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/store/mem_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/store/mem_test.go
new file mode 100644
index 000000000..e8ef8d0da
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/store/mem_test.go
@@ -0,0 +1,43 @@
+package store
+
+import (
+ "testing"
+ "time"
+)
+
+func TestMemStore(t *testing.T) {
+ st := NewMemStore(0)
+ win := time.Second
+
+ // Reset stores a key with count of 1, current timestamp
+ err := st.Reset("k", time.Second)
+ if err != nil {
+ t.Errorf("expected reset to return nil, got %s", err)
+ }
+ cnt, sec1, _ := st.Incr("k", win)
+ if cnt != 2 {
+ t.Errorf("expected reset+incr to set count to 2, got %d", cnt)
+ }
+
+ // Incr increments the key, keeps same timestamp
+ cnt, sec2, err := st.Incr("k", win)
+ if err != nil {
+ t.Errorf("expected 2nd incr to return nil error, got %s", err)
+ }
+ if cnt != 3 {
+ t.Errorf("expected 2nd incr to return 3, got %d", cnt)
+ }
+ if sec1 != sec2 {
+ t.Errorf("expected 2nd incr to return %d secs, got %d", sec1, sec2)
+ }
+
+ // Reset on existing key brings it back to 1, new timestamp
+ err = st.Reset("k", win)
+ if err != nil {
+ t.Errorf("expected reset on existing key to return nil, got %s", err)
+ }
+ cnt, _, _ = st.Incr("k", win)
+ if cnt != 2 {
+ t.Errorf("expected last reset+incr to return 2, got %d", cnt)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/store/redis.go b/Godeps/_workspace/src/github.com/throttled/throttled/store/redis.go
new file mode 100644
index 000000000..6347eb6fc
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/store/redis.go
@@ -0,0 +1,85 @@
+package store
+
+import (
+ "time"
+
+ "github.com/garyburd/redigo/redis"
+ "github.com/throttled/throttled"
+)
+
+// redisStore implements a Redis-based store.
+type redisStore struct {
+ pool *redis.Pool
+ prefix string
+ db int
+}
+
+// NewRedisStore creates a new Redis-based store, using the provided pool to get its
+// connections. The keys will have the specified keyPrefix, which may be an empty string,
+// and the database index specified by db will be selected to store the keys.
+//
+func NewRedisStore(pool *redis.Pool, keyPrefix string, db int) throttled.Store {
+ return &redisStore{
+ pool: pool,
+ prefix: keyPrefix,
+ db: db,
+ }
+}
+
+// Incr increments the specified key. If the key did not exist, it sets it to 1
+// and sets it to expire after the number of seconds specified by window.
+//
+// It returns the new count value and the number of remaining seconds, or an error
+// if the operation fails.
+func (r *redisStore) Incr(key string, window time.Duration) (int, int, error) {
+ conn := r.pool.Get()
+ defer conn.Close()
+ if err := selectDB(r.db, conn); err != nil {
+ return 0, 0, err
+ }
+ // Atomically increment and read the TTL.
+ conn.Send("MULTI")
+ conn.Send("INCR", r.prefix+key)
+ conn.Send("TTL", r.prefix+key)
+ vals, err := redis.Values(conn.Do("EXEC"))
+ if err != nil {
+ conn.Do("DISCARD")
+ return 0, 0, err
+ }
+ var cnt, ttl int
+ if _, err = redis.Scan(vals, &cnt, &ttl); err != nil {
+ return 0, 0, err
+ }
+ // If there was no TTL set, then this is a newly created key (INCR creates the key
+ // if it didn't exist), so set it to expire.
+ if ttl == -1 {
+ ttl = int(window.Seconds())
+ _, err = conn.Do("EXPIRE", r.prefix+key, ttl)
+ if err != nil {
+ return 0, 0, err
+ }
+ }
+ return cnt, ttl, nil
+}
+
+// Reset sets the value of the key to 1, and resets its time window.
+func (r *redisStore) Reset(key string, window time.Duration) error {
+ conn := r.pool.Get()
+ defer conn.Close()
+ if err := selectDB(r.db, conn); err != nil {
+ return err
+ }
+ _, err := redis.String(conn.Do("SET", r.prefix+key, "1", "EX", int(window.Seconds()), "NX"))
+ return err
+}
+
+// Select the specified database index.
+func selectDB(db int, conn redis.Conn) error {
+ // Select the specified database
+ if db > 0 {
+ if _, err := redis.String(conn.Do("SELECT", db)); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/store/redis_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/store/redis_test.go
new file mode 100644
index 000000000..a282d6d25
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/store/redis_test.go
@@ -0,0 +1,66 @@
+package store
+
+import (
+ "testing"
+ "time"
+
+ "github.com/garyburd/redigo/redis"
+)
+
+func getPool() *redis.Pool {
+ pool := &redis.Pool{
+ MaxIdle: 3,
+ IdleTimeout: 30 * time.Second,
+ Dial: func() (redis.Conn, error) {
+ return redis.Dial("tcp", ":6379")
+ },
+ TestOnBorrow: func(c redis.Conn, t time.Time) error {
+ _, err := c.Do("PING")
+ return err
+ },
+ }
+ return pool
+}
+
+func TestRedisStore(t *testing.T) {
+ pool := getPool()
+ c := pool.Get()
+ if _, err := redis.String(c.Do("PING")); err != nil {
+ c.Close()
+ t.Skip("redis server not available on localhost port 6379")
+ }
+ st := NewRedisStore(pool, "throttled:", 1)
+ win := 2 * time.Second
+
+ // Incr increments the key, even if it does not exist
+ cnt, secs, err := st.Incr("k", win)
+ if err != nil {
+ t.Errorf("expected initial incr to return nil error, got %s", err)
+ }
+ if cnt != 1 {
+ t.Errorf("expected initial incr to return 1, got %d", cnt)
+ }
+ if secs != int(win.Seconds()) {
+ t.Errorf("expected initial incr to return %d secs, got %d", int(win.Seconds()), secs)
+ }
+
+ // Waiting a second diminishes the remaining seconds
+ time.Sleep(time.Second)
+ _, sec2, _ := st.Incr("k", win)
+ if sec2 != secs-1 {
+ t.Errorf("expected 2nd incr after a 1s sleep to return %d secs, got %d", secs-1, sec2)
+ }
+
+ // Waiting a second so the key expires, Incr should set back to 1, initial secs
+ time.Sleep(1100 * time.Millisecond)
+ cnt, sec3, err := st.Incr("k", win)
+ if err != nil {
+ t.Errorf("expected last incr to return nil error, got %s", err)
+ }
+ if cnt != 1 {
+ t.Errorf("expected last incr to return 1, got %d", cnt)
+ }
+ if sec3 != int(win.Seconds()) {
+ t.Errorf("expected last incr to return %d secs, got %d", int(win.Seconds()), sec3)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/throttler.go b/Godeps/_workspace/src/github.com/throttled/throttled/throttler.go
new file mode 100644
index 000000000..06da13051
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/throttler.go
@@ -0,0 +1,86 @@
+package throttled
+
+import (
+ "net/http"
+ "sync"
+)
+
+var (
+ // DefaultDeniedHandler handles the requests that were denied access because
+ // of a throttler. By default, returns a 429 status code with a
+ // generic message.
+ DefaultDeniedHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ http.Error(w, "limit exceeded", 429)
+ }))
+
+ // Error is the function to call when an error occurs on a throttled handler.
+ // By default, returns a 500 status code with a generic message.
+ Error = ErrorFunc(func(w http.ResponseWriter, r *http.Request, err error) {
+ http.Error(w, "internal error", http.StatusInternalServerError)
+ })
+)
+
+// ErrorFunc defines the function type for the Error variable.
+type ErrorFunc func(w http.ResponseWriter, r *http.Request, err error)
+
+// The Limiter interface defines the methods required to control access to a
+// throttled handler.
+type Limiter interface {
+ Start()
+ Limit(http.ResponseWriter, *http.Request) (<-chan bool, error)
+}
+
+// Custom creates a Throttler using the provided Limiter implementation.
+func Custom(l Limiter) *Throttler {
+ return &Throttler{
+ limiter: l,
+ }
+}
+
+// A Throttler controls access to HTTP handlers using a Limiter.
+type Throttler struct {
+ // DeniedHandler is called if the request is disallowed. If it is nil,
+ // the DefaultDeniedHandler variable is used.
+ DeniedHandler http.Handler
+
+ limiter Limiter
+ // The mutex protects the started flag
+ mu sync.Mutex
+ started bool
+}
+
+// Throttle wraps a HTTP handler so that its access is controlled by
+// the Throttler. It returns the Handler with the throttling logic.
+func (t *Throttler) Throttle(h http.Handler) http.Handler {
+ dh := t.start()
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ ch, err := t.limiter.Limit(w, r)
+ if err != nil {
+ Error(w, r, err)
+ return
+ }
+ ok := <-ch
+ if ok {
+ h.ServeHTTP(w, r)
+ } else {
+ dh.ServeHTTP(w, r)
+ }
+ })
+}
+
+// start starts the throttling and returns the effective denied handler to
+// use for requests that were denied access.
+func (t *Throttler) start() http.Handler {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ // Get the effective denied handler
+ dh := t.DeniedHandler
+ if dh == nil {
+ dh = DefaultDeniedHandler
+ }
+ if !t.started {
+ t.limiter.Start()
+ t.started = true
+ }
+ return dh
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/varyby.go b/Godeps/_workspace/src/github.com/throttled/throttled/varyby.go
new file mode 100644
index 000000000..3b2cdb011
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/varyby.go
@@ -0,0 +1,78 @@
+package throttled
+
+import (
+ "bytes"
+ "net/http"
+ "strings"
+)
+
+// VaryBy defines the criteria to use to group requests.
+type VaryBy struct {
+ // Vary by the RemoteAddr as specified by the net/http.Request field.
+ RemoteAddr bool
+
+ // Vary by the HTTP Method as specified by the net/http.Request field.
+ Method bool
+
+ // Vary by the URL's Path as specified by the Path field of the net/http.Request
+ // URL field.
+ Path bool
+
+ // Vary by this list of header names, read from the net/http.Request Header field.
+ Headers []string
+
+ // Vary by this list of parameters, read from the net/http.Request FormValue method.
+ Params []string
+
+ // Vary by this list of cookie names, read from the net/http.Request Cookie method.
+ Cookies []string
+
+ // Use this separator string to concatenate the various criteria of the VaryBy struct.
+ // Defaults to a newline character if empty (\n).
+ Separator string
+
+ // Custom specifies the custom-generated key to use for this request.
+ // If not nil, the value returned by this function is used instead of any
+ // VaryBy criteria.
+ Custom func(r *http.Request) string
+}
+
+// Key returns the key for this request based on the criteria defined by the VaryBy struct.
+func (vb *VaryBy) Key(r *http.Request) string {
+ var buf bytes.Buffer
+
+ if vb == nil {
+ return "" // Special case for no vary-by option
+ }
+ if vb.Custom != nil {
+ // A custom key generator is specified
+ return vb.Custom(r)
+ }
+ sep := vb.Separator
+ if sep == "" {
+ sep = "\n" // Separator defaults to newline
+ }
+ if vb.RemoteAddr {
+ buf.WriteString(strings.ToLower(r.RemoteAddr) + sep)
+ }
+ if vb.Method {
+ buf.WriteString(strings.ToLower(r.Method) + sep)
+ }
+ for _, h := range vb.Headers {
+ buf.WriteString(strings.ToLower(r.Header.Get(h)) + sep)
+ }
+ if vb.Path {
+ buf.WriteString(r.URL.Path + sep)
+ }
+ for _, p := range vb.Params {
+ buf.WriteString(r.FormValue(p) + sep)
+ }
+ for _, c := range vb.Cookies {
+ ck, err := r.Cookie(c)
+ if err == nil {
+ buf.WriteString(ck.Value)
+ }
+ buf.WriteString(sep) // Write the separator anyway, whether or not the cookie exists
+ }
+ return buf.String()
+}
diff --git a/Godeps/_workspace/src/github.com/throttled/throttled/varyby_test.go b/Godeps/_workspace/src/github.com/throttled/throttled/varyby_test.go
new file mode 100644
index 000000000..91b7ae0ae
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/throttled/throttled/varyby_test.go
@@ -0,0 +1,56 @@
+package throttled
+
+import (
+ "net/http"
+ "net/url"
+ "testing"
+)
+
+func TestVaryBy(t *testing.T) {
+ u, err := url.Parse("http://localhost/test/path?q=s")
+ if err != nil {
+ panic(err)
+ }
+ ck := &http.Cookie{Name: "ssn", Value: "test"}
+ cases := []struct {
+ vb *VaryBy
+ r *http.Request
+ k string
+ }{
+ 0: {nil, &http.Request{}, ""},
+ 1: {&VaryBy{RemoteAddr: true}, &http.Request{RemoteAddr: "::"}, "::\n"},
+ 2: {
+ &VaryBy{Method: true, Path: true},
+ &http.Request{Method: "POST", URL: u},
+ "post\n/test/path\n",
+ },
+ 3: {
+ &VaryBy{Headers: []string{"Content-length"}},
+ &http.Request{Header: http.Header{"Content-Type": []string{"text/plain"}, "Content-Length": []string{"123"}}},
+ "123\n",
+ },
+ 4: {
+ &VaryBy{Separator: ",", Method: true, Headers: []string{"Content-length"}, Params: []string{"q", "user"}},
+ &http.Request{Method: "GET", Header: http.Header{"Content-Type": []string{"text/plain"}, "Content-Length": []string{"123"}}, Form: url.Values{"q": []string{"s"}, "pwd": []string{"secret"}, "user": []string{"test"}}},
+ "get,123,s,test,",
+ },
+ 5: {
+ &VaryBy{Cookies: []string{"ssn"}},
+ &http.Request{Header: http.Header{"Cookie": []string{ck.String()}}},
+ "test\n",
+ },
+ 6: {
+ &VaryBy{Cookies: []string{"ssn"}, RemoteAddr: true, Custom: func(r *http.Request) string {
+ return "blah"
+ }},
+ &http.Request{Header: http.Header{"Cookie": []string{ck.String()}}},
+ "blah",
+ },
+ }
+ for i, c := range cases {
+ got := c.vb.Key(c.r)
+ if got != c.k {
+ t.Errorf("%d: expected '%s' (%d), got '%s' (%d)", i, c.k, len(c.k), got, len(got))
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/.travis.yml b/Godeps/_workspace/src/gopkg.in/bufio.v1/.travis.yml
deleted file mode 100644
index ccca6bb4a..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: go
-
-go:
- - 1.0
- - 1.1
- - 1.2
- - tip
-
-install:
- - go get launchpad.net/gocheck
- - go get gopkg.in/bufio.v1
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/LICENSE b/Godeps/_workspace/src/gopkg.in/bufio.v1/LICENSE
deleted file mode 100644
index 07a316cbf..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2013 The bufio Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/Makefile b/Godeps/_workspace/src/gopkg.in/bufio.v1/Makefile
deleted file mode 100644
index 038ed47e9..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-all:
- go test gopkg.in/bufio.v1
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/README.md b/Godeps/_workspace/src/gopkg.in/bufio.v1/README.md
deleted file mode 100644
index bfb85ee54..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-bufio
-=====
-
-This is a fork of the http://golang.org/pkg/bufio/ package. It adds `ReadN` method that allows reading next `n` bytes from the internal buffer without allocating intermediate buffer. This method works just like the [Buffer.Next](http://golang.org/pkg/bytes/#Buffer.Next) method, but has slightly different signature.
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/buffer.go b/Godeps/_workspace/src/gopkg.in/bufio.v1/buffer.go
deleted file mode 100644
index 8b915605b..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/buffer.go
+++ /dev/null
@@ -1,413 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bufio
-
-// Simple byte buffer for marshaling data.
-
-import (
- "bytes"
- "errors"
- "io"
- "unicode/utf8"
-)
-
-// A Buffer is a variable-sized buffer of bytes with Read and Write methods.
-// The zero value for Buffer is an empty buffer ready to use.
-type Buffer struct {
- buf []byte // contents are the bytes buf[off : len(buf)]
- off int // read at &buf[off], write at &buf[len(buf)]
- runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each WriteByte or Rune
- bootstrap [64]byte // memory to hold first slice; helps small buffers (Printf) avoid allocation.
- lastRead readOp // last read operation, so that Unread* can work correctly.
-}
-
-// The readOp constants describe the last action performed on
-// the buffer, so that UnreadRune and UnreadByte can
-// check for invalid usage.
-type readOp int
-
-const (
- opInvalid readOp = iota // Non-read operation.
- opReadRune // Read rune.
- opRead // Any other read operation.
-)
-
-// ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.
-var ErrTooLarge = errors.New("bytes.Buffer: too large")
-
-// Bytes returns a slice of the contents of the unread portion of the buffer;
-// len(b.Bytes()) == b.Len(). If the caller changes the contents of the
-// returned slice, the contents of the buffer will change provided there
-// are no intervening method calls on the Buffer.
-func (b *Buffer) Bytes() []byte { return b.buf[b.off:] }
-
-// String returns the contents of the unread portion of the buffer
-// as a string. If the Buffer is a nil pointer, it returns "<nil>".
-func (b *Buffer) String() string {
- if b == nil {
- // Special case, useful in debugging.
- return "<nil>"
- }
- return string(b.buf[b.off:])
-}
-
-// Len returns the number of bytes of the unread portion of the buffer;
-// b.Len() == len(b.Bytes()).
-func (b *Buffer) Len() int { return len(b.buf) - b.off }
-
-// Truncate discards all but the first n unread bytes from the buffer.
-// It panics if n is negative or greater than the length of the buffer.
-func (b *Buffer) Truncate(n int) {
- b.lastRead = opInvalid
- switch {
- case n < 0 || n > b.Len():
- panic("bytes.Buffer: truncation out of range")
- case n == 0:
- // Reuse buffer space.
- b.off = 0
- }
- b.buf = b.buf[0 : b.off+n]
-}
-
-// Reset resets the buffer so it has no content.
-// b.Reset() is the same as b.Truncate(0).
-func (b *Buffer) Reset() { b.Truncate(0) }
-
-// grow grows the buffer to guarantee space for n more bytes.
-// It returns the index where bytes should be written.
-// If the buffer can't grow it will panic with ErrTooLarge.
-func (b *Buffer) grow(n int) int {
- m := b.Len()
- // If buffer is empty, reset to recover space.
- if m == 0 && b.off != 0 {
- b.Truncate(0)
- }
- if len(b.buf)+n > cap(b.buf) {
- var buf []byte
- if b.buf == nil && n <= len(b.bootstrap) {
- buf = b.bootstrap[0:]
- } else if m+n <= cap(b.buf)/2 {
- // We can slide things down instead of allocating a new
- // slice. We only need m+n <= cap(b.buf) to slide, but
- // we instead let capacity get twice as large so we
- // don't spend all our time copying.
- copy(b.buf[:], b.buf[b.off:])
- buf = b.buf[:m]
- } else {
- // not enough space anywhere
- buf = makeSlice(2*cap(b.buf) + n)
- copy(buf, b.buf[b.off:])
- }
- b.buf = buf
- b.off = 0
- }
- b.buf = b.buf[0 : b.off+m+n]
- return b.off + m
-}
-
-// Grow grows the buffer's capacity, if necessary, to guarantee space for
-// another n bytes. After Grow(n), at least n bytes can be written to the
-// buffer without another allocation.
-// If n is negative, Grow will panic.
-// If the buffer can't grow it will panic with ErrTooLarge.
-func (b *Buffer) Grow(n int) {
- if n < 0 {
- panic("bytes.Buffer.Grow: negative count")
- }
- m := b.grow(n)
- b.buf = b.buf[0:m]
-}
-
-// Write appends the contents of p to the buffer, growing the buffer as
-// needed. The return value n is the length of p; err is always nil. If the
-// buffer becomes too large, Write will panic with ErrTooLarge.
-func (b *Buffer) Write(p []byte) (n int, err error) {
- b.lastRead = opInvalid
- m := b.grow(len(p))
- return copy(b.buf[m:], p), nil
-}
-
-// WriteString appends the contents of s to the buffer, growing the buffer as
-// needed. The return value n is the length of s; err is always nil. If the
-// buffer becomes too large, WriteString will panic with ErrTooLarge.
-func (b *Buffer) WriteString(s string) (n int, err error) {
- b.lastRead = opInvalid
- m := b.grow(len(s))
- return copy(b.buf[m:], s), nil
-}
-
-// MinRead is the minimum slice size passed to a Read call by
-// Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond
-// what is required to hold the contents of r, ReadFrom will not grow the
-// underlying buffer.
-const MinRead = 512
-
-// ReadFrom reads data from r until EOF and appends it to the buffer, growing
-// the buffer as needed. The return value n is the number of bytes read. Any
-// error except io.EOF encountered during the read is also returned. If the
-// buffer becomes too large, ReadFrom will panic with ErrTooLarge.
-func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
- b.lastRead = opInvalid
- // If buffer is empty, reset to recover space.
- if b.off >= len(b.buf) {
- b.Truncate(0)
- }
- for {
- if free := cap(b.buf) - len(b.buf); free < MinRead {
- // not enough space at end
- newBuf := b.buf
- if b.off+free < MinRead {
- // not enough space using beginning of buffer;
- // double buffer capacity
- newBuf = makeSlice(2*cap(b.buf) + MinRead)
- }
- copy(newBuf, b.buf[b.off:])
- b.buf = newBuf[:len(b.buf)-b.off]
- b.off = 0
- }
- m, e := r.Read(b.buf[len(b.buf):cap(b.buf)])
- b.buf = b.buf[0 : len(b.buf)+m]
- n += int64(m)
- if e == io.EOF {
- break
- }
- if e != nil {
- return n, e
- }
- }
- return n, nil // err is EOF, so return nil explicitly
-}
-
-// makeSlice allocates a slice of size n. If the allocation fails, it panics
-// with ErrTooLarge.
-func makeSlice(n int) []byte {
- // If the make fails, give a known error.
- defer func() {
- if recover() != nil {
- panic(ErrTooLarge)
- }
- }()
- return make([]byte, n)
-}
-
-// WriteTo writes data to w until the buffer is drained or an error occurs.
-// The return value n is the number of bytes written; it always fits into an
-// int, but it is int64 to match the io.WriterTo interface. Any error
-// encountered during the write is also returned.
-func (b *Buffer) WriteTo(w io.Writer) (n int64, err error) {
- b.lastRead = opInvalid
- if b.off < len(b.buf) {
- nBytes := b.Len()
- m, e := w.Write(b.buf[b.off:])
- if m > nBytes {
- panic("bytes.Buffer.WriteTo: invalid Write count")
- }
- b.off += m
- n = int64(m)
- if e != nil {
- return n, e
- }
- // all bytes should have been written, by definition of
- // Write method in io.Writer
- if m != nBytes {
- return n, io.ErrShortWrite
- }
- }
- // Buffer is now empty; reset.
- b.Truncate(0)
- return
-}
-
-// WriteByte appends the byte c to the buffer, growing the buffer as needed.
-// The returned error is always nil, but is included to match bufio.Writer's
-// WriteByte. If the buffer becomes too large, WriteByte will panic with
-// ErrTooLarge.
-func (b *Buffer) WriteByte(c byte) error {
- b.lastRead = opInvalid
- m := b.grow(1)
- b.buf[m] = c
- return nil
-}
-
-// WriteRune appends the UTF-8 encoding of Unicode code point r to the
-// buffer, returning its length and an error, which is always nil but is
-// included to match bufio.Writer's WriteRune. The buffer is grown as needed;
-// if it becomes too large, WriteRune will panic with ErrTooLarge.
-func (b *Buffer) WriteRune(r rune) (n int, err error) {
- if r < utf8.RuneSelf {
- b.WriteByte(byte(r))
- return 1, nil
- }
- n = utf8.EncodeRune(b.runeBytes[0:], r)
- b.Write(b.runeBytes[0:n])
- return n, nil
-}
-
-// Read reads the next len(p) bytes from the buffer or until the buffer
-// is drained. The return value n is the number of bytes read. If the
-// buffer has no data to return, err is io.EOF (unless len(p) is zero);
-// otherwise it is nil.
-func (b *Buffer) Read(p []byte) (n int, err error) {
- b.lastRead = opInvalid
- if b.off >= len(b.buf) {
- // Buffer is empty, reset to recover space.
- b.Truncate(0)
- if len(p) == 0 {
- return
- }
- return 0, io.EOF
- }
- n = copy(p, b.buf[b.off:])
- b.off += n
- if n > 0 {
- b.lastRead = opRead
- }
- return
-}
-
-// Next returns a slice containing the next n bytes from the buffer,
-// advancing the buffer as if the bytes had been returned by Read.
-// If there are fewer than n bytes in the buffer, Next returns the entire buffer.
-// The slice is only valid until the next call to a read or write method.
-func (b *Buffer) Next(n int) []byte {
- b.lastRead = opInvalid
- m := b.Len()
- if n > m {
- n = m
- }
- data := b.buf[b.off : b.off+n]
- b.off += n
- if n > 0 {
- b.lastRead = opRead
- }
- return data
-}
-
-// ReadByte reads and returns the next byte from the buffer.
-// If no byte is available, it returns error io.EOF.
-func (b *Buffer) ReadByte() (c byte, err error) {
- b.lastRead = opInvalid
- if b.off >= len(b.buf) {
- // Buffer is empty, reset to recover space.
- b.Truncate(0)
- return 0, io.EOF
- }
- c = b.buf[b.off]
- b.off++
- b.lastRead = opRead
- return c, nil
-}
-
-// ReadRune reads and returns the next UTF-8-encoded
-// Unicode code point from the buffer.
-// If no bytes are available, the error returned is io.EOF.
-// If the bytes are an erroneous UTF-8 encoding, it
-// consumes one byte and returns U+FFFD, 1.
-func (b *Buffer) ReadRune() (r rune, size int, err error) {
- b.lastRead = opInvalid
- if b.off >= len(b.buf) {
- // Buffer is empty, reset to recover space.
- b.Truncate(0)
- return 0, 0, io.EOF
- }
- b.lastRead = opReadRune
- c := b.buf[b.off]
- if c < utf8.RuneSelf {
- b.off++
- return rune(c), 1, nil
- }
- r, n := utf8.DecodeRune(b.buf[b.off:])
- b.off += n
- return r, n, nil
-}
-
-// UnreadRune unreads the last rune returned by ReadRune.
-// If the most recent read or write operation on the buffer was
-// not a ReadRune, UnreadRune returns an error. (In this regard
-// it is stricter than UnreadByte, which will unread the last byte
-// from any read operation.)
-func (b *Buffer) UnreadRune() error {
- if b.lastRead != opReadRune {
- return errors.New("bytes.Buffer: UnreadRune: previous operation was not ReadRune")
- }
- b.lastRead = opInvalid
- if b.off > 0 {
- _, n := utf8.DecodeLastRune(b.buf[0:b.off])
- b.off -= n
- }
- return nil
-}
-
-// UnreadByte unreads the last byte returned by the most recent
-// read operation. If write has happened since the last read, UnreadByte
-// returns an error.
-func (b *Buffer) UnreadByte() error {
- if b.lastRead != opReadRune && b.lastRead != opRead {
- return errors.New("bytes.Buffer: UnreadByte: previous operation was not a read")
- }
- b.lastRead = opInvalid
- if b.off > 0 {
- b.off--
- }
- return nil
-}
-
-// ReadBytes reads until the first occurrence of delim in the input,
-// returning a slice containing the data up to and including the delimiter.
-// If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often io.EOF).
-// ReadBytes returns err != nil if and only if the returned data does not end in
-// delim.
-func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
- slice, err := b.readSlice(delim)
- // return a copy of slice. The buffer's backing array may
- // be overwritten by later calls.
- line = append(line, slice...)
- return
-}
-
-// readSlice is like ReadBytes but returns a reference to internal buffer data.
-func (b *Buffer) readSlice(delim byte) (line []byte, err error) {
- i := bytes.IndexByte(b.buf[b.off:], delim)
- end := b.off + i + 1
- if i < 0 {
- end = len(b.buf)
- err = io.EOF
- }
- line = b.buf[b.off:end]
- b.off = end
- b.lastRead = opRead
- return line, err
-}
-
-// ReadString reads until the first occurrence of delim in the input,
-// returning a string containing the data up to and including the delimiter.
-// If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often io.EOF).
-// ReadString returns err != nil if and only if the returned data does not end
-// in delim.
-func (b *Buffer) ReadString(delim byte) (line string, err error) {
- slice, err := b.readSlice(delim)
- return string(slice), err
-}
-
-// NewBuffer creates and initializes a new Buffer using buf as its initial
-// contents. It is intended to prepare a Buffer to read existing data. It
-// can also be used to size the internal buffer for writing. To do that,
-// buf should have the desired capacity but a length of zero.
-//
-// In most cases, new(Buffer) (or just declaring a Buffer variable) is
-// sufficient to initialize a Buffer.
-func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} }
-
-// NewBufferString creates and initializes a new Buffer using string s as its
-// initial contents. It is intended to prepare a buffer to read an existing
-// string.
-//
-// In most cases, new(Buffer) (or just declaring a Buffer variable) is
-// sufficient to initialize a Buffer.
-func NewBufferString(s string) *Buffer {
- return &Buffer{buf: []byte(s)}
-}
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/buffer_test.go b/Godeps/_workspace/src/gopkg.in/bufio.v1/buffer_test.go
deleted file mode 100644
index ca1ac2105..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/buffer_test.go
+++ /dev/null
@@ -1,527 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bufio
-
-import (
- "bytes"
- "io"
- "math/rand"
- "runtime"
- "testing"
- "unicode/utf8"
-)
-
-const N = 10000 // make this bigger for a larger (and slower) test
-var data string // test data for write tests
-var testBytes []byte // test data; same as data but as a slice.
-
-func init() {
- testBytes = make([]byte, N)
- for i := 0; i < N; i++ {
- testBytes[i] = 'a' + byte(i%26)
- }
- data = string(testBytes)
-}
-
-// Verify that contents of buf match the string s.
-func check(t *testing.T, testname string, buf *Buffer, s string) {
- bytes := buf.Bytes()
- str := buf.String()
- if buf.Len() != len(bytes) {
- t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d", testname, buf.Len(), len(bytes))
- }
-
- if buf.Len() != len(str) {
- t.Errorf("%s: buf.Len() == %d, len(buf.String()) == %d", testname, buf.Len(), len(str))
- }
-
- if buf.Len() != len(s) {
- t.Errorf("%s: buf.Len() == %d, len(s) == %d", testname, buf.Len(), len(s))
- }
-
- if string(bytes) != s {
- t.Errorf("%s: string(buf.Bytes()) == %q, s == %q", testname, string(bytes), s)
- }
-}
-
-// Fill buf through n writes of string fus.
-// The initial contents of buf corresponds to the string s;
-// the result is the final contents of buf returned as a string.
-func fillString(t *testing.T, testname string, buf *Buffer, s string, n int, fus string) string {
- check(t, testname+" (fill 1)", buf, s)
- for ; n > 0; n-- {
- m, err := buf.WriteString(fus)
- if m != len(fus) {
- t.Errorf(testname+" (fill 2): m == %d, expected %d", m, len(fus))
- }
- if err != nil {
- t.Errorf(testname+" (fill 3): err should always be nil, found err == %s", err)
- }
- s += fus
- check(t, testname+" (fill 4)", buf, s)
- }
- return s
-}
-
-// Fill buf through n writes of byte slice fub.
-// The initial contents of buf corresponds to the string s;
-// the result is the final contents of buf returned as a string.
-func fillBytes(t *testing.T, testname string, buf *Buffer, s string, n int, fub []byte) string {
- check(t, testname+" (fill 1)", buf, s)
- for ; n > 0; n-- {
- m, err := buf.Write(fub)
- if m != len(fub) {
- t.Errorf(testname+" (fill 2): m == %d, expected %d", m, len(fub))
- }
- if err != nil {
- t.Errorf(testname+" (fill 3): err should always be nil, found err == %s", err)
- }
- s += string(fub)
- check(t, testname+" (fill 4)", buf, s)
- }
- return s
-}
-
-func TestNewBuffer(t *testing.T) {
- buf := NewBuffer(testBytes)
- check(t, "NewBuffer", buf, data)
-}
-
-func TestNewBufferString(t *testing.T) {
- buf := NewBufferString(data)
- check(t, "NewBufferString", buf, data)
-}
-
-// Empty buf through repeated reads into fub.
-// The initial contents of buf corresponds to the string s.
-func empty(t *testing.T, testname string, buf *Buffer, s string, fub []byte) {
- check(t, testname+" (empty 1)", buf, s)
-
- for {
- n, err := buf.Read(fub)
- if n == 0 {
- break
- }
- if err != nil {
- t.Errorf(testname+" (empty 2): err should always be nil, found err == %s", err)
- }
- s = s[n:]
- check(t, testname+" (empty 3)", buf, s)
- }
-
- check(t, testname+" (empty 4)", buf, "")
-}
-
-func TestBasicOperations(t *testing.T) {
- var buf Buffer
-
- for i := 0; i < 5; i++ {
- check(t, "TestBasicOperations (1)", &buf, "")
-
- buf.Reset()
- check(t, "TestBasicOperations (2)", &buf, "")
-
- buf.Truncate(0)
- check(t, "TestBasicOperations (3)", &buf, "")
-
- n, err := buf.Write([]byte(data[0:1]))
- if n != 1 {
- t.Errorf("wrote 1 byte, but n == %d", n)
- }
- if err != nil {
- t.Errorf("err should always be nil, but err == %s", err)
- }
- check(t, "TestBasicOperations (4)", &buf, "a")
-
- buf.WriteByte(data[1])
- check(t, "TestBasicOperations (5)", &buf, "ab")
-
- n, err = buf.Write([]byte(data[2:26]))
- if n != 24 {
- t.Errorf("wrote 25 bytes, but n == %d", n)
- }
- check(t, "TestBasicOperations (6)", &buf, string(data[0:26]))
-
- buf.Truncate(26)
- check(t, "TestBasicOperations (7)", &buf, string(data[0:26]))
-
- buf.Truncate(20)
- check(t, "TestBasicOperations (8)", &buf, string(data[0:20]))
-
- empty(t, "TestBasicOperations (9)", &buf, string(data[0:20]), make([]byte, 5))
- empty(t, "TestBasicOperations (10)", &buf, "", make([]byte, 100))
-
- buf.WriteByte(data[1])
- c, err := buf.ReadByte()
- if err != nil {
- t.Error("ReadByte unexpected eof")
- }
- if c != data[1] {
- t.Errorf("ReadByte wrong value c=%v", c)
- }
- c, err = buf.ReadByte()
- if err == nil {
- t.Error("ReadByte unexpected not eof")
- }
- }
-}
-
-func TestLargeStringWrites(t *testing.T) {
- var buf Buffer
- limit := 30
- if testing.Short() {
- limit = 9
- }
- for i := 3; i < limit; i += 3 {
- s := fillString(t, "TestLargeWrites (1)", &buf, "", 5, data)
- empty(t, "TestLargeStringWrites (2)", &buf, s, make([]byte, len(data)/i))
- }
- check(t, "TestLargeStringWrites (3)", &buf, "")
-}
-
-func TestLargeByteWrites(t *testing.T) {
- var buf Buffer
- limit := 30
- if testing.Short() {
- limit = 9
- }
- for i := 3; i < limit; i += 3 {
- s := fillBytes(t, "TestLargeWrites (1)", &buf, "", 5, testBytes)
- empty(t, "TestLargeByteWrites (2)", &buf, s, make([]byte, len(data)/i))
- }
- check(t, "TestLargeByteWrites (3)", &buf, "")
-}
-
-func TestLargeStringReads(t *testing.T) {
- var buf Buffer
- for i := 3; i < 30; i += 3 {
- s := fillString(t, "TestLargeReads (1)", &buf, "", 5, data[0:len(data)/i])
- empty(t, "TestLargeReads (2)", &buf, s, make([]byte, len(data)))
- }
- check(t, "TestLargeStringReads (3)", &buf, "")
-}
-
-func TestLargeByteReads(t *testing.T) {
- var buf Buffer
- for i := 3; i < 30; i += 3 {
- s := fillBytes(t, "TestLargeReads (1)", &buf, "", 5, testBytes[0:len(testBytes)/i])
- empty(t, "TestLargeReads (2)", &buf, s, make([]byte, len(data)))
- }
- check(t, "TestLargeByteReads (3)", &buf, "")
-}
-
-func TestMixedReadsAndWrites(t *testing.T) {
- var buf Buffer
- s := ""
- for i := 0; i < 50; i++ {
- wlen := rand.Intn(len(data))
- if i%2 == 0 {
- s = fillString(t, "TestMixedReadsAndWrites (1)", &buf, s, 1, data[0:wlen])
- } else {
- s = fillBytes(t, "TestMixedReadsAndWrites (1)", &buf, s, 1, testBytes[0:wlen])
- }
-
- rlen := rand.Intn(len(data))
- fub := make([]byte, rlen)
- n, _ := buf.Read(fub)
- s = s[n:]
- }
- empty(t, "TestMixedReadsAndWrites (2)", &buf, s, make([]byte, buf.Len()))
-}
-
-func TestNil(t *testing.T) {
- var b *Buffer
- if b.String() != "<nil>" {
- t.Errorf("expected <nil>; got %q", b.String())
- }
-}
-
-func TestReadFrom(t *testing.T) {
- var buf Buffer
- for i := 3; i < 30; i += 3 {
- s := fillBytes(t, "TestReadFrom (1)", &buf, "", 5, testBytes[0:len(testBytes)/i])
- var b Buffer
- b.ReadFrom(&buf)
- empty(t, "TestReadFrom (2)", &b, s, make([]byte, len(data)))
- }
-}
-
-func TestWriteTo(t *testing.T) {
- var buf Buffer
- for i := 3; i < 30; i += 3 {
- s := fillBytes(t, "TestWriteTo (1)", &buf, "", 5, testBytes[0:len(testBytes)/i])
- var b Buffer
- buf.WriteTo(&b)
- empty(t, "TestWriteTo (2)", &b, s, make([]byte, len(data)))
- }
-}
-
-func TestRuneIO(t *testing.T) {
- const NRune = 1000
- // Built a test slice while we write the data
- b := make([]byte, utf8.UTFMax*NRune)
- var buf Buffer
- n := 0
- for r := rune(0); r < NRune; r++ {
- size := utf8.EncodeRune(b[n:], r)
- nbytes, err := buf.WriteRune(r)
- if err != nil {
- t.Fatalf("WriteRune(%U) error: %s", r, err)
- }
- if nbytes != size {
- t.Fatalf("WriteRune(%U) expected %d, got %d", r, size, nbytes)
- }
- n += size
- }
- b = b[0:n]
-
- // Check the resulting bytes
- if !bytes.Equal(buf.Bytes(), b) {
- t.Fatalf("incorrect result from WriteRune: %q not %q", buf.Bytes(), b)
- }
-
- p := make([]byte, utf8.UTFMax)
- // Read it back with ReadRune
- for r := rune(0); r < NRune; r++ {
- size := utf8.EncodeRune(p, r)
- nr, nbytes, err := buf.ReadRune()
- if nr != r || nbytes != size || err != nil {
- t.Fatalf("ReadRune(%U) got %U,%d not %U,%d (err=%s)", r, nr, nbytes, r, size, err)
- }
- }
-
- // Check that UnreadRune works
- buf.Reset()
- buf.Write(b)
- for r := rune(0); r < NRune; r++ {
- r1, size, _ := buf.ReadRune()
- if err := buf.UnreadRune(); err != nil {
- t.Fatalf("UnreadRune(%U) got error %q", r, err)
- }
- r2, nbytes, err := buf.ReadRune()
- if r1 != r2 || r1 != r || nbytes != size || err != nil {
- t.Fatalf("ReadRune(%U) after UnreadRune got %U,%d not %U,%d (err=%s)", r, r2, nbytes, r, size, err)
- }
- }
-}
-
-func TestNext(t *testing.T) {
- b := []byte{0, 1, 2, 3, 4}
- tmp := make([]byte, 5)
- for i := 0; i <= 5; i++ {
- for j := i; j <= 5; j++ {
- for k := 0; k <= 6; k++ {
- // 0 <= i <= j <= 5; 0 <= k <= 6
- // Check that if we start with a buffer
- // of length j at offset i and ask for
- // Next(k), we get the right bytes.
- buf := NewBuffer(b[0:j])
- n, _ := buf.Read(tmp[0:i])
- if n != i {
- t.Fatalf("Read %d returned %d", i, n)
- }
- bb := buf.Next(k)
- want := k
- if want > j-i {
- want = j - i
- }
- if len(bb) != want {
- t.Fatalf("in %d,%d: len(Next(%d)) == %d", i, j, k, len(bb))
- }
- for l, v := range bb {
- if v != byte(l+i) {
- t.Fatalf("in %d,%d: Next(%d)[%d] = %d, want %d", i, j, k, l, v, l+i)
- }
- }
- }
- }
- }
-}
-
-var readBytesTests = []struct {
- buffer string
- delim byte
- expected []string
- err error
-}{
- {"", 0, []string{""}, io.EOF},
- {"a\x00", 0, []string{"a\x00"}, nil},
- {"abbbaaaba", 'b', []string{"ab", "b", "b", "aaab"}, nil},
- {"hello\x01world", 1, []string{"hello\x01"}, nil},
- {"foo\nbar", 0, []string{"foo\nbar"}, io.EOF},
- {"alpha\nbeta\ngamma\n", '\n', []string{"alpha\n", "beta\n", "gamma\n"}, nil},
- {"alpha\nbeta\ngamma", '\n', []string{"alpha\n", "beta\n", "gamma"}, io.EOF},
-}
-
-func TestReadBytes(t *testing.T) {
- for _, test := range readBytesTests {
- buf := NewBufferString(test.buffer)
- var err error
- for _, expected := range test.expected {
- var bytes []byte
- bytes, err = buf.ReadBytes(test.delim)
- if string(bytes) != expected {
- t.Errorf("expected %q, got %q", expected, bytes)
- }
- if err != nil {
- break
- }
- }
- if err != test.err {
- t.Errorf("expected error %v, got %v", test.err, err)
- }
- }
-}
-
-func TestReadString(t *testing.T) {
- for _, test := range readBytesTests {
- buf := NewBufferString(test.buffer)
- var err error
- for _, expected := range test.expected {
- var s string
- s, err = buf.ReadString(test.delim)
- if s != expected {
- t.Errorf("expected %q, got %q", expected, s)
- }
- if err != nil {
- break
- }
- }
- if err != test.err {
- t.Errorf("expected error %v, got %v", test.err, err)
- }
- }
-}
-
-func BenchmarkReadString(b *testing.B) {
- const n = 32 << 10
-
- data := make([]byte, n)
- data[n-1] = 'x'
- b.SetBytes(int64(n))
- for i := 0; i < b.N; i++ {
- buf := NewBuffer(data)
- _, err := buf.ReadString('x')
- if err != nil {
- b.Fatal(err)
- }
- }
-}
-
-func TestGrow(t *testing.T) {
- x := []byte{'x'}
- y := []byte{'y'}
- tmp := make([]byte, 72)
- for _, startLen := range []int{0, 100, 1000, 10000, 100000} {
- xBytes := bytes.Repeat(x, startLen)
- for _, growLen := range []int{0, 100, 1000, 10000, 100000} {
- buf := NewBuffer(xBytes)
- // If we read, this affects buf.off, which is good to test.
- readBytes, _ := buf.Read(tmp)
- buf.Grow(growLen)
- yBytes := bytes.Repeat(y, growLen)
- // Check no allocation occurs in write, as long as we're single-threaded.
- var m1, m2 runtime.MemStats
- runtime.ReadMemStats(&m1)
- buf.Write(yBytes)
- runtime.ReadMemStats(&m2)
- if runtime.GOMAXPROCS(-1) == 1 && m1.Mallocs != m2.Mallocs {
- t.Errorf("allocation occurred during write")
- }
- // Check that buffer has correct data.
- if !bytes.Equal(buf.Bytes()[0:startLen-readBytes], xBytes[readBytes:]) {
- t.Errorf("bad initial data at %d %d", startLen, growLen)
- }
- if !bytes.Equal(buf.Bytes()[startLen-readBytes:startLen-readBytes+growLen], yBytes) {
- t.Errorf("bad written data at %d %d", startLen, growLen)
- }
- }
- }
-}
-
-// Was a bug: used to give EOF reading empty slice at EOF.
-func TestReadEmptyAtEOF(t *testing.T) {
- b := new(Buffer)
- slice := make([]byte, 0)
- n, err := b.Read(slice)
- if err != nil {
- t.Errorf("read error: %v", err)
- }
- if n != 0 {
- t.Errorf("wrong count; got %d want 0", n)
- }
-}
-
-func TestBufferUnreadByte(t *testing.T) {
- b := new(Buffer)
- b.WriteString("abcdefghijklmnopqrstuvwxyz")
-
- _, err := b.ReadBytes('m')
- if err != nil {
- t.Fatalf("ReadBytes: %v", err)
- }
-
- err = b.UnreadByte()
- if err != nil {
- t.Fatalf("UnreadByte: %v", err)
- }
- c, err := b.ReadByte()
- if err != nil {
- t.Fatalf("ReadByte: %v", err)
- }
- if c != 'm' {
- t.Errorf("ReadByte = %q; want %q", c, 'm')
- }
-}
-
-// Tests that we occasionally compact. Issue 5154.
-func TestBufferGrowth(t *testing.T) {
- var b Buffer
- buf := make([]byte, 1024)
- b.Write(buf[0:1])
- var cap0 int
- for i := 0; i < 5<<10; i++ {
- b.Write(buf)
- b.Read(buf)
- if i == 0 {
- cap0 = b.Cap()
- }
- }
- cap1 := b.Cap()
- // (*Buffer).grow allows for 2x capacity slop before sliding,
- // so set our error threshold at 3x.
- if cap1 > cap0*3 {
- t.Errorf("buffer cap = %d; too big (grew from %d)", cap1, cap0)
- }
-}
-
-// From Issue 5154.
-func BenchmarkBufferNotEmptyWriteRead(b *testing.B) {
- buf := make([]byte, 1024)
- for i := 0; i < b.N; i++ {
- var b Buffer
- b.Write(buf[0:1])
- for i := 0; i < 5<<10; i++ {
- b.Write(buf)
- b.Read(buf)
- }
- }
-}
-
-// Check that we don't compact too often. From Issue 5154.
-func BenchmarkBufferFullSmallReads(b *testing.B) {
- buf := make([]byte, 1024)
- for i := 0; i < b.N; i++ {
- var b Buffer
- b.Write(buf)
- for b.Len()+20 < b.Cap() {
- b.Write(buf[:10])
- }
- for i := 0; i < 5<<10; i++ {
- b.Read(buf[:1])
- b.Write(buf[:1])
- }
- }
-}
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/bufio.go b/Godeps/_workspace/src/gopkg.in/bufio.v1/bufio.go
deleted file mode 100644
index 8f5cdc084..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/bufio.go
+++ /dev/null
@@ -1,728 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer
-// object, creating another object (Reader or Writer) that also implements
-// the interface but provides buffering and some help for textual I/O.
-package bufio
-
-import (
- "bytes"
- "errors"
- "io"
- "unicode/utf8"
-)
-
-const (
- defaultBufSize = 4096
-)
-
-var (
- ErrInvalidUnreadByte = errors.New("bufio: invalid use of UnreadByte")
- ErrInvalidUnreadRune = errors.New("bufio: invalid use of UnreadRune")
- ErrBufferFull = errors.New("bufio: buffer full")
- ErrNegativeCount = errors.New("bufio: negative count")
-)
-
-// Buffered input.
-
-// Reader implements buffering for an io.Reader object.
-type Reader struct {
- buf []byte
- rd io.Reader
- r, w int
- err error
- lastByte int
- lastRuneSize int
-}
-
-const minReadBufferSize = 16
-const maxConsecutiveEmptyReads = 100
-
-// NewReaderSize returns a new Reader whose buffer has at least the specified
-// size. If the argument io.Reader is already a Reader with large enough
-// size, it returns the underlying Reader.
-func NewReaderSize(rd io.Reader, size int) *Reader {
- // Is it already a Reader?
- b, ok := rd.(*Reader)
- if ok && len(b.buf) >= size {
- return b
- }
- if size < minReadBufferSize {
- size = minReadBufferSize
- }
- r := new(Reader)
- r.reset(make([]byte, size), rd)
- return r
-}
-
-// NewReader returns a new Reader whose buffer has the default size.
-func NewReader(rd io.Reader) *Reader {
- return NewReaderSize(rd, defaultBufSize)
-}
-
-// Reset discards any buffered data, resets all state, and switches
-// the buffered reader to read from r.
-func (b *Reader) Reset(r io.Reader) {
- b.reset(b.buf, r)
-}
-
-func (b *Reader) reset(buf []byte, r io.Reader) {
- *b = Reader{
- buf: buf,
- rd: r,
- lastByte: -1,
- lastRuneSize: -1,
- }
-}
-
-var errNegativeRead = errors.New("bufio: reader returned negative count from Read")
-
-// fill reads a new chunk into the buffer.
-func (b *Reader) fill() {
- // Slide existing data to beginning.
- if b.r > 0 {
- copy(b.buf, b.buf[b.r:b.w])
- b.w -= b.r
- b.r = 0
- }
-
- if b.w >= len(b.buf) {
- panic("bufio: tried to fill full buffer")
- }
-
- // Read new data: try a limited number of times.
- for i := maxConsecutiveEmptyReads; i > 0; i-- {
- n, err := b.rd.Read(b.buf[b.w:])
- if n < 0 {
- panic(errNegativeRead)
- }
- b.w += n
- if err != nil {
- b.err = err
- return
- }
- if n > 0 {
- return
- }
- }
- b.err = io.ErrNoProgress
-}
-
-func (b *Reader) readErr() error {
- err := b.err
- b.err = nil
- return err
-}
-
-// Peek returns the next n bytes without advancing the reader. The bytes stop
-// being valid at the next read call. If Peek returns fewer than n bytes, it
-// also returns an error explaining why the read is short. The error is
-// ErrBufferFull if n is larger than b's buffer size.
-func (b *Reader) Peek(n int) ([]byte, error) {
- if n < 0 {
- return nil, ErrNegativeCount
- }
- if n > len(b.buf) {
- return nil, ErrBufferFull
- }
- // 0 <= n <= len(b.buf)
- for b.w-b.r < n && b.err == nil {
- b.fill() // b.w-b.r < len(b.buf) => buffer is not full
- }
- m := b.w - b.r
- if m > n {
- m = n
- }
- var err error
- if m < n {
- err = b.readErr()
- if err == nil {
- err = ErrBufferFull
- }
- }
- return b.buf[b.r : b.r+m], err
-}
-
-// Read reads data into p.
-// It returns the number of bytes read into p.
-// It calls Read at most once on the underlying Reader,
-// hence n may be less than len(p).
-// At EOF, the count will be zero and err will be io.EOF.
-func (b *Reader) Read(p []byte) (n int, err error) {
- n = len(p)
- if n == 0 {
- return 0, b.readErr()
- }
- if b.r == b.w {
- if b.err != nil {
- return 0, b.readErr()
- }
- if len(p) >= len(b.buf) {
- // Large read, empty buffer.
- // Read directly into p to avoid copy.
- n, b.err = b.rd.Read(p)
- if n < 0 {
- panic(errNegativeRead)
- }
- if n > 0 {
- b.lastByte = int(p[n-1])
- b.lastRuneSize = -1
- }
- return n, b.readErr()
- }
- b.fill() // buffer is empty
- if b.w == b.r {
- return 0, b.readErr()
- }
- }
-
- if n > b.w-b.r {
- n = b.w - b.r
- }
- copy(p[0:n], b.buf[b.r:])
- b.r += n
- b.lastByte = int(b.buf[b.r-1])
- b.lastRuneSize = -1
- return n, nil
-}
-
-// ReadByte reads and returns a single byte.
-// If no byte is available, returns an error.
-func (b *Reader) ReadByte() (c byte, err error) {
- b.lastRuneSize = -1
- for b.r == b.w {
- if b.err != nil {
- return 0, b.readErr()
- }
- b.fill() // buffer is empty
- }
- c = b.buf[b.r]
- b.r++
- b.lastByte = int(c)
- return c, nil
-}
-
-// UnreadByte unreads the last byte. Only the most recently read byte can be unread.
-func (b *Reader) UnreadByte() error {
- if b.lastByte < 0 || b.r == 0 && b.w > 0 {
- return ErrInvalidUnreadByte
- }
- // b.r > 0 || b.w == 0
- if b.r > 0 {
- b.r--
- } else {
- // b.r == 0 && b.w == 0
- b.w = 1
- }
- b.buf[b.r] = byte(b.lastByte)
- b.lastByte = -1
- b.lastRuneSize = -1
- return nil
-}
-
-// ReadRune reads a single UTF-8 encoded Unicode character and returns the
-// rune and its size in bytes. If the encoded rune is invalid, it consumes one byte
-// and returns unicode.ReplacementChar (U+FFFD) with a size of 1.
-func (b *Reader) ReadRune() (r rune, size int, err error) {
- for b.r+utf8.UTFMax > b.w && !utf8.FullRune(b.buf[b.r:b.w]) && b.err == nil && b.w-b.r < len(b.buf) {
- b.fill() // b.w-b.r < len(buf) => buffer is not full
- }
- b.lastRuneSize = -1
- if b.r == b.w {
- return 0, 0, b.readErr()
- }
- r, size = rune(b.buf[b.r]), 1
- if r >= 0x80 {
- r, size = utf8.DecodeRune(b.buf[b.r:b.w])
- }
- b.r += size
- b.lastByte = int(b.buf[b.r-1])
- b.lastRuneSize = size
- return r, size, nil
-}
-
-// UnreadRune unreads the last rune. If the most recent read operation on
-// the buffer was not a ReadRune, UnreadRune returns an error. (In this
-// regard it is stricter than UnreadByte, which will unread the last byte
-// from any read operation.)
-func (b *Reader) UnreadRune() error {
- if b.lastRuneSize < 0 || b.r < b.lastRuneSize {
- return ErrInvalidUnreadRune
- }
- b.r -= b.lastRuneSize
- b.lastByte = -1
- b.lastRuneSize = -1
- return nil
-}
-
-// Buffered returns the number of bytes that can be read from the current buffer.
-func (b *Reader) Buffered() int { return b.w - b.r }
-
-// ReadSlice reads until the first occurrence of delim in the input,
-// returning a slice pointing at the bytes in the buffer.
-// The bytes stop being valid at the next read.
-// If ReadSlice encounters an error before finding a delimiter,
-// it returns all the data in the buffer and the error itself (often io.EOF).
-// ReadSlice fails with error ErrBufferFull if the buffer fills without a delim.
-// Because the data returned from ReadSlice will be overwritten
-// by the next I/O operation, most clients should use
-// ReadBytes or ReadString instead.
-// ReadSlice returns err != nil if and only if line does not end in delim.
-func (b *Reader) ReadSlice(delim byte) (line []byte, err error) {
- for {
- // Search buffer.
- if i := bytes.IndexByte(b.buf[b.r:b.w], delim); i >= 0 {
- line = b.buf[b.r : b.r+i+1]
- b.r += i + 1
- break
- }
-
- // Pending error?
- if b.err != nil {
- line = b.buf[b.r:b.w]
- b.r = b.w
- err = b.readErr()
- break
- }
-
- // Buffer full?
- if n := b.Buffered(); n >= len(b.buf) {
- b.r = b.w
- line = b.buf
- err = ErrBufferFull
- break
- }
-
- b.fill() // buffer is not full
- }
-
- // Handle last byte, if any.
- if i := len(line) - 1; i >= 0 {
- b.lastByte = int(line[i])
- }
-
- return
-}
-
-// ReadN tries to read exactly n bytes.
-// The bytes stop being valid at the next read call.
-// If ReadN encounters an error before reading n bytes,
-// it returns all the data in the buffer and the error itself (often io.EOF).
-// ReadN fails with error ErrBufferFull if the buffer fills
-// without reading N bytes.
-// Because the data returned from ReadN will be overwritten
-// by the next I/O operation, most clients should use
-// ReadBytes or ReadString instead.
-func (b *Reader) ReadN(n int) ([]byte, error) {
- for b.Buffered() < n {
- if b.err != nil {
- buf := b.buf[b.r:b.w]
- b.r = b.w
- return buf, b.readErr()
- }
-
- // Buffer is full?
- if b.Buffered() >= len(b.buf) {
- b.r = b.w
- return b.buf, ErrBufferFull
- }
-
- b.fill()
- }
- buf := b.buf[b.r : b.r+n]
- b.r += n
- return buf, nil
-}
-
-// ReadLine is a low-level line-reading primitive. Most callers should use
-// ReadBytes('\n') or ReadString('\n') instead or use a Scanner.
-//
-// ReadLine tries to return a single line, not including the end-of-line bytes.
-// If the line was too long for the buffer then isPrefix is set and the
-// beginning of the line is returned. The rest of the line will be returned
-// from future calls. isPrefix will be false when returning the last fragment
-// of the line. The returned buffer is only valid until the next call to
-// ReadLine. ReadLine either returns a non-nil line or it returns an error,
-// never both.
-//
-// The text returned from ReadLine does not include the line end ("\r\n" or "\n").
-// No indication or error is given if the input ends without a final line end.
-// Calling UnreadByte after ReadLine will always unread the last byte read
-// (possibly a character belonging to the line end) even if that byte is not
-// part of the line returned by ReadLine.
-func (b *Reader) ReadLine() (line []byte, isPrefix bool, err error) {
- line, err = b.ReadSlice('\n')
- if err == ErrBufferFull {
- // Handle the case where "\r\n" straddles the buffer.
- if len(line) > 0 && line[len(line)-1] == '\r' {
- // Put the '\r' back on buf and drop it from line.
- // Let the next call to ReadLine check for "\r\n".
- if b.r == 0 {
- // should be unreachable
- panic("bufio: tried to rewind past start of buffer")
- }
- b.r--
- line = line[:len(line)-1]
- }
- return line, true, nil
- }
-
- if len(line) == 0 {
- if err != nil {
- line = nil
- }
- return
- }
- err = nil
-
- if line[len(line)-1] == '\n' {
- drop := 1
- if len(line) > 1 && line[len(line)-2] == '\r' {
- drop = 2
- }
- line = line[:len(line)-drop]
- }
- return
-}
-
-// ReadBytes reads until the first occurrence of delim in the input,
-// returning a slice containing the data up to and including the delimiter.
-// If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often io.EOF).
-// ReadBytes returns err != nil if and only if the returned data does not end in
-// delim.
-// For simple uses, a Scanner may be more convenient.
-func (b *Reader) ReadBytes(delim byte) (line []byte, err error) {
- // Use ReadSlice to look for array,
- // accumulating full buffers.
- var frag []byte
- var full [][]byte
- err = nil
-
- for {
- var e error
- frag, e = b.ReadSlice(delim)
- if e == nil { // got final fragment
- break
- }
- if e != ErrBufferFull { // unexpected error
- err = e
- break
- }
-
- // Make a copy of the buffer.
- buf := make([]byte, len(frag))
- copy(buf, frag)
- full = append(full, buf)
- }
-
- // Allocate new buffer to hold the full pieces and the fragment.
- n := 0
- for i := range full {
- n += len(full[i])
- }
- n += len(frag)
-
- // Copy full pieces and fragment in.
- buf := make([]byte, n)
- n = 0
- for i := range full {
- n += copy(buf[n:], full[i])
- }
- copy(buf[n:], frag)
- return buf, err
-}
-
-// ReadString reads until the first occurrence of delim in the input,
-// returning a string containing the data up to and including the delimiter.
-// If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often io.EOF).
-// ReadString returns err != nil if and only if the returned data does not end in
-// delim.
-// For simple uses, a Scanner may be more convenient.
-func (b *Reader) ReadString(delim byte) (line string, err error) {
- bytes, err := b.ReadBytes(delim)
- line = string(bytes)
- return line, err
-}
-
-// WriteTo implements io.WriterTo.
-func (b *Reader) WriteTo(w io.Writer) (n int64, err error) {
- n, err = b.writeBuf(w)
- if err != nil {
- return
- }
-
- if r, ok := b.rd.(io.WriterTo); ok {
- m, err := r.WriteTo(w)
- n += m
- return n, err
- }
-
- if w, ok := w.(io.ReaderFrom); ok {
- m, err := w.ReadFrom(b.rd)
- n += m
- return n, err
- }
-
- if b.w-b.r < len(b.buf) {
- b.fill() // buffer not full
- }
-
- for b.r < b.w {
- // b.r < b.w => buffer is not empty
- m, err := b.writeBuf(w)
- n += m
- if err != nil {
- return n, err
- }
- b.fill() // buffer is empty
- }
-
- if b.err == io.EOF {
- b.err = nil
- }
-
- return n, b.readErr()
-}
-
-// writeBuf writes the Reader's buffer to the writer.
-func (b *Reader) writeBuf(w io.Writer) (int64, error) {
- n, err := w.Write(b.buf[b.r:b.w])
- if n < b.r-b.w {
- panic(errors.New("bufio: writer did not write all data"))
- }
- b.r += n
- return int64(n), err
-}
-
-// buffered output
-
-// Writer implements buffering for an io.Writer object.
-// If an error occurs writing to a Writer, no more data will be
-// accepted and all subsequent writes will return the error.
-// After all data has been written, the client should call the
-// Flush method to guarantee all data has been forwarded to
-// the underlying io.Writer.
-type Writer struct {
- err error
- buf []byte
- n int
- wr io.Writer
-}
-
-// NewWriterSize returns a new Writer whose buffer has at least the specified
-// size. If the argument io.Writer is already a Writer with large enough
-// size, it returns the underlying Writer.
-func NewWriterSize(w io.Writer, size int) *Writer {
- // Is it already a Writer?
- b, ok := w.(*Writer)
- if ok && len(b.buf) >= size {
- return b
- }
- if size <= 0 {
- size = defaultBufSize
- }
- return &Writer{
- buf: make([]byte, size),
- wr: w,
- }
-}
-
-// NewWriter returns a new Writer whose buffer has the default size.
-func NewWriter(w io.Writer) *Writer {
- return NewWriterSize(w, defaultBufSize)
-}
-
-// Reset discards any unflushed buffered data, clears any error, and
-// resets b to write its output to w.
-func (b *Writer) Reset(w io.Writer) {
- b.err = nil
- b.n = 0
- b.wr = w
-}
-
-// Flush writes any buffered data to the underlying io.Writer.
-func (b *Writer) Flush() error {
- err := b.flush()
- return err
-}
-
-func (b *Writer) flush() error {
- if b.err != nil {
- return b.err
- }
- if b.n == 0 {
- return nil
- }
- n, err := b.wr.Write(b.buf[0:b.n])
- if n < b.n && err == nil {
- err = io.ErrShortWrite
- }
- if err != nil {
- if n > 0 && n < b.n {
- copy(b.buf[0:b.n-n], b.buf[n:b.n])
- }
- b.n -= n
- b.err = err
- return err
- }
- b.n = 0
- return nil
-}
-
-// Available returns how many bytes are unused in the buffer.
-func (b *Writer) Available() int { return len(b.buf) - b.n }
-
-// Buffered returns the number of bytes that have been written into the current buffer.
-func (b *Writer) Buffered() int { return b.n }
-
-// Write writes the contents of p into the buffer.
-// It returns the number of bytes written.
-// If nn < len(p), it also returns an error explaining
-// why the write is short.
-func (b *Writer) Write(p []byte) (nn int, err error) {
- for len(p) > b.Available() && b.err == nil {
- var n int
- if b.Buffered() == 0 {
- // Large write, empty buffer.
- // Write directly from p to avoid copy.
- n, b.err = b.wr.Write(p)
- } else {
- n = copy(b.buf[b.n:], p)
- b.n += n
- b.flush()
- }
- nn += n
- p = p[n:]
- }
- if b.err != nil {
- return nn, b.err
- }
- n := copy(b.buf[b.n:], p)
- b.n += n
- nn += n
- return nn, nil
-}
-
-// WriteByte writes a single byte.
-func (b *Writer) WriteByte(c byte) error {
- if b.err != nil {
- return b.err
- }
- if b.Available() <= 0 && b.flush() != nil {
- return b.err
- }
- b.buf[b.n] = c
- b.n++
- return nil
-}
-
-// WriteRune writes a single Unicode code point, returning
-// the number of bytes written and any error.
-func (b *Writer) WriteRune(r rune) (size int, err error) {
- if r < utf8.RuneSelf {
- err = b.WriteByte(byte(r))
- if err != nil {
- return 0, err
- }
- return 1, nil
- }
- if b.err != nil {
- return 0, b.err
- }
- n := b.Available()
- if n < utf8.UTFMax {
- if b.flush(); b.err != nil {
- return 0, b.err
- }
- n = b.Available()
- if n < utf8.UTFMax {
- // Can only happen if buffer is silly small.
- return b.WriteString(string(r))
- }
- }
- size = utf8.EncodeRune(b.buf[b.n:], r)
- b.n += size
- return size, nil
-}
-
-// WriteString writes a string.
-// It returns the number of bytes written.
-// If the count is less than len(s), it also returns an error explaining
-// why the write is short.
-func (b *Writer) WriteString(s string) (int, error) {
- nn := 0
- for len(s) > b.Available() && b.err == nil {
- n := copy(b.buf[b.n:], s)
- b.n += n
- nn += n
- s = s[n:]
- b.flush()
- }
- if b.err != nil {
- return nn, b.err
- }
- n := copy(b.buf[b.n:], s)
- b.n += n
- nn += n
- return nn, nil
-}
-
-// ReadFrom implements io.ReaderFrom.
-func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) {
- if b.Buffered() == 0 {
- if w, ok := b.wr.(io.ReaderFrom); ok {
- return w.ReadFrom(r)
- }
- }
- var m int
- for {
- if b.Available() == 0 {
- if err1 := b.flush(); err1 != nil {
- return n, err1
- }
- }
- nr := 0
- for nr < maxConsecutiveEmptyReads {
- m, err = r.Read(b.buf[b.n:])
- if m != 0 || err != nil {
- break
- }
- nr++
- }
- if nr == maxConsecutiveEmptyReads {
- return n, io.ErrNoProgress
- }
- b.n += m
- n += int64(m)
- if err != nil {
- break
- }
- }
- if err == io.EOF {
- // If we filled the buffer exactly, flush pre-emptively.
- if b.Available() == 0 {
- err = b.flush()
- } else {
- err = nil
- }
- }
- return n, err
-}
-
-// buffered input and output
-
-// ReadWriter stores pointers to a Reader and a Writer.
-// It implements io.ReadWriter.
-type ReadWriter struct {
- *Reader
- *Writer
-}
-
-// NewReadWriter allocates a new ReadWriter that dispatches to r and w.
-func NewReadWriter(r *Reader, w *Writer) *ReadWriter {
- return &ReadWriter{r, w}
-}
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/bufio_test.go b/Godeps/_workspace/src/gopkg.in/bufio.v1/bufio_test.go
deleted file mode 100644
index f19d9bd28..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/bufio_test.go
+++ /dev/null
@@ -1,1418 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bufio_test
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "strings"
- "testing"
- "testing/iotest"
- "time"
- "unicode/utf8"
-
- . "gopkg.in/bufio.v1"
-)
-
-// Reads from a reader and rot13s the result.
-type rot13Reader struct {
- r io.Reader
-}
-
-func newRot13Reader(r io.Reader) *rot13Reader {
- r13 := new(rot13Reader)
- r13.r = r
- return r13
-}
-
-func (r13 *rot13Reader) Read(p []byte) (int, error) {
- n, err := r13.r.Read(p)
- if err != nil {
- return n, err
- }
- for i := 0; i < n; i++ {
- c := p[i] | 0x20 // lowercase byte
- if 'a' <= c && c <= 'm' {
- p[i] += 13
- } else if 'n' <= c && c <= 'z' {
- p[i] -= 13
- }
- }
- return n, nil
-}
-
-// Call ReadByte to accumulate the text of a file
-func readBytes(buf *Reader) string {
- var b [1000]byte
- nb := 0
- for {
- c, err := buf.ReadByte()
- if err == io.EOF {
- break
- }
- if err == nil {
- b[nb] = c
- nb++
- } else if err != iotest.ErrTimeout {
- panic("Data: " + err.Error())
- }
- }
- return string(b[0:nb])
-}
-
-func TestReaderSimple(t *testing.T) {
- data := "hello world"
- b := NewReader(strings.NewReader(data))
- if s := readBytes(b); s != "hello world" {
- t.Errorf("simple hello world test failed: got %q", s)
- }
-
- b = NewReader(newRot13Reader(strings.NewReader(data)))
- if s := readBytes(b); s != "uryyb jbeyq" {
- t.Errorf("rot13 hello world test failed: got %q", s)
- }
-}
-
-type readMaker struct {
- name string
- fn func(io.Reader) io.Reader
-}
-
-var readMakers = []readMaker{
- {"full", func(r io.Reader) io.Reader { return r }},
- {"byte", iotest.OneByteReader},
- {"half", iotest.HalfReader},
- {"data+err", iotest.DataErrReader},
- {"timeout", iotest.TimeoutReader},
-}
-
-// Call ReadString (which ends up calling everything else)
-// to accumulate the text of a file.
-func readLines(b *Reader) string {
- s := ""
- for {
- s1, err := b.ReadString('\n')
- if err == io.EOF {
- break
- }
- if err != nil && err != iotest.ErrTimeout {
- panic("GetLines: " + err.Error())
- }
- s += s1
- }
- return s
-}
-
-// Call Read to accumulate the text of a file
-func reads(buf *Reader, m int) string {
- var b [1000]byte
- nb := 0
- for {
- n, err := buf.Read(b[nb : nb+m])
- nb += n
- if err == io.EOF {
- break
- }
- }
- return string(b[0:nb])
-}
-
-type bufReader struct {
- name string
- fn func(*Reader) string
-}
-
-var bufreaders = []bufReader{
- {"1", func(b *Reader) string { return reads(b, 1) }},
- {"2", func(b *Reader) string { return reads(b, 2) }},
- {"3", func(b *Reader) string { return reads(b, 3) }},
- {"4", func(b *Reader) string { return reads(b, 4) }},
- {"5", func(b *Reader) string { return reads(b, 5) }},
- {"7", func(b *Reader) string { return reads(b, 7) }},
- {"bytes", readBytes},
- {"lines", readLines},
-}
-
-const minReadBufferSize = 16
-
-var bufsizes = []int{
- 0, minReadBufferSize, 23, 32, 46, 64, 93, 128, 1024, 4096,
-}
-
-func TestReader(t *testing.T) {
- var texts [31]string
- str := ""
- all := ""
- for i := 0; i < len(texts)-1; i++ {
- texts[i] = str + "\n"
- all += texts[i]
- str += string(i%26 + 'a')
- }
- texts[len(texts)-1] = all
-
- for h := 0; h < len(texts); h++ {
- text := texts[h]
- for i := 0; i < len(readMakers); i++ {
- for j := 0; j < len(bufreaders); j++ {
- for k := 0; k < len(bufsizes); k++ {
- readmaker := readMakers[i]
- bufreader := bufreaders[j]
- bufsize := bufsizes[k]
- read := readmaker.fn(strings.NewReader(text))
- buf := NewReaderSize(read, bufsize)
- s := bufreader.fn(buf)
- if s != text {
- t.Errorf("reader=%s fn=%s bufsize=%d want=%q got=%q",
- readmaker.name, bufreader.name, bufsize, text, s)
- }
- }
- }
- }
- }
-}
-
-type zeroReader struct{}
-
-func (zeroReader) Read(p []byte) (int, error) {
- return 0, nil
-}
-
-func TestZeroReader(t *testing.T) {
- var z zeroReader
- r := NewReader(z)
-
- c := make(chan error)
- go func() {
- _, err := r.ReadByte()
- c <- err
- }()
-
- select {
- case err := <-c:
- if err == nil {
- t.Error("error expected")
- } else if err != io.ErrNoProgress {
- t.Error("unexpected error:", err)
- }
- case <-time.After(time.Second):
- t.Error("test timed out (endless loop in ReadByte?)")
- }
-}
-
-// A StringReader delivers its data one string segment at a time via Read.
-type StringReader struct {
- data []string
- step int
-}
-
-func (r *StringReader) Read(p []byte) (n int, err error) {
- if r.step < len(r.data) {
- s := r.data[r.step]
- n = copy(p, s)
- r.step++
- } else {
- err = io.EOF
- }
- return
-}
-
-func readRuneSegments(t *testing.T, segments []string) {
- got := ""
- want := strings.Join(segments, "")
- r := NewReader(&StringReader{data: segments})
- for {
- r, _, err := r.ReadRune()
- if err != nil {
- if err != io.EOF {
- return
- }
- break
- }
- got += string(r)
- }
- if got != want {
- t.Errorf("segments=%v got=%s want=%s", segments, got, want)
- }
-}
-
-var segmentList = [][]string{
- {},
- {""},
- {"日", "本語"},
- {"\u65e5", "\u672c", "\u8a9e"},
- {"\U000065e5", "\U0000672c", "\U00008a9e"},
- {"\xe6", "\x97\xa5\xe6", "\x9c\xac\xe8\xaa\x9e"},
- {"Hello", ", ", "World", "!"},
- {"Hello", ", ", "", "World", "!"},
-}
-
-func TestReadRune(t *testing.T) {
- for _, s := range segmentList {
- readRuneSegments(t, s)
- }
-}
-
-func TestUnreadRune(t *testing.T) {
- segments := []string{"Hello, world:", "日本語"}
- r := NewReader(&StringReader{data: segments})
- got := ""
- want := strings.Join(segments, "")
- // Normal execution.
- for {
- r1, _, err := r.ReadRune()
- if err != nil {
- if err != io.EOF {
- t.Error("unexpected error on ReadRune:", err)
- }
- break
- }
- got += string(r1)
- // Put it back and read it again.
- if err = r.UnreadRune(); err != nil {
- t.Fatal("unexpected error on UnreadRune:", err)
- }
- r2, _, err := r.ReadRune()
- if err != nil {
- t.Fatal("unexpected error reading after unreading:", err)
- }
- if r1 != r2 {
- t.Fatalf("incorrect rune after unread: got %c, want %c", r1, r2)
- }
- }
- if got != want {
- t.Errorf("got %q, want %q", got, want)
- }
-}
-
-func TestReaderUnreadByte(t *testing.T) {
- segments := []string{"Hello, ", "world"}
- r := NewReader(&StringReader{data: segments})
- got := ""
- want := strings.Join(segments, "")
- // Normal execution.
- for {
- b1, err := r.ReadByte()
- if err != nil {
- if err != io.EOF {
- t.Error("unexpected error on ReadByte:", err)
- }
- break
- }
- got += string(b1)
- // Put it back and read it again.
- if err = r.UnreadByte(); err != nil {
- t.Fatal("unexpected error on UnreadByte:", err)
- }
- b2, err := r.ReadByte()
- if err != nil {
- t.Fatal("unexpected error reading after unreading:", err)
- }
- if b1 != b2 {
- t.Fatalf("incorrect byte after unread: got %q, want %q", b1, b2)
- }
- }
- if got != want {
- t.Errorf("got %q, want %q", got, want)
- }
-}
-
-func TestUnreadByteMultiple(t *testing.T) {
- segments := []string{"Hello, ", "world"}
- data := strings.Join(segments, "")
- for n := 0; n <= len(data); n++ {
- r := NewReader(&StringReader{data: segments})
- // Read n bytes.
- for i := 0; i < n; i++ {
- b, err := r.ReadByte()
- if err != nil {
- t.Fatalf("n = %d: unexpected error on ReadByte: %v", n, err)
- }
- if b != data[i] {
- t.Fatalf("n = %d: incorrect byte returned from ReadByte: got %q, want %q", n, b, data[i])
- }
- }
- // Unread one byte if there is one.
- if n > 0 {
- if err := r.UnreadByte(); err != nil {
- t.Errorf("n = %d: unexpected error on UnreadByte: %v", n, err)
- }
- }
- // Test that we cannot unread any further.
- if err := r.UnreadByte(); err == nil {
- t.Errorf("n = %d: expected error on UnreadByte", n)
- }
- }
-}
-
-func TestUnreadByteOthers(t *testing.T) {
- // A list of readers to use in conjunction with UnreadByte.
- var readers = []func(*Reader, byte) ([]byte, error){
- (*Reader).ReadBytes,
- (*Reader).ReadSlice,
- func(r *Reader, delim byte) ([]byte, error) {
- data, err := r.ReadString(delim)
- return []byte(data), err
- },
- // ReadLine doesn't fit the data/pattern easily
- // so we leave it out. It should be covered via
- // the ReadSlice test since ReadLine simply calls
- // ReadSlice, and it's that function that handles
- // the last byte.
- }
-
- // Try all readers with UnreadByte.
- for rno, read := range readers {
- // Some input data that is longer than the minimum reader buffer size.
- const n = 10
- var buf bytes.Buffer
- for i := 0; i < n; i++ {
- buf.WriteString("abcdefg")
- }
-
- r := NewReaderSize(&buf, minReadBufferSize)
- readTo := func(delim byte, want string) {
- data, err := read(r, delim)
- if err != nil {
- t.Fatalf("#%d: unexpected error reading to %c: %v", rno, delim, err)
- }
- if got := string(data); got != want {
- t.Fatalf("#%d: got %q, want %q", rno, got, want)
- }
- }
-
- // Read the data with occasional UnreadByte calls.
- for i := 0; i < n; i++ {
- readTo('d', "abcd")
- for j := 0; j < 3; j++ {
- if err := r.UnreadByte(); err != nil {
- t.Fatalf("#%d: unexpected error on UnreadByte: %v", rno, err)
- }
- readTo('d', "d")
- }
- readTo('g', "efg")
- }
-
- // All data should have been read.
- _, err := r.ReadByte()
- if err != io.EOF {
- t.Errorf("#%d: got error %v; want EOF", rno, err)
- }
- }
-}
-
-// Test that UnreadRune fails if the preceding operation was not a ReadRune.
-func TestUnreadRuneError(t *testing.T) {
- buf := make([]byte, 3) // All runes in this test are 3 bytes long
- r := NewReader(&StringReader{data: []string{"日本語日本語日本語"}})
- if r.UnreadRune() == nil {
- t.Error("expected error on UnreadRune from fresh buffer")
- }
- _, _, err := r.ReadRune()
- if err != nil {
- t.Error("unexpected error on ReadRune (1):", err)
- }
- if err = r.UnreadRune(); err != nil {
- t.Error("unexpected error on UnreadRune (1):", err)
- }
- if r.UnreadRune() == nil {
- t.Error("expected error after UnreadRune (1)")
- }
- // Test error after Read.
- _, _, err = r.ReadRune() // reset state
- if err != nil {
- t.Error("unexpected error on ReadRune (2):", err)
- }
- _, err = r.Read(buf)
- if err != nil {
- t.Error("unexpected error on Read (2):", err)
- }
- if r.UnreadRune() == nil {
- t.Error("expected error after Read (2)")
- }
- // Test error after ReadByte.
- _, _, err = r.ReadRune() // reset state
- if err != nil {
- t.Error("unexpected error on ReadRune (2):", err)
- }
- for _ = range buf {
- _, err = r.ReadByte()
- if err != nil {
- t.Error("unexpected error on ReadByte (2):", err)
- }
- }
- if r.UnreadRune() == nil {
- t.Error("expected error after ReadByte")
- }
- // Test error after UnreadByte.
- _, _, err = r.ReadRune() // reset state
- if err != nil {
- t.Error("unexpected error on ReadRune (3):", err)
- }
- _, err = r.ReadByte()
- if err != nil {
- t.Error("unexpected error on ReadByte (3):", err)
- }
- err = r.UnreadByte()
- if err != nil {
- t.Error("unexpected error on UnreadByte (3):", err)
- }
- if r.UnreadRune() == nil {
- t.Error("expected error after UnreadByte (3)")
- }
-}
-
-func TestUnreadRuneAtEOF(t *testing.T) {
- // UnreadRune/ReadRune should error at EOF (was a bug; used to panic)
- r := NewReader(strings.NewReader("x"))
- r.ReadRune()
- r.ReadRune()
- r.UnreadRune()
- _, _, err := r.ReadRune()
- if err == nil {
- t.Error("expected error at EOF")
- } else if err != io.EOF {
- t.Error("expected EOF; got", err)
- }
-}
-
-func TestReadWriteRune(t *testing.T) {
- const NRune = 1000
- byteBuf := new(bytes.Buffer)
- w := NewWriter(byteBuf)
- // Write the runes out using WriteRune
- buf := make([]byte, utf8.UTFMax)
- for r := rune(0); r < NRune; r++ {
- size := utf8.EncodeRune(buf, r)
- nbytes, err := w.WriteRune(r)
- if err != nil {
- t.Fatalf("WriteRune(0x%x) error: %s", r, err)
- }
- if nbytes != size {
- t.Fatalf("WriteRune(0x%x) expected %d, got %d", r, size, nbytes)
- }
- }
- w.Flush()
-
- r := NewReader(byteBuf)
- // Read them back with ReadRune
- for r1 := rune(0); r1 < NRune; r1++ {
- size := utf8.EncodeRune(buf, r1)
- nr, nbytes, err := r.ReadRune()
- if nr != r1 || nbytes != size || err != nil {
- t.Fatalf("ReadRune(0x%x) got 0x%x,%d not 0x%x,%d (err=%s)", r1, nr, nbytes, r1, size, err)
- }
- }
-}
-
-func TestWriter(t *testing.T) {
- var data [8192]byte
-
- for i := 0; i < len(data); i++ {
- data[i] = byte(' ' + i%('~'-' '))
- }
- w := new(bytes.Buffer)
- for i := 0; i < len(bufsizes); i++ {
- for j := 0; j < len(bufsizes); j++ {
- nwrite := bufsizes[i]
- bs := bufsizes[j]
-
- // Write nwrite bytes using buffer size bs.
- // Check that the right amount makes it out
- // and that the data is correct.
-
- w.Reset()
- buf := NewWriterSize(w, bs)
- context := fmt.Sprintf("nwrite=%d bufsize=%d", nwrite, bs)
- n, e1 := buf.Write(data[0:nwrite])
- if e1 != nil || n != nwrite {
- t.Errorf("%s: buf.Write %d = %d, %v", context, nwrite, n, e1)
- continue
- }
- if e := buf.Flush(); e != nil {
- t.Errorf("%s: buf.Flush = %v", context, e)
- }
-
- written := w.Bytes()
- if len(written) != nwrite {
- t.Errorf("%s: %d bytes written", context, len(written))
- }
- for l := 0; l < len(written); l++ {
- if written[i] != data[i] {
- t.Errorf("wrong bytes written")
- t.Errorf("want=%q", data[0:len(written)])
- t.Errorf("have=%q", written)
- }
- }
- }
- }
-}
-
-// Check that write errors are returned properly.
-
-type errorWriterTest struct {
- n, m int
- err error
- expect error
-}
-
-func (w errorWriterTest) Write(p []byte) (int, error) {
- return len(p) * w.n / w.m, w.err
-}
-
-var errorWriterTests = []errorWriterTest{
- {0, 1, nil, io.ErrShortWrite},
- {1, 2, nil, io.ErrShortWrite},
- {1, 1, nil, nil},
- {0, 1, io.ErrClosedPipe, io.ErrClosedPipe},
- {1, 2, io.ErrClosedPipe, io.ErrClosedPipe},
- {1, 1, io.ErrClosedPipe, io.ErrClosedPipe},
-}
-
-func TestWriteErrors(t *testing.T) {
- for _, w := range errorWriterTests {
- buf := NewWriter(w)
- _, e := buf.Write([]byte("hello world"))
- if e != nil {
- t.Errorf("Write hello to %v: %v", w, e)
- continue
- }
- // Two flushes, to verify the error is sticky.
- for i := 0; i < 2; i++ {
- e = buf.Flush()
- if e != w.expect {
- t.Errorf("Flush %d/2 %v: got %v, wanted %v", i+1, w, e, w.expect)
- }
- }
- }
-}
-
-func TestNewReaderSizeIdempotent(t *testing.T) {
- const BufSize = 1000
- b := NewReaderSize(strings.NewReader("hello world"), BufSize)
- // Does it recognize itself?
- b1 := NewReaderSize(b, BufSize)
- if b1 != b {
- t.Error("NewReaderSize did not detect underlying Reader")
- }
- // Does it wrap if existing buffer is too small?
- b2 := NewReaderSize(b, 2*BufSize)
- if b2 == b {
- t.Error("NewReaderSize did not enlarge buffer")
- }
-}
-
-func TestNewWriterSizeIdempotent(t *testing.T) {
- const BufSize = 1000
- b := NewWriterSize(new(bytes.Buffer), BufSize)
- // Does it recognize itself?
- b1 := NewWriterSize(b, BufSize)
- if b1 != b {
- t.Error("NewWriterSize did not detect underlying Writer")
- }
- // Does it wrap if existing buffer is too small?
- b2 := NewWriterSize(b, 2*BufSize)
- if b2 == b {
- t.Error("NewWriterSize did not enlarge buffer")
- }
-}
-
-func TestWriteString(t *testing.T) {
- const BufSize = 8
- buf := new(bytes.Buffer)
- b := NewWriterSize(buf, BufSize)
- b.WriteString("0") // easy
- b.WriteString("123456") // still easy
- b.WriteString("7890") // easy after flush
- b.WriteString("abcdefghijklmnopqrstuvwxy") // hard
- b.WriteString("z")
- if err := b.Flush(); err != nil {
- t.Error("WriteString", err)
- }
- s := "01234567890abcdefghijklmnopqrstuvwxyz"
- if string(buf.Bytes()) != s {
- t.Errorf("WriteString wants %q gets %q", s, string(buf.Bytes()))
- }
-}
-
-func TestBufferFull(t *testing.T) {
- const longString = "And now, hello, world! It is the time for all good men to come to the aid of their party"
- buf := NewReaderSize(strings.NewReader(longString), minReadBufferSize)
- line, err := buf.ReadSlice('!')
- if string(line) != "And now, hello, " || err != ErrBufferFull {
- t.Errorf("first ReadSlice(,) = %q, %v", line, err)
- }
- line, err = buf.ReadSlice('!')
- if string(line) != "world!" || err != nil {
- t.Errorf("second ReadSlice(,) = %q, %v", line, err)
- }
-}
-
-func TestPeek(t *testing.T) {
- p := make([]byte, 10)
- // string is 16 (minReadBufferSize) long.
- buf := NewReaderSize(strings.NewReader("abcdefghijklmnop"), minReadBufferSize)
- if s, err := buf.Peek(1); string(s) != "a" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "a", string(s), err)
- }
- if s, err := buf.Peek(4); string(s) != "abcd" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "abcd", string(s), err)
- }
- if _, err := buf.Peek(-1); err != ErrNegativeCount {
- t.Fatalf("want ErrNegativeCount got %v", err)
- }
- if _, err := buf.Peek(32); err != ErrBufferFull {
- t.Fatalf("want ErrBufFull got %v", err)
- }
- if _, err := buf.Read(p[0:3]); string(p[0:3]) != "abc" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "abc", string(p[0:3]), err)
- }
- if s, err := buf.Peek(1); string(s) != "d" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "d", string(s), err)
- }
- if s, err := buf.Peek(2); string(s) != "de" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "de", string(s), err)
- }
- if _, err := buf.Read(p[0:3]); string(p[0:3]) != "def" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "def", string(p[0:3]), err)
- }
- if s, err := buf.Peek(4); string(s) != "ghij" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "ghij", string(s), err)
- }
- if _, err := buf.Read(p[0:]); string(p[0:]) != "ghijklmnop" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "ghijklmnop", string(p[0:minReadBufferSize]), err)
- }
- if s, err := buf.Peek(0); string(s) != "" || err != nil {
- t.Fatalf("want %q got %q, err=%v", "", string(s), err)
- }
- if _, err := buf.Peek(1); err != io.EOF {
- t.Fatalf("want EOF got %v", err)
- }
-
- // Test for issue 3022, not exposing a reader's error on a successful Peek.
- buf = NewReaderSize(dataAndEOFReader("abcd"), 32)
- if s, err := buf.Peek(2); string(s) != "ab" || err != nil {
- t.Errorf(`Peek(2) on "abcd", EOF = %q, %v; want "ab", nil`, string(s), err)
- }
- if s, err := buf.Peek(4); string(s) != "abcd" || err != nil {
- t.Errorf(`Peek(4) on "abcd", EOF = %q, %v; want "abcd", nil`, string(s), err)
- }
- if n, err := buf.Read(p[0:5]); string(p[0:n]) != "abcd" || err != nil {
- t.Fatalf("Read after peek = %q, %v; want abcd, EOF", p[0:n], err)
- }
- if n, err := buf.Read(p[0:1]); string(p[0:n]) != "" || err != io.EOF {
- t.Fatalf(`second Read after peek = %q, %v; want "", EOF`, p[0:n], err)
- }
-}
-
-type dataAndEOFReader string
-
-func (r dataAndEOFReader) Read(p []byte) (int, error) {
- return copy(p, r), io.EOF
-}
-
-func TestPeekThenUnreadRune(t *testing.T) {
- // This sequence used to cause a crash.
- r := NewReader(strings.NewReader("x"))
- r.ReadRune()
- r.Peek(1)
- r.UnreadRune()
- r.ReadRune() // Used to panic here
-}
-
-var testOutput = []byte("0123456789abcdefghijklmnopqrstuvwxy")
-var testInput = []byte("012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy")
-var testInputrn = []byte("012\r\n345\r\n678\r\n9ab\r\ncde\r\nfgh\r\nijk\r\nlmn\r\nopq\r\nrst\r\nuvw\r\nxy\r\n\n\r\n")
-
-// TestReader wraps a []byte and returns reads of a specific length.
-type testReader struct {
- data []byte
- stride int
-}
-
-func (t *testReader) Read(buf []byte) (n int, err error) {
- n = t.stride
- if n > len(t.data) {
- n = len(t.data)
- }
- if n > len(buf) {
- n = len(buf)
- }
- copy(buf, t.data)
- t.data = t.data[n:]
- if len(t.data) == 0 {
- err = io.EOF
- }
- return
-}
-
-func testReadLine(t *testing.T, input []byte) {
- //for stride := 1; stride < len(input); stride++ {
- for stride := 1; stride < 2; stride++ {
- done := 0
- reader := testReader{input, stride}
- l := NewReaderSize(&reader, len(input)+1)
- for {
- line, isPrefix, err := l.ReadLine()
- if len(line) > 0 && err != nil {
- t.Errorf("ReadLine returned both data and error: %s", err)
- }
- if isPrefix {
- t.Errorf("ReadLine returned prefix")
- }
- if err != nil {
- if err != io.EOF {
- t.Fatalf("Got unknown error: %s", err)
- }
- break
- }
- if want := testOutput[done : done+len(line)]; !bytes.Equal(want, line) {
- t.Errorf("Bad line at stride %d: want: %x got: %x", stride, want, line)
- }
- done += len(line)
- }
- if done != len(testOutput) {
- t.Errorf("ReadLine didn't return everything: got: %d, want: %d (stride: %d)", done, len(testOutput), stride)
- }
- }
-}
-
-func TestReadLine(t *testing.T) {
- testReadLine(t, testInput)
- testReadLine(t, testInputrn)
-}
-
-func TestLineTooLong(t *testing.T) {
- data := make([]byte, 0)
- for i := 0; i < minReadBufferSize*5/2; i++ {
- data = append(data, '0'+byte(i%10))
- }
- buf := bytes.NewReader(data)
- l := NewReaderSize(buf, minReadBufferSize)
- line, isPrefix, err := l.ReadLine()
- if !isPrefix || !bytes.Equal(line, data[:minReadBufferSize]) || err != nil {
- t.Errorf("bad result for first line: got %q want %q %v", line, data[:minReadBufferSize], err)
- }
- data = data[len(line):]
- line, isPrefix, err = l.ReadLine()
- if !isPrefix || !bytes.Equal(line, data[:minReadBufferSize]) || err != nil {
- t.Errorf("bad result for second line: got %q want %q %v", line, data[:minReadBufferSize], err)
- }
- data = data[len(line):]
- line, isPrefix, err = l.ReadLine()
- if isPrefix || !bytes.Equal(line, data[:minReadBufferSize/2]) || err != nil {
- t.Errorf("bad result for third line: got %q want %q %v", line, data[:minReadBufferSize/2], err)
- }
- line, isPrefix, err = l.ReadLine()
- if isPrefix || err == nil {
- t.Errorf("expected no more lines: %x %s", line, err)
- }
-}
-
-func TestReadAfterLines(t *testing.T) {
- line1 := "this is line1"
- restData := "this is line2\nthis is line 3\n"
- inbuf := bytes.NewReader([]byte(line1 + "\n" + restData))
- outbuf := new(bytes.Buffer)
- maxLineLength := len(line1) + len(restData)/2
- l := NewReaderSize(inbuf, maxLineLength)
- line, isPrefix, err := l.ReadLine()
- if isPrefix || err != nil || string(line) != line1 {
- t.Errorf("bad result for first line: isPrefix=%v err=%v line=%q", isPrefix, err, string(line))
- }
- n, err := io.Copy(outbuf, l)
- if int(n) != len(restData) || err != nil {
- t.Errorf("bad result for Read: n=%d err=%v", n, err)
- }
- if outbuf.String() != restData {
- t.Errorf("bad result for Read: got %q; expected %q", outbuf.String(), restData)
- }
-}
-
-func TestReadEmptyBuffer(t *testing.T) {
- l := NewReaderSize(new(bytes.Buffer), minReadBufferSize)
- line, isPrefix, err := l.ReadLine()
- if err != io.EOF {
- t.Errorf("expected EOF from ReadLine, got '%s' %t %s", line, isPrefix, err)
- }
-}
-
-func TestLinesAfterRead(t *testing.T) {
- l := NewReaderSize(bytes.NewReader([]byte("foo")), minReadBufferSize)
- _, err := ioutil.ReadAll(l)
- if err != nil {
- t.Error(err)
- return
- }
-
- line, isPrefix, err := l.ReadLine()
- if err != io.EOF {
- t.Errorf("expected EOF from ReadLine, got '%s' %t %s", line, isPrefix, err)
- }
-}
-
-func TestReadLineNonNilLineOrError(t *testing.T) {
- r := NewReader(strings.NewReader("line 1\n"))
- for i := 0; i < 2; i++ {
- l, _, err := r.ReadLine()
- if l != nil && err != nil {
- t.Fatalf("on line %d/2; ReadLine=%#v, %v; want non-nil line or Error, but not both",
- i+1, l, err)
- }
- }
-}
-
-type readLineResult struct {
- line []byte
- isPrefix bool
- err error
-}
-
-var readLineNewlinesTests = []struct {
- input string
- expect []readLineResult
-}{
- {"012345678901234\r\n012345678901234\r\n", []readLineResult{
- {[]byte("012345678901234"), true, nil},
- {nil, false, nil},
- {[]byte("012345678901234"), true, nil},
- {nil, false, nil},
- {nil, false, io.EOF},
- }},
- {"0123456789012345\r012345678901234\r", []readLineResult{
- {[]byte("0123456789012345"), true, nil},
- {[]byte("\r012345678901234"), true, nil},
- {[]byte("\r"), false, nil},
- {nil, false, io.EOF},
- }},
-}
-
-func TestReadLineNewlines(t *testing.T) {
- for _, e := range readLineNewlinesTests {
- testReadLineNewlines(t, e.input, e.expect)
- }
-}
-
-func testReadLineNewlines(t *testing.T, input string, expect []readLineResult) {
- b := NewReaderSize(strings.NewReader(input), minReadBufferSize)
- for i, e := range expect {
- line, isPrefix, err := b.ReadLine()
- if !bytes.Equal(line, e.line) {
- t.Errorf("%q call %d, line == %q, want %q", input, i, line, e.line)
- return
- }
- if isPrefix != e.isPrefix {
- t.Errorf("%q call %d, isPrefix == %v, want %v", input, i, isPrefix, e.isPrefix)
- return
- }
- if err != e.err {
- t.Errorf("%q call %d, err == %v, want %v", input, i, err, e.err)
- return
- }
- }
-}
-
-func createTestInput(n int) []byte {
- input := make([]byte, n)
- for i := range input {
- // 101 and 251 are arbitrary prime numbers.
- // The idea is to create an input sequence
- // which doesn't repeat too frequently.
- input[i] = byte(i % 251)
- if i%101 == 0 {
- input[i] ^= byte(i / 101)
- }
- }
- return input
-}
-
-func TestReaderWriteTo(t *testing.T) {
- input := createTestInput(8192)
- r := NewReader(onlyReader{bytes.NewReader(input)})
- w := new(bytes.Buffer)
- if n, err := r.WriteTo(w); err != nil || n != int64(len(input)) {
- t.Fatalf("r.WriteTo(w) = %d, %v, want %d, nil", n, err, len(input))
- }
-
- for i, val := range w.Bytes() {
- if val != input[i] {
- t.Errorf("after write: out[%d] = %#x, want %#x", i, val, input[i])
- }
- }
-}
-
-type errorWriterToTest struct {
- rn, wn int
- rerr, werr error
- expected error
-}
-
-func (r errorWriterToTest) Read(p []byte) (int, error) {
- return len(p) * r.rn, r.rerr
-}
-
-func (w errorWriterToTest) Write(p []byte) (int, error) {
- return len(p) * w.wn, w.werr
-}
-
-var errorWriterToTests = []errorWriterToTest{
- {1, 0, nil, io.ErrClosedPipe, io.ErrClosedPipe},
- {0, 1, io.ErrClosedPipe, nil, io.ErrClosedPipe},
- {0, 0, io.ErrUnexpectedEOF, io.ErrClosedPipe, io.ErrClosedPipe},
- {0, 1, io.EOF, nil, nil},
-}
-
-func TestReaderWriteToErrors(t *testing.T) {
- for i, rw := range errorWriterToTests {
- r := NewReader(rw)
- if _, err := r.WriteTo(rw); err != rw.expected {
- t.Errorf("r.WriteTo(errorWriterToTests[%d]) = _, %v, want _,%v", i, err, rw.expected)
- }
- }
-}
-
-func TestWriterReadFrom(t *testing.T) {
- ws := []func(io.Writer) io.Writer{
- func(w io.Writer) io.Writer { return onlyWriter{w} },
- func(w io.Writer) io.Writer { return w },
- }
-
- rs := []func(io.Reader) io.Reader{
- iotest.DataErrReader,
- func(r io.Reader) io.Reader { return r },
- }
-
- for ri, rfunc := range rs {
- for wi, wfunc := range ws {
- input := createTestInput(8192)
- b := new(bytes.Buffer)
- w := NewWriter(wfunc(b))
- r := rfunc(bytes.NewReader(input))
- if n, err := w.ReadFrom(r); err != nil || n != int64(len(input)) {
- t.Errorf("ws[%d],rs[%d]: w.ReadFrom(r) = %d, %v, want %d, nil", wi, ri, n, err, len(input))
- continue
- }
- if err := w.Flush(); err != nil {
- t.Errorf("Flush returned %v", err)
- continue
- }
- if got, want := b.String(), string(input); got != want {
- t.Errorf("ws[%d], rs[%d]:\ngot %q\nwant %q\n", wi, ri, got, want)
- }
- }
- }
-}
-
-type errorReaderFromTest struct {
- rn, wn int
- rerr, werr error
- expected error
-}
-
-func (r errorReaderFromTest) Read(p []byte) (int, error) {
- return len(p) * r.rn, r.rerr
-}
-
-func (w errorReaderFromTest) Write(p []byte) (int, error) {
- return len(p) * w.wn, w.werr
-}
-
-var errorReaderFromTests = []errorReaderFromTest{
- {0, 1, io.EOF, nil, nil},
- {1, 1, io.EOF, nil, nil},
- {0, 1, io.ErrClosedPipe, nil, io.ErrClosedPipe},
- {0, 0, io.ErrClosedPipe, io.ErrShortWrite, io.ErrClosedPipe},
- {1, 0, nil, io.ErrShortWrite, io.ErrShortWrite},
-}
-
-func TestWriterReadFromErrors(t *testing.T) {
- for i, rw := range errorReaderFromTests {
- w := NewWriter(rw)
- if _, err := w.ReadFrom(rw); err != rw.expected {
- t.Errorf("w.ReadFrom(errorReaderFromTests[%d]) = _, %v, want _,%v", i, err, rw.expected)
- }
- }
-}
-
-// TestWriterReadFromCounts tests that using io.Copy to copy into a
-// bufio.Writer does not prematurely flush the buffer. For example, when
-// buffering writes to a network socket, excessive network writes should be
-// avoided.
-func TestWriterReadFromCounts(t *testing.T) {
- var w0 writeCountingDiscard
- b0 := NewWriterSize(&w0, 1234)
- b0.WriteString(strings.Repeat("x", 1000))
- if w0 != 0 {
- t.Fatalf("write 1000 'x's: got %d writes, want 0", w0)
- }
- b0.WriteString(strings.Repeat("x", 200))
- if w0 != 0 {
- t.Fatalf("write 1200 'x's: got %d writes, want 0", w0)
- }
- io.Copy(b0, onlyReader{strings.NewReader(strings.Repeat("x", 30))})
- if w0 != 0 {
- t.Fatalf("write 1230 'x's: got %d writes, want 0", w0)
- }
- io.Copy(b0, onlyReader{strings.NewReader(strings.Repeat("x", 9))})
- if w0 != 1 {
- t.Fatalf("write 1239 'x's: got %d writes, want 1", w0)
- }
-
- var w1 writeCountingDiscard
- b1 := NewWriterSize(&w1, 1234)
- b1.WriteString(strings.Repeat("x", 1200))
- b1.Flush()
- if w1 != 1 {
- t.Fatalf("flush 1200 'x's: got %d writes, want 1", w1)
- }
- b1.WriteString(strings.Repeat("x", 89))
- if w1 != 1 {
- t.Fatalf("write 1200 + 89 'x's: got %d writes, want 1", w1)
- }
- io.Copy(b1, onlyReader{strings.NewReader(strings.Repeat("x", 700))})
- if w1 != 1 {
- t.Fatalf("write 1200 + 789 'x's: got %d writes, want 1", w1)
- }
- io.Copy(b1, onlyReader{strings.NewReader(strings.Repeat("x", 600))})
- if w1 != 2 {
- t.Fatalf("write 1200 + 1389 'x's: got %d writes, want 2", w1)
- }
- b1.Flush()
- if w1 != 3 {
- t.Fatalf("flush 1200 + 1389 'x's: got %d writes, want 3", w1)
- }
-}
-
-// A writeCountingDiscard is like ioutil.Discard and counts the number of times
-// Write is called on it.
-type writeCountingDiscard int
-
-func (w *writeCountingDiscard) Write(p []byte) (int, error) {
- *w++
- return len(p), nil
-}
-
-type negativeReader int
-
-func (r *negativeReader) Read([]byte) (int, error) { return -1, nil }
-
-func TestNegativeRead(t *testing.T) {
- // should panic with a description pointing at the reader, not at itself.
- // (should NOT panic with slice index error, for example.)
- b := NewReader(new(negativeReader))
- defer func() {
- switch err := recover().(type) {
- case nil:
- t.Fatal("read did not panic")
- case error:
- if !strings.Contains(err.Error(), "reader returned negative count from Read") {
- t.Fatalf("wrong panic: %v", err)
- }
- default:
- t.Fatalf("unexpected panic value: %T(%v)", err, err)
- }
- }()
- b.Read(make([]byte, 100))
-}
-
-var errFake = errors.New("fake error")
-
-type errorThenGoodReader struct {
- didErr bool
- nread int
-}
-
-func (r *errorThenGoodReader) Read(p []byte) (int, error) {
- r.nread++
- if !r.didErr {
- r.didErr = true
- return 0, errFake
- }
- return len(p), nil
-}
-
-func TestReaderClearError(t *testing.T) {
- r := &errorThenGoodReader{}
- b := NewReader(r)
- buf := make([]byte, 1)
- if _, err := b.Read(nil); err != nil {
- t.Fatalf("1st nil Read = %v; want nil", err)
- }
- if _, err := b.Read(buf); err != errFake {
- t.Fatalf("1st Read = %v; want errFake", err)
- }
- if _, err := b.Read(nil); err != nil {
- t.Fatalf("2nd nil Read = %v; want nil", err)
- }
- if _, err := b.Read(buf); err != nil {
- t.Fatalf("3rd Read with buffer = %v; want nil", err)
- }
- if r.nread != 2 {
- t.Errorf("num reads = %d; want 2", r.nread)
- }
-}
-
-// Test for golang.org/issue/5947
-func TestWriterReadFromWhileFull(t *testing.T) {
- buf := new(bytes.Buffer)
- w := NewWriterSize(buf, 10)
-
- // Fill buffer exactly.
- n, err := w.Write([]byte("0123456789"))
- if n != 10 || err != nil {
- t.Fatalf("Write returned (%v, %v), want (10, nil)", n, err)
- }
-
- // Use ReadFrom to read in some data.
- n2, err := w.ReadFrom(strings.NewReader("abcdef"))
- if n2 != 6 || err != nil {
- t.Fatalf("ReadFrom returned (%v, %v), want (6, nil)", n2, err)
- }
-}
-
-type emptyThenNonEmptyReader struct {
- r io.Reader
- n int
-}
-
-func (r *emptyThenNonEmptyReader) Read(p []byte) (int, error) {
- if r.n <= 0 {
- return r.r.Read(p)
- }
- r.n--
- return 0, nil
-}
-
-// Test for golang.org/issue/7611
-func TestWriterReadFromUntilEOF(t *testing.T) {
- buf := new(bytes.Buffer)
- w := NewWriterSize(buf, 5)
-
- // Partially fill buffer
- n, err := w.Write([]byte("0123"))
- if n != 4 || err != nil {
- t.Fatalf("Write returned (%v, %v), want (4, nil)", n, err)
- }
-
- // Use ReadFrom to read in some data.
- r := &emptyThenNonEmptyReader{r: strings.NewReader("abcd"), n: 3}
- n2, err := w.ReadFrom(r)
- if n2 != 4 || err != nil {
- t.Fatalf("ReadFrom returned (%v, %v), want (4, nil)", n2, err)
- }
- w.Flush()
- if got, want := string(buf.Bytes()), "0123abcd"; got != want {
- t.Fatalf("buf.Bytes() returned %q, want %q", got, want)
- }
-}
-
-func TestWriterReadFromErrNoProgress(t *testing.T) {
- buf := new(bytes.Buffer)
- w := NewWriterSize(buf, 5)
-
- // Partially fill buffer
- n, err := w.Write([]byte("0123"))
- if n != 4 || err != nil {
- t.Fatalf("Write returned (%v, %v), want (4, nil)", n, err)
- }
-
- // Use ReadFrom to read in some data.
- r := &emptyThenNonEmptyReader{r: strings.NewReader("abcd"), n: 100}
- n2, err := w.ReadFrom(r)
- if n2 != 0 || err != io.ErrNoProgress {
- t.Fatalf("buf.Bytes() returned (%v, %v), want (0, io.ErrNoProgress)", n2, err)
- }
-}
-
-func TestReaderReset(t *testing.T) {
- r := NewReader(strings.NewReader("foo foo"))
- buf := make([]byte, 3)
- r.Read(buf)
- if string(buf) != "foo" {
- t.Errorf("buf = %q; want foo", buf)
- }
- r.Reset(strings.NewReader("bar bar"))
- all, err := ioutil.ReadAll(r)
- if err != nil {
- t.Fatal(err)
- }
- if string(all) != "bar bar" {
- t.Errorf("ReadAll = %q; want bar bar", all)
- }
-}
-
-func TestWriterReset(t *testing.T) {
- var buf1, buf2 bytes.Buffer
- w := NewWriter(&buf1)
- w.WriteString("foo")
- w.Reset(&buf2) // and not flushed
- w.WriteString("bar")
- w.Flush()
- if buf1.String() != "" {
- t.Errorf("buf1 = %q; want empty", buf1.String())
- }
- if buf2.String() != "bar" {
- t.Errorf("buf2 = %q; want bar", buf2.String())
- }
-}
-
-// An onlyReader only implements io.Reader, no matter what other methods the underlying implementation may have.
-type onlyReader struct {
- io.Reader
-}
-
-// An onlyWriter only implements io.Writer, no matter what other methods the underlying implementation may have.
-type onlyWriter struct {
- io.Writer
-}
-
-func BenchmarkReaderCopyOptimal(b *testing.B) {
- // Optimal case is where the underlying reader implements io.WriterTo
- srcBuf := bytes.NewBuffer(make([]byte, 8192))
- src := NewReader(srcBuf)
- dstBuf := new(bytes.Buffer)
- dst := onlyWriter{dstBuf}
- for i := 0; i < b.N; i++ {
- srcBuf.Reset()
- src.Reset(srcBuf)
- dstBuf.Reset()
- io.Copy(dst, src)
- }
-}
-
-func BenchmarkReaderCopyUnoptimal(b *testing.B) {
- // Unoptimal case is where the underlying reader doesn't implement io.WriterTo
- srcBuf := bytes.NewBuffer(make([]byte, 8192))
- src := NewReader(onlyReader{srcBuf})
- dstBuf := new(bytes.Buffer)
- dst := onlyWriter{dstBuf}
- for i := 0; i < b.N; i++ {
- srcBuf.Reset()
- src.Reset(onlyReader{srcBuf})
- dstBuf.Reset()
- io.Copy(dst, src)
- }
-}
-
-func BenchmarkReaderCopyNoWriteTo(b *testing.B) {
- srcBuf := bytes.NewBuffer(make([]byte, 8192))
- srcReader := NewReader(srcBuf)
- src := onlyReader{srcReader}
- dstBuf := new(bytes.Buffer)
- dst := onlyWriter{dstBuf}
- for i := 0; i < b.N; i++ {
- srcBuf.Reset()
- srcReader.Reset(srcBuf)
- dstBuf.Reset()
- io.Copy(dst, src)
- }
-}
-
-func BenchmarkReaderWriteToOptimal(b *testing.B) {
- const bufSize = 16 << 10
- buf := make([]byte, bufSize)
- r := bytes.NewReader(buf)
- srcReader := NewReaderSize(onlyReader{r}, 1<<10)
- if _, ok := ioutil.Discard.(io.ReaderFrom); !ok {
- b.Fatal("ioutil.Discard doesn't support ReaderFrom")
- }
- for i := 0; i < b.N; i++ {
- r.Seek(0, 0)
- srcReader.Reset(onlyReader{r})
- n, err := srcReader.WriteTo(ioutil.Discard)
- if err != nil {
- b.Fatal(err)
- }
- if n != bufSize {
- b.Fatalf("n = %d; want %d", n, bufSize)
- }
- }
-}
-
-func BenchmarkWriterCopyOptimal(b *testing.B) {
- // Optimal case is where the underlying writer implements io.ReaderFrom
- srcBuf := bytes.NewBuffer(make([]byte, 8192))
- src := onlyReader{srcBuf}
- dstBuf := new(bytes.Buffer)
- dst := NewWriter(dstBuf)
- for i := 0; i < b.N; i++ {
- srcBuf.Reset()
- dstBuf.Reset()
- dst.Reset(dstBuf)
- io.Copy(dst, src)
- }
-}
-
-func BenchmarkWriterCopyUnoptimal(b *testing.B) {
- srcBuf := bytes.NewBuffer(make([]byte, 8192))
- src := onlyReader{srcBuf}
- dstBuf := new(bytes.Buffer)
- dst := NewWriter(onlyWriter{dstBuf})
- for i := 0; i < b.N; i++ {
- srcBuf.Reset()
- dstBuf.Reset()
- dst.Reset(onlyWriter{dstBuf})
- io.Copy(dst, src)
- }
-}
-
-func BenchmarkWriterCopyNoReadFrom(b *testing.B) {
- srcBuf := bytes.NewBuffer(make([]byte, 8192))
- src := onlyReader{srcBuf}
- dstBuf := new(bytes.Buffer)
- dstWriter := NewWriter(dstBuf)
- dst := onlyWriter{dstWriter}
- for i := 0; i < b.N; i++ {
- srcBuf.Reset()
- dstBuf.Reset()
- dstWriter.Reset(dstBuf)
- io.Copy(dst, src)
- }
-}
-
-func BenchmarkReaderEmpty(b *testing.B) {
- b.ReportAllocs()
- str := strings.Repeat("x", 16<<10)
- for i := 0; i < b.N; i++ {
- br := NewReader(strings.NewReader(str))
- n, err := io.Copy(ioutil.Discard, br)
- if err != nil {
- b.Fatal(err)
- }
- if n != int64(len(str)) {
- b.Fatal("wrong length")
- }
- }
-}
-
-func BenchmarkWriterEmpty(b *testing.B) {
- b.ReportAllocs()
- str := strings.Repeat("x", 1<<10)
- bs := []byte(str)
- for i := 0; i < b.N; i++ {
- bw := NewWriter(ioutil.Discard)
- bw.Flush()
- bw.WriteByte('a')
- bw.Flush()
- bw.WriteRune('B')
- bw.Flush()
- bw.Write(bs)
- bw.Flush()
- bw.WriteString(str)
- bw.Flush()
- }
-}
-
-func BenchmarkWriterFlush(b *testing.B) {
- b.ReportAllocs()
- bw := NewWriter(ioutil.Discard)
- str := strings.Repeat("x", 50)
- for i := 0; i < b.N; i++ {
- bw.WriteString(str)
- bw.Flush()
- }
-}
diff --git a/Godeps/_workspace/src/gopkg.in/bufio.v1/export_test.go b/Godeps/_workspace/src/gopkg.in/bufio.v1/export_test.go
deleted file mode 100644
index 16629d022..000000000
--- a/Godeps/_workspace/src/gopkg.in/bufio.v1/export_test.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bufio
-
-func (b *Buffer) Cap() int {
- return cap(b.buf)
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/.travis.yml b/Godeps/_workspace/src/gopkg.in/redis.v2/.travis.yml
deleted file mode 100644
index c3cf4b8a6..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/.travis.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-language: go
-
-services:
-- redis-server
-
-go:
- - 1.1
- - 1.2
- - 1.3
- - tip
-
-install:
- - go get gopkg.in/bufio.v1
- - go get gopkg.in/check.v1
- - mkdir -p $HOME/gopath/src/gopkg.in
- - ln -s `pwd` $HOME/gopath/src/gopkg.in/redis.v2
-
-before_script:
- - redis-server testdata/sentinel.conf --sentinel &
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/LICENSE b/Godeps/_workspace/src/gopkg.in/redis.v2/LICENSE
deleted file mode 100644
index 6855a95fe..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2012 The Redis Go Client Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/Makefile b/Godeps/_workspace/src/gopkg.in/redis.v2/Makefile
deleted file mode 100644
index b250d9bfa..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-all:
- go test gopkg.in/redis.v2 -cpu=1,2,4
- go test gopkg.in/redis.v2 -short -race
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/README.md b/Godeps/_workspace/src/gopkg.in/redis.v2/README.md
deleted file mode 100644
index ddf875f9a..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-Redis client for Golang [![Build Status](https://travis-ci.org/go-redis/redis.png?branch=master)](https://travis-ci.org/go-redis/redis)
-=======================
-
-Supports:
-
-- Redis 2.8 commands except QUIT, MONITOR, SLOWLOG and SYNC.
-- Pub/sub.
-- Transactions.
-- Pipelining.
-- Connection pool.
-- TLS connections.
-- Thread safety.
-- Timeouts.
-- Redis Sentinel.
-
-API docs: http://godoc.org/gopkg.in/redis.v2.
-Examples: http://godoc.org/gopkg.in/redis.v2#pkg-examples.
-
-Installation
-------------
-
-Install:
-
- go get gopkg.in/redis.v2
-
-Look and feel
--------------
-
-Some corner cases:
-
- SORT list LIMIT 0 2 ASC
- vals, err := client.Sort("list", redis.Sort{Offset: 0, Count: 2, Order: "ASC"}).Result()
-
- ZRANGEBYSCORE zset -inf +inf WITHSCORES LIMIT 0 2
- vals, err := client.ZRangeByScoreWithScores("zset", redis.ZRangeByScore{
- Min: "-inf",
- Max: "+inf",
- Offset: 0,
- Count: 2,
- }).Result()
-
- ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 AGGREGATE SUM
- vals, err := client.ZInterStore("out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2").Result()
-
- EVAL "return {KEYS[1],ARGV[1]}" 1 "key" "hello"
- vals, err := client.Eval("return {KEYS[1],ARGV[1]}", []string{"key"}, []string{"hello"}).Result()
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/command.go b/Godeps/_workspace/src/gopkg.in/redis.v2/command.go
deleted file mode 100644
index d7c76cf92..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/command.go
+++ /dev/null
@@ -1,597 +0,0 @@
-package redis
-
-import (
- "fmt"
- "strconv"
- "strings"
- "time"
-
- "gopkg.in/bufio.v1"
-)
-
-var (
- _ Cmder = (*Cmd)(nil)
- _ Cmder = (*SliceCmd)(nil)
- _ Cmder = (*StatusCmd)(nil)
- _ Cmder = (*IntCmd)(nil)
- _ Cmder = (*DurationCmd)(nil)
- _ Cmder = (*BoolCmd)(nil)
- _ Cmder = (*StringCmd)(nil)
- _ Cmder = (*FloatCmd)(nil)
- _ Cmder = (*StringSliceCmd)(nil)
- _ Cmder = (*BoolSliceCmd)(nil)
- _ Cmder = (*StringStringMapCmd)(nil)
- _ Cmder = (*ZSliceCmd)(nil)
- _ Cmder = (*ScanCmd)(nil)
-)
-
-type Cmder interface {
- args() []string
- parseReply(*bufio.Reader) error
- setErr(error)
-
- writeTimeout() *time.Duration
- readTimeout() *time.Duration
-
- Err() error
- String() string
-}
-
-func setCmdsErr(cmds []Cmder, e error) {
- for _, cmd := range cmds {
- cmd.setErr(e)
- }
-}
-
-func cmdString(cmd Cmder, val interface{}) string {
- s := strings.Join(cmd.args(), " ")
- if err := cmd.Err(); err != nil {
- return s + ": " + err.Error()
- }
- if val != nil {
- return s + ": " + fmt.Sprint(val)
- }
- return s
-
-}
-
-//------------------------------------------------------------------------------
-
-type baseCmd struct {
- _args []string
-
- err error
-
- _writeTimeout, _readTimeout *time.Duration
-}
-
-func newBaseCmd(args ...string) *baseCmd {
- return &baseCmd{
- _args: args,
- }
-}
-
-func (cmd *baseCmd) Err() error {
- if cmd.err != nil {
- return cmd.err
- }
- return nil
-}
-
-func (cmd *baseCmd) args() []string {
- return cmd._args
-}
-
-func (cmd *baseCmd) readTimeout() *time.Duration {
- return cmd._readTimeout
-}
-
-func (cmd *baseCmd) setReadTimeout(d time.Duration) {
- cmd._readTimeout = &d
-}
-
-func (cmd *baseCmd) writeTimeout() *time.Duration {
- return cmd._writeTimeout
-}
-
-func (cmd *baseCmd) setWriteTimeout(d time.Duration) {
- cmd._writeTimeout = &d
-}
-
-func (cmd *baseCmd) setErr(e error) {
- cmd.err = e
-}
-
-//------------------------------------------------------------------------------
-
-type Cmd struct {
- *baseCmd
-
- val interface{}
-}
-
-func NewCmd(args ...string) *Cmd {
- return &Cmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *Cmd) Val() interface{} {
- return cmd.val
-}
-
-func (cmd *Cmd) Result() (interface{}, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *Cmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *Cmd) parseReply(rd *bufio.Reader) error {
- cmd.val, cmd.err = parseReply(rd, parseSlice)
- return cmd.err
-}
-
-//------------------------------------------------------------------------------
-
-type SliceCmd struct {
- *baseCmd
-
- val []interface{}
-}
-
-func NewSliceCmd(args ...string) *SliceCmd {
- return &SliceCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *SliceCmd) Val() []interface{} {
- return cmd.val
-}
-
-func (cmd *SliceCmd) Result() ([]interface{}, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *SliceCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *SliceCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, parseSlice)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.([]interface{})
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type StatusCmd struct {
- *baseCmd
-
- val string
-}
-
-func NewStatusCmd(args ...string) *StatusCmd {
- return &StatusCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *StatusCmd) Val() string {
- return cmd.val
-}
-
-func (cmd *StatusCmd) Result() (string, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *StatusCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *StatusCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, nil)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.(string)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type IntCmd struct {
- *baseCmd
-
- val int64
-}
-
-func NewIntCmd(args ...string) *IntCmd {
- return &IntCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *IntCmd) Val() int64 {
- return cmd.val
-}
-
-func (cmd *IntCmd) Result() (int64, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *IntCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *IntCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, nil)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.(int64)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type DurationCmd struct {
- *baseCmd
-
- val time.Duration
- precision time.Duration
-}
-
-func NewDurationCmd(precision time.Duration, args ...string) *DurationCmd {
- return &DurationCmd{
- baseCmd: newBaseCmd(args...),
- precision: precision,
- }
-}
-
-func (cmd *DurationCmd) Val() time.Duration {
- return cmd.val
-}
-
-func (cmd *DurationCmd) Result() (time.Duration, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *DurationCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *DurationCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, nil)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = time.Duration(v.(int64)) * cmd.precision
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type BoolCmd struct {
- *baseCmd
-
- val bool
-}
-
-func NewBoolCmd(args ...string) *BoolCmd {
- return &BoolCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *BoolCmd) Val() bool {
- return cmd.val
-}
-
-func (cmd *BoolCmd) Result() (bool, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *BoolCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *BoolCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, nil)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.(int64) == 1
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type StringCmd struct {
- *baseCmd
-
- val string
-}
-
-func NewStringCmd(args ...string) *StringCmd {
- return &StringCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *StringCmd) Val() string {
- return cmd.val
-}
-
-func (cmd *StringCmd) Result() (string, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *StringCmd) Int64() (int64, error) {
- if cmd.err != nil {
- return 0, cmd.err
- }
- return strconv.ParseInt(cmd.val, 10, 64)
-}
-
-func (cmd *StringCmd) Uint64() (uint64, error) {
- if cmd.err != nil {
- return 0, cmd.err
- }
- return strconv.ParseUint(cmd.val, 10, 64)
-}
-
-func (cmd *StringCmd) Float64() (float64, error) {
- if cmd.err != nil {
- return 0, cmd.err
- }
- return strconv.ParseFloat(cmd.val, 64)
-}
-
-func (cmd *StringCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *StringCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, nil)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.(string)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type FloatCmd struct {
- *baseCmd
-
- val float64
-}
-
-func NewFloatCmd(args ...string) *FloatCmd {
- return &FloatCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *FloatCmd) Val() float64 {
- return cmd.val
-}
-
-func (cmd *FloatCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *FloatCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, nil)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val, cmd.err = strconv.ParseFloat(v.(string), 64)
- return cmd.err
-}
-
-//------------------------------------------------------------------------------
-
-type StringSliceCmd struct {
- *baseCmd
-
- val []string
-}
-
-func NewStringSliceCmd(args ...string) *StringSliceCmd {
- return &StringSliceCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *StringSliceCmd) Val() []string {
- return cmd.val
-}
-
-func (cmd *StringSliceCmd) Result() ([]string, error) {
- return cmd.Val(), cmd.Err()
-}
-
-func (cmd *StringSliceCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *StringSliceCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, parseStringSlice)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.([]string)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type BoolSliceCmd struct {
- *baseCmd
-
- val []bool
-}
-
-func NewBoolSliceCmd(args ...string) *BoolSliceCmd {
- return &BoolSliceCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *BoolSliceCmd) Val() []bool {
- return cmd.val
-}
-
-func (cmd *BoolSliceCmd) Result() ([]bool, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *BoolSliceCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *BoolSliceCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, parseBoolSlice)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.([]bool)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type StringStringMapCmd struct {
- *baseCmd
-
- val map[string]string
-}
-
-func NewStringStringMapCmd(args ...string) *StringStringMapCmd {
- return &StringStringMapCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *StringStringMapCmd) Val() map[string]string {
- return cmd.val
-}
-
-func (cmd *StringStringMapCmd) Result() (map[string]string, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *StringStringMapCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *StringStringMapCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, parseStringStringMap)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.(map[string]string)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type ZSliceCmd struct {
- *baseCmd
-
- val []Z
-}
-
-func NewZSliceCmd(args ...string) *ZSliceCmd {
- return &ZSliceCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *ZSliceCmd) Val() []Z {
- return cmd.val
-}
-
-func (cmd *ZSliceCmd) Result() ([]Z, error) {
- return cmd.val, cmd.err
-}
-
-func (cmd *ZSliceCmd) String() string {
- return cmdString(cmd, cmd.val)
-}
-
-func (cmd *ZSliceCmd) parseReply(rd *bufio.Reader) error {
- v, err := parseReply(rd, parseZSlice)
- if err != nil {
- cmd.err = err
- return err
- }
- cmd.val = v.([]Z)
- return nil
-}
-
-//------------------------------------------------------------------------------
-
-type ScanCmd struct {
- *baseCmd
-
- cursor int64
- keys []string
-}
-
-func NewScanCmd(args ...string) *ScanCmd {
- return &ScanCmd{
- baseCmd: newBaseCmd(args...),
- }
-}
-
-func (cmd *ScanCmd) Val() (int64, []string) {
- return cmd.cursor, cmd.keys
-}
-
-func (cmd *ScanCmd) Result() (int64, []string, error) {
- return cmd.cursor, cmd.keys, cmd.err
-}
-
-func (cmd *ScanCmd) String() string {
- return cmdString(cmd, cmd.keys)
-}
-
-func (cmd *ScanCmd) parseReply(rd *bufio.Reader) error {
- vi, err := parseReply(rd, parseSlice)
- if err != nil {
- cmd.err = err
- return cmd.err
- }
- v := vi.([]interface{})
-
- cmd.cursor, cmd.err = strconv.ParseInt(v[0].(string), 10, 64)
- if cmd.err != nil {
- return cmd.err
- }
-
- keys := v[1].([]interface{})
- for _, keyi := range keys {
- cmd.keys = append(cmd.keys, keyi.(string))
- }
-
- return nil
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/commands.go b/Godeps/_workspace/src/gopkg.in/redis.v2/commands.go
deleted file mode 100644
index 6068bab17..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/commands.go
+++ /dev/null
@@ -1,1246 +0,0 @@
-package redis
-
-import (
- "io"
- "strconv"
- "time"
-)
-
-func formatFloat(f float64) string {
- return strconv.FormatFloat(f, 'f', -1, 64)
-}
-
-func readTimeout(sec int64) time.Duration {
- if sec == 0 {
- return 0
- }
- return time.Duration(sec+1) * time.Second
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) Auth(password string) *StatusCmd {
- cmd := NewStatusCmd("AUTH", password)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Echo(message string) *StringCmd {
- cmd := NewStringCmd("ECHO", message)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Ping() *StatusCmd {
- cmd := NewStatusCmd("PING")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Quit() *StatusCmd {
- panic("not implemented")
-}
-
-func (c *Client) Select(index int64) *StatusCmd {
- cmd := NewStatusCmd("SELECT", strconv.FormatInt(index, 10))
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) Del(keys ...string) *IntCmd {
- args := append([]string{"DEL"}, keys...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Dump(key string) *StringCmd {
- cmd := NewStringCmd("DUMP", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Exists(key string) *BoolCmd {
- cmd := NewBoolCmd("EXISTS", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Expire(key string, dur time.Duration) *BoolCmd {
- cmd := NewBoolCmd("EXPIRE", key, strconv.FormatInt(int64(dur/time.Second), 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ExpireAt(key string, tm time.Time) *BoolCmd {
- cmd := NewBoolCmd("EXPIREAT", key, strconv.FormatInt(tm.Unix(), 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Keys(pattern string) *StringSliceCmd {
- cmd := NewStringSliceCmd("KEYS", pattern)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Migrate(host, port, key string, db, timeout int64) *StatusCmd {
- cmd := NewStatusCmd(
- "MIGRATE",
- host,
- port,
- key,
- strconv.FormatInt(db, 10),
- strconv.FormatInt(timeout, 10),
- )
- cmd.setReadTimeout(readTimeout(timeout))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Move(key string, db int64) *BoolCmd {
- cmd := NewBoolCmd("MOVE", key, strconv.FormatInt(db, 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ObjectRefCount(keys ...string) *IntCmd {
- args := append([]string{"OBJECT", "REFCOUNT"}, keys...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ObjectEncoding(keys ...string) *StringCmd {
- args := append([]string{"OBJECT", "ENCODING"}, keys...)
- cmd := NewStringCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ObjectIdleTime(keys ...string) *DurationCmd {
- args := append([]string{"OBJECT", "IDLETIME"}, keys...)
- cmd := NewDurationCmd(time.Second, args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Persist(key string) *BoolCmd {
- cmd := NewBoolCmd("PERSIST", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) PExpire(key string, dur time.Duration) *BoolCmd {
- cmd := NewBoolCmd("PEXPIRE", key, strconv.FormatInt(int64(dur/time.Millisecond), 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) PExpireAt(key string, tm time.Time) *BoolCmd {
- cmd := NewBoolCmd(
- "PEXPIREAT",
- key,
- strconv.FormatInt(tm.UnixNano()/int64(time.Millisecond), 10),
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) PTTL(key string) *DurationCmd {
- cmd := NewDurationCmd(time.Millisecond, "PTTL", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) RandomKey() *StringCmd {
- cmd := NewStringCmd("RANDOMKEY")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Rename(key, newkey string) *StatusCmd {
- cmd := NewStatusCmd("RENAME", key, newkey)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) RenameNX(key, newkey string) *BoolCmd {
- cmd := NewBoolCmd("RENAMENX", key, newkey)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Restore(key string, ttl int64, value string) *StatusCmd {
- cmd := NewStatusCmd(
- "RESTORE",
- key,
- strconv.FormatInt(ttl, 10),
- value,
- )
- c.Process(cmd)
- return cmd
-}
-
-type Sort struct {
- By string
- Offset, Count float64
- Get []string
- Order string
- IsAlpha bool
- Store string
-}
-
-func (c *Client) Sort(key string, sort Sort) *StringSliceCmd {
- args := []string{"SORT", key}
- if sort.By != "" {
- args = append(args, "BY", sort.By)
- }
- if sort.Offset != 0 || sort.Count != 0 {
- args = append(args, "LIMIT", formatFloat(sort.Offset), formatFloat(sort.Count))
- }
- for _, get := range sort.Get {
- args = append(args, "GET", get)
- }
- if sort.Order != "" {
- args = append(args, sort.Order)
- }
- if sort.IsAlpha {
- args = append(args, "ALPHA")
- }
- if sort.Store != "" {
- args = append(args, "STORE", sort.Store)
- }
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) TTL(key string) *DurationCmd {
- cmd := NewDurationCmd(time.Second, "TTL", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Type(key string) *StatusCmd {
- cmd := NewStatusCmd("TYPE", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Scan(cursor int64, match string, count int64) *ScanCmd {
- args := []string{"SCAN", strconv.FormatInt(cursor, 10)}
- if match != "" {
- args = append(args, "MATCH", match)
- }
- if count > 0 {
- args = append(args, "COUNT", strconv.FormatInt(count, 10))
- }
- cmd := NewScanCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SScan(key string, cursor int64, match string, count int64) *ScanCmd {
- args := []string{"SSCAN", key, strconv.FormatInt(cursor, 10)}
- if match != "" {
- args = append(args, "MATCH", match)
- }
- if count > 0 {
- args = append(args, "COUNT", strconv.FormatInt(count, 10))
- }
- cmd := NewScanCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HScan(key string, cursor int64, match string, count int64) *ScanCmd {
- args := []string{"HSCAN", key, strconv.FormatInt(cursor, 10)}
- if match != "" {
- args = append(args, "MATCH", match)
- }
- if count > 0 {
- args = append(args, "COUNT", strconv.FormatInt(count, 10))
- }
- cmd := NewScanCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZScan(key string, cursor int64, match string, count int64) *ScanCmd {
- args := []string{"ZSCAN", key, strconv.FormatInt(cursor, 10)}
- if match != "" {
- args = append(args, "MATCH", match)
- }
- if count > 0 {
- args = append(args, "COUNT", strconv.FormatInt(count, 10))
- }
- cmd := NewScanCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) Append(key, value string) *IntCmd {
- cmd := NewIntCmd("APPEND", key, value)
- c.Process(cmd)
- return cmd
-}
-
-type BitCount struct {
- Start, End int64
-}
-
-func (c *Client) BitCount(key string, bitCount *BitCount) *IntCmd {
- args := []string{"BITCOUNT", key}
- if bitCount != nil {
- args = append(
- args,
- strconv.FormatInt(bitCount.Start, 10),
- strconv.FormatInt(bitCount.End, 10),
- )
- }
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) bitOp(op, destKey string, keys ...string) *IntCmd {
- args := []string{"BITOP", op, destKey}
- args = append(args, keys...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) BitOpAnd(destKey string, keys ...string) *IntCmd {
- return c.bitOp("AND", destKey, keys...)
-}
-
-func (c *Client) BitOpOr(destKey string, keys ...string) *IntCmd {
- return c.bitOp("OR", destKey, keys...)
-}
-
-func (c *Client) BitOpXor(destKey string, keys ...string) *IntCmd {
- return c.bitOp("XOR", destKey, keys...)
-}
-
-func (c *Client) BitOpNot(destKey string, key string) *IntCmd {
- return c.bitOp("NOT", destKey, key)
-}
-
-func (c *Client) Decr(key string) *IntCmd {
- cmd := NewIntCmd("DECR", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) DecrBy(key string, decrement int64) *IntCmd {
- cmd := NewIntCmd("DECRBY", key, strconv.FormatInt(decrement, 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Get(key string) *StringCmd {
- cmd := NewStringCmd("GET", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) GetBit(key string, offset int64) *IntCmd {
- cmd := NewIntCmd("GETBIT", key, strconv.FormatInt(offset, 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) GetRange(key string, start, end int64) *StringCmd {
- cmd := NewStringCmd(
- "GETRANGE",
- key,
- strconv.FormatInt(start, 10),
- strconv.FormatInt(end, 10),
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) GetSet(key, value string) *StringCmd {
- cmd := NewStringCmd("GETSET", key, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Incr(key string) *IntCmd {
- cmd := NewIntCmd("INCR", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) IncrBy(key string, value int64) *IntCmd {
- cmd := NewIntCmd("INCRBY", key, strconv.FormatInt(value, 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) IncrByFloat(key string, value float64) *FloatCmd {
- cmd := NewFloatCmd("INCRBYFLOAT", key, formatFloat(value))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) MGet(keys ...string) *SliceCmd {
- args := append([]string{"MGET"}, keys...)
- cmd := NewSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) MSet(pairs ...string) *StatusCmd {
- args := append([]string{"MSET"}, pairs...)
- cmd := NewStatusCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) MSetNX(pairs ...string) *BoolCmd {
- args := append([]string{"MSETNX"}, pairs...)
- cmd := NewBoolCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) PSetEx(key string, dur time.Duration, value string) *StatusCmd {
- cmd := NewStatusCmd(
- "PSETEX",
- key,
- strconv.FormatInt(int64(dur/time.Millisecond), 10),
- value,
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Set(key, value string) *StatusCmd {
- cmd := NewStatusCmd("SET", key, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SetBit(key string, offset int64, value int) *IntCmd {
- cmd := NewIntCmd(
- "SETBIT",
- key,
- strconv.FormatInt(offset, 10),
- strconv.FormatInt(int64(value), 10),
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SetEx(key string, dur time.Duration, value string) *StatusCmd {
- cmd := NewStatusCmd("SETEX", key, strconv.FormatInt(int64(dur/time.Second), 10), value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SetNX(key, value string) *BoolCmd {
- cmd := NewBoolCmd("SETNX", key, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SetRange(key string, offset int64, value string) *IntCmd {
- cmd := NewIntCmd("SETRANGE", key, strconv.FormatInt(offset, 10), value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) StrLen(key string) *IntCmd {
- cmd := NewIntCmd("STRLEN", key)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) HDel(key string, fields ...string) *IntCmd {
- args := append([]string{"HDEL", key}, fields...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HExists(key, field string) *BoolCmd {
- cmd := NewBoolCmd("HEXISTS", key, field)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HGet(key, field string) *StringCmd {
- cmd := NewStringCmd("HGET", key, field)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HGetAll(key string) *StringSliceCmd {
- cmd := NewStringSliceCmd("HGETALL", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HGetAllMap(key string) *StringStringMapCmd {
- cmd := NewStringStringMapCmd("HGETALL", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HIncrBy(key, field string, incr int64) *IntCmd {
- cmd := NewIntCmd("HINCRBY", key, field, strconv.FormatInt(incr, 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HIncrByFloat(key, field string, incr float64) *FloatCmd {
- cmd := NewFloatCmd("HINCRBYFLOAT", key, field, formatFloat(incr))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HKeys(key string) *StringSliceCmd {
- cmd := NewStringSliceCmd("HKEYS", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HLen(key string) *IntCmd {
- cmd := NewIntCmd("HLEN", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HMGet(key string, fields ...string) *SliceCmd {
- args := append([]string{"HMGET", key}, fields...)
- cmd := NewSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HMSet(key, field, value string, pairs ...string) *StatusCmd {
- args := append([]string{"HMSET", key, field, value}, pairs...)
- cmd := NewStatusCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HSet(key, field, value string) *BoolCmd {
- cmd := NewBoolCmd("HSET", key, field, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HSetNX(key, field, value string) *BoolCmd {
- cmd := NewBoolCmd("HSETNX", key, field, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) HVals(key string) *StringSliceCmd {
- cmd := NewStringSliceCmd("HVALS", key)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) BLPop(timeout int64, keys ...string) *StringSliceCmd {
- args := append([]string{"BLPOP"}, keys...)
- args = append(args, strconv.FormatInt(timeout, 10))
- cmd := NewStringSliceCmd(args...)
- cmd.setReadTimeout(readTimeout(timeout))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) BRPop(timeout int64, keys ...string) *StringSliceCmd {
- args := append([]string{"BRPOP"}, keys...)
- args = append(args, strconv.FormatInt(timeout, 10))
- cmd := NewStringSliceCmd(args...)
- cmd.setReadTimeout(readTimeout(timeout))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) BRPopLPush(source, destination string, timeout int64) *StringCmd {
- cmd := NewStringCmd(
- "BRPOPLPUSH",
- source,
- destination,
- strconv.FormatInt(timeout, 10),
- )
- cmd.setReadTimeout(readTimeout(timeout))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LIndex(key string, index int64) *StringCmd {
- cmd := NewStringCmd("LINDEX", key, strconv.FormatInt(index, 10))
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LInsert(key, op, pivot, value string) *IntCmd {
- cmd := NewIntCmd("LINSERT", key, op, pivot, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LLen(key string) *IntCmd {
- cmd := NewIntCmd("LLEN", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LPop(key string) *StringCmd {
- cmd := NewStringCmd("LPOP", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LPush(key string, values ...string) *IntCmd {
- args := append([]string{"LPUSH", key}, values...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LPushX(key, value string) *IntCmd {
- cmd := NewIntCmd("LPUSHX", key, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LRange(key string, start, stop int64) *StringSliceCmd {
- cmd := NewStringSliceCmd(
- "LRANGE",
- key,
- strconv.FormatInt(start, 10),
- strconv.FormatInt(stop, 10),
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LRem(key string, count int64, value string) *IntCmd {
- cmd := NewIntCmd("LREM", key, strconv.FormatInt(count, 10), value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LSet(key string, index int64, value string) *StatusCmd {
- cmd := NewStatusCmd("LSET", key, strconv.FormatInt(index, 10), value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LTrim(key string, start, stop int64) *StatusCmd {
- cmd := NewStatusCmd(
- "LTRIM",
- key,
- strconv.FormatInt(start, 10),
- strconv.FormatInt(stop, 10),
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) RPop(key string) *StringCmd {
- cmd := NewStringCmd("RPOP", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) RPopLPush(source, destination string) *StringCmd {
- cmd := NewStringCmd("RPOPLPUSH", source, destination)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) RPush(key string, values ...string) *IntCmd {
- args := append([]string{"RPUSH", key}, values...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) RPushX(key string, value string) *IntCmd {
- cmd := NewIntCmd("RPUSHX", key, value)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) SAdd(key string, members ...string) *IntCmd {
- args := append([]string{"SADD", key}, members...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SCard(key string) *IntCmd {
- cmd := NewIntCmd("SCARD", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SDiff(keys ...string) *StringSliceCmd {
- args := append([]string{"SDIFF"}, keys...)
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SDiffStore(destination string, keys ...string) *IntCmd {
- args := append([]string{"SDIFFSTORE", destination}, keys...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SInter(keys ...string) *StringSliceCmd {
- args := append([]string{"SINTER"}, keys...)
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SInterStore(destination string, keys ...string) *IntCmd {
- args := append([]string{"SINTERSTORE", destination}, keys...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SIsMember(key, member string) *BoolCmd {
- cmd := NewBoolCmd("SISMEMBER", key, member)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SMembers(key string) *StringSliceCmd {
- cmd := NewStringSliceCmd("SMEMBERS", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SMove(source, destination, member string) *BoolCmd {
- cmd := NewBoolCmd("SMOVE", source, destination, member)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SPop(key string) *StringCmd {
- cmd := NewStringCmd("SPOP", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SRandMember(key string) *StringCmd {
- cmd := NewStringCmd("SRANDMEMBER", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SRem(key string, members ...string) *IntCmd {
- args := append([]string{"SREM", key}, members...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SUnion(keys ...string) *StringSliceCmd {
- args := append([]string{"SUNION"}, keys...)
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SUnionStore(destination string, keys ...string) *IntCmd {
- args := append([]string{"SUNIONSTORE", destination}, keys...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-type Z struct {
- Score float64
- Member string
-}
-
-type ZStore struct {
- Weights []int64
- Aggregate string
-}
-
-func (c *Client) ZAdd(key string, members ...Z) *IntCmd {
- args := []string{"ZADD", key}
- for _, m := range members {
- args = append(args, formatFloat(m.Score), m.Member)
- }
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZCard(key string) *IntCmd {
- cmd := NewIntCmd("ZCARD", key)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZCount(key, min, max string) *IntCmd {
- cmd := NewIntCmd("ZCOUNT", key, min, max)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZIncrBy(key string, increment float64, member string) *FloatCmd {
- cmd := NewFloatCmd("ZINCRBY", key, formatFloat(increment), member)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZInterStore(
- destination string,
- store ZStore,
- keys ...string,
-) *IntCmd {
- args := []string{"ZINTERSTORE", destination, strconv.FormatInt(int64(len(keys)), 10)}
- args = append(args, keys...)
- if len(store.Weights) > 0 {
- args = append(args, "WEIGHTS")
- for _, weight := range store.Weights {
- args = append(args, strconv.FormatInt(weight, 10))
- }
- }
- if store.Aggregate != "" {
- args = append(args, "AGGREGATE", store.Aggregate)
- }
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) zRange(key string, start, stop int64, withScores bool) *StringSliceCmd {
- args := []string{
- "ZRANGE",
- key,
- strconv.FormatInt(start, 10),
- strconv.FormatInt(stop, 10),
- }
- if withScores {
- args = append(args, "WITHSCORES")
- }
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRange(key string, start, stop int64) *StringSliceCmd {
- return c.zRange(key, start, stop, false)
-}
-
-func (c *Client) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd {
- args := []string{
- "ZRANGE",
- key,
- strconv.FormatInt(start, 10),
- strconv.FormatInt(stop, 10),
- "WITHSCORES",
- }
- cmd := NewZSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-type ZRangeByScore struct {
- Min, Max string
-
- Offset, Count int64
-}
-
-func (c *Client) zRangeByScore(key string, opt ZRangeByScore, withScores bool) *StringSliceCmd {
- args := []string{"ZRANGEBYSCORE", key, opt.Min, opt.Max}
- if withScores {
- args = append(args, "WITHSCORES")
- }
- if opt.Offset != 0 || opt.Count != 0 {
- args = append(
- args,
- "LIMIT",
- strconv.FormatInt(opt.Offset, 10),
- strconv.FormatInt(opt.Count, 10),
- )
- }
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRangeByScore(key string, opt ZRangeByScore) *StringSliceCmd {
- return c.zRangeByScore(key, opt, false)
-}
-
-func (c *Client) ZRangeByScoreWithScores(key string, opt ZRangeByScore) *ZSliceCmd {
- args := []string{"ZRANGEBYSCORE", key, opt.Min, opt.Max, "WITHSCORES"}
- if opt.Offset != 0 || opt.Count != 0 {
- args = append(
- args,
- "LIMIT",
- strconv.FormatInt(opt.Offset, 10),
- strconv.FormatInt(opt.Count, 10),
- )
- }
- cmd := NewZSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRank(key, member string) *IntCmd {
- cmd := NewIntCmd("ZRANK", key, member)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRem(key string, members ...string) *IntCmd {
- args := append([]string{"ZREM", key}, members...)
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRemRangeByRank(key string, start, stop int64) *IntCmd {
- cmd := NewIntCmd(
- "ZREMRANGEBYRANK",
- key,
- strconv.FormatInt(start, 10),
- strconv.FormatInt(stop, 10),
- )
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRemRangeByScore(key, min, max string) *IntCmd {
- cmd := NewIntCmd("ZREMRANGEBYSCORE", key, min, max)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) zRevRange(key, start, stop string, withScores bool) *StringSliceCmd {
- args := []string{"ZREVRANGE", key, start, stop}
- if withScores {
- args = append(args, "WITHSCORES")
- }
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRevRange(key, start, stop string) *StringSliceCmd {
- return c.zRevRange(key, start, stop, false)
-}
-
-func (c *Client) ZRevRangeWithScores(key, start, stop string) *ZSliceCmd {
- args := []string{"ZREVRANGE", key, start, stop, "WITHSCORES"}
- cmd := NewZSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) zRevRangeByScore(key string, opt ZRangeByScore, withScores bool) *StringSliceCmd {
- args := []string{"ZREVRANGEBYSCORE", key, opt.Max, opt.Min}
- if withScores {
- args = append(args, "WITHSCORES")
- }
- if opt.Offset != 0 || opt.Count != 0 {
- args = append(
- args,
- "LIMIT",
- strconv.FormatInt(opt.Offset, 10),
- strconv.FormatInt(opt.Count, 10),
- )
- }
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRevRangeByScore(key string, opt ZRangeByScore) *StringSliceCmd {
- return c.zRevRangeByScore(key, opt, false)
-}
-
-func (c *Client) ZRevRangeByScoreWithScores(key string, opt ZRangeByScore) *ZSliceCmd {
- args := []string{"ZREVRANGEBYSCORE", key, opt.Max, opt.Min, "WITHSCORES"}
- if opt.Offset != 0 || opt.Count != 0 {
- args = append(
- args,
- "LIMIT",
- strconv.FormatInt(opt.Offset, 10),
- strconv.FormatInt(opt.Count, 10),
- )
- }
- cmd := NewZSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZRevRank(key, member string) *IntCmd {
- cmd := NewIntCmd("ZREVRANK", key, member)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZScore(key, member string) *FloatCmd {
- cmd := NewFloatCmd("ZSCORE", key, member)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ZUnionStore(
- destination string,
- store ZStore,
- keys ...string,
-) *IntCmd {
- args := []string{"ZUNIONSTORE", destination, strconv.FormatInt(int64(len(keys)), 10)}
- args = append(args, keys...)
- if len(store.Weights) > 0 {
- args = append(args, "WEIGHTS")
- for _, weight := range store.Weights {
- args = append(args, strconv.FormatInt(weight, 10))
- }
- }
- if store.Aggregate != "" {
- args = append(args, "AGGREGATE", store.Aggregate)
- }
- cmd := NewIntCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) BgRewriteAOF() *StatusCmd {
- cmd := NewStatusCmd("BGREWRITEAOF")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) BgSave() *StatusCmd {
- cmd := NewStatusCmd("BGSAVE")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ClientKill(ipPort string) *StatusCmd {
- cmd := NewStatusCmd("CLIENT", "KILL", ipPort)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ClientList() *StringCmd {
- cmd := NewStringCmd("CLIENT", "LIST")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ConfigGet(parameter string) *SliceCmd {
- cmd := NewSliceCmd("CONFIG", "GET", parameter)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ConfigResetStat() *StatusCmd {
- cmd := NewStatusCmd("CONFIG", "RESETSTAT")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ConfigSet(parameter, value string) *StatusCmd {
- cmd := NewStatusCmd("CONFIG", "SET", parameter, value)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) DbSize() *IntCmd {
- cmd := NewIntCmd("DBSIZE")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) FlushAll() *StatusCmd {
- cmd := NewStatusCmd("FLUSHALL")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) FlushDb() *StatusCmd {
- cmd := NewStatusCmd("FLUSHDB")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Info() *StringCmd {
- cmd := NewStringCmd("INFO")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) LastSave() *IntCmd {
- cmd := NewIntCmd("LASTSAVE")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) Save() *StatusCmd {
- cmd := NewStatusCmd("SAVE")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) shutdown(modifier string) *StatusCmd {
- var args []string
- if modifier == "" {
- args = []string{"SHUTDOWN"}
- } else {
- args = []string{"SHUTDOWN", modifier}
- }
- cmd := NewStatusCmd(args...)
- c.Process(cmd)
- if err := cmd.Err(); err != nil {
- if err == io.EOF {
- // Server quit as expected.
- cmd.err = nil
- }
- } else {
- // Server did not quit. String reply contains the reason.
- cmd.err = errorf(cmd.val)
- cmd.val = ""
- }
- return cmd
-}
-
-func (c *Client) Shutdown() *StatusCmd {
- return c.shutdown("")
-}
-
-func (c *Client) ShutdownSave() *StatusCmd {
- return c.shutdown("SAVE")
-}
-
-func (c *Client) ShutdownNoSave() *StatusCmd {
- return c.shutdown("NOSAVE")
-}
-
-func (c *Client) SlaveOf(host, port string) *StatusCmd {
- cmd := NewStatusCmd("SLAVEOF", host, port)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) SlowLog() {
- panic("not implemented")
-}
-
-func (c *Client) Sync() {
- panic("not implemented")
-}
-
-func (c *Client) Time() *StringSliceCmd {
- cmd := NewStringSliceCmd("TIME")
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) Eval(script string, keys []string, args []string) *Cmd {
- cmdArgs := []string{"EVAL", script, strconv.FormatInt(int64(len(keys)), 10)}
- cmdArgs = append(cmdArgs, keys...)
- cmdArgs = append(cmdArgs, args...)
- cmd := NewCmd(cmdArgs...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) EvalSha(sha1 string, keys []string, args []string) *Cmd {
- cmdArgs := []string{"EVALSHA", sha1, strconv.FormatInt(int64(len(keys)), 10)}
- cmdArgs = append(cmdArgs, keys...)
- cmdArgs = append(cmdArgs, args...)
- cmd := NewCmd(cmdArgs...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ScriptExists(scripts ...string) *BoolSliceCmd {
- args := append([]string{"SCRIPT", "EXISTS"}, scripts...)
- cmd := NewBoolSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ScriptFlush() *StatusCmd {
- cmd := NewStatusCmd("SCRIPT", "FLUSH")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ScriptKill() *StatusCmd {
- cmd := NewStatusCmd("SCRIPT", "KILL")
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) ScriptLoad(script string) *StringCmd {
- cmd := NewStringCmd("SCRIPT", "LOAD", script)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) DebugObject(key string) *StringCmd {
- cmd := NewStringCmd("DEBUG", "OBJECT", key)
- c.Process(cmd)
- return cmd
-}
-
-//------------------------------------------------------------------------------
-
-func (c *Client) PubSubChannels(pattern string) *StringSliceCmd {
- args := []string{"PUBSUB", "CHANNELS"}
- if pattern != "*" {
- args = append(args, pattern)
- }
- cmd := NewStringSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) PubSubNumSub(channels ...string) *SliceCmd {
- args := []string{"PUBSUB", "NUMSUB"}
- args = append(args, channels...)
- cmd := NewSliceCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Client) PubSubNumPat() *IntCmd {
- cmd := NewIntCmd("PUBSUB", "NUMPAT")
- c.Process(cmd)
- return cmd
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/doc.go b/Godeps/_workspace/src/gopkg.in/redis.v2/doc.go
deleted file mode 100644
index 55262533a..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
-Package redis implements a Redis client.
-*/
-package redis
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/error.go b/Godeps/_workspace/src/gopkg.in/redis.v2/error.go
deleted file mode 100644
index 667fffdc6..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/error.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package redis
-
-import (
- "fmt"
-)
-
-// Redis nil reply.
-var Nil = errorf("redis: nil")
-
-// Redis transaction failed.
-var TxFailedErr = errorf("redis: transaction failed")
-
-type redisError struct {
- s string
-}
-
-func errorf(s string, args ...interface{}) redisError {
- return redisError{s: fmt.Sprintf(s, args...)}
-}
-
-func (err redisError) Error() string {
- return err.s
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/example_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/example_test.go
deleted file mode 100644
index dbc951310..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/example_test.go
+++ /dev/null
@@ -1,180 +0,0 @@
-package redis_test
-
-import (
- "fmt"
- "strconv"
-
- "gopkg.in/redis.v2"
-)
-
-var client *redis.Client
-
-func init() {
- client = redis.NewTCPClient(&redis.Options{
- Addr: ":6379",
- })
- client.FlushDb()
-}
-
-func ExampleNewTCPClient() {
- client := redis.NewTCPClient(&redis.Options{
- Addr: "localhost:6379",
- Password: "", // no password set
- DB: 0, // use default DB
- })
-
- pong, err := client.Ping().Result()
- fmt.Println(pong, err)
- // Output: PONG <nil>
-}
-
-func ExampleNewFailoverClient() {
- client := redis.NewFailoverClient(&redis.FailoverOptions{
- MasterName: "master",
- SentinelAddrs: []string{":26379"},
- })
-
- pong, err := client.Ping().Result()
- fmt.Println(pong, err)
- // Output: PONG <nil>
-}
-
-func ExampleClient() {
- if err := client.Set("foo", "bar").Err(); err != nil {
- panic(err)
- }
-
- v, err := client.Get("hello").Result()
- fmt.Printf("%q %q %v", v, err, err == redis.Nil)
- // Output: "" "redis: nil" true
-}
-
-func ExampleClient_Incr() {
- if err := client.Incr("counter").Err(); err != nil {
- panic(err)
- }
-
- n, err := client.Get("counter").Int64()
- fmt.Println(n, err)
- // Output: 1 <nil>
-}
-
-func ExampleClient_Pipelined() {
- cmds, err := client.Pipelined(func(c *redis.Pipeline) error {
- c.Set("key1", "hello1")
- c.Get("key1")
- return nil
- })
- fmt.Println(err)
- set := cmds[0].(*redis.StatusCmd)
- fmt.Println(set)
- get := cmds[1].(*redis.StringCmd)
- fmt.Println(get)
- // Output: <nil>
- // SET key1 hello1: OK
- // GET key1: hello1
-}
-
-func ExamplePipeline() {
- pipeline := client.Pipeline()
- set := pipeline.Set("key1", "hello1")
- get := pipeline.Get("key1")
- cmds, err := pipeline.Exec()
- fmt.Println(cmds, err)
- fmt.Println(set)
- fmt.Println(get)
- // Output: [SET key1 hello1: OK GET key1: hello1] <nil>
- // SET key1 hello1: OK
- // GET key1: hello1
-}
-
-func ExampleMulti() {
- incr := func(tx *redis.Multi) ([]redis.Cmder, error) {
- s, err := tx.Get("key").Result()
- if err != nil && err != redis.Nil {
- return nil, err
- }
- n, _ := strconv.ParseInt(s, 10, 64)
-
- return tx.Exec(func() error {
- tx.Set("key", strconv.FormatInt(n+1, 10))
- return nil
- })
- }
-
- client.Del("key")
-
- tx := client.Multi()
- defer tx.Close()
-
- watch := tx.Watch("key")
- _ = watch.Err()
-
- for {
- cmds, err := incr(tx)
- if err == redis.TxFailedErr {
- continue
- } else if err != nil {
- panic(err)
- }
- fmt.Println(cmds, err)
- break
- }
-
- // Output: [SET key 1: OK] <nil>
-}
-
-func ExamplePubSub() {
- pubsub := client.PubSub()
- defer pubsub.Close()
-
- err := pubsub.Subscribe("mychannel")
- _ = err
-
- msg, err := pubsub.Receive()
- fmt.Println(msg, err)
-
- pub := client.Publish("mychannel", "hello")
- _ = pub.Err()
-
- msg, err = pubsub.Receive()
- fmt.Println(msg, err)
-
- // Output: subscribe: mychannel <nil>
- // Message<mychannel: hello> <nil>
-}
-
-func ExampleScript() {
- setnx := redis.NewScript(`
- if redis.call("get", KEYS[1]) == false then
- redis.call("set", KEYS[1], ARGV[1])
- return 1
- end
- return 0
- `)
-
- v1, err := setnx.Run(client, []string{"keynx"}, []string{"foo"}).Result()
- fmt.Println(v1.(int64), err)
-
- v2, err := setnx.Run(client, []string{"keynx"}, []string{"bar"}).Result()
- fmt.Println(v2.(int64), err)
-
- get := client.Get("keynx")
- fmt.Println(get)
-
- // Output: 1 <nil>
- // 0 <nil>
- // GET keynx: foo
-}
-
-func Example_customCommand() {
- Get := func(client *redis.Client, key string) *redis.StringCmd {
- cmd := redis.NewStringCmd("GET", key)
- client.Process(cmd)
- return cmd
- }
-
- v, err := Get(client, "key_does_not_exist").Result()
- fmt.Printf("%q %s", v, err)
- // Output: "" redis: nil
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/export_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/export_test.go
deleted file mode 100644
index 7f7fa6797..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/export_test.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package redis
-
-func (c *baseClient) Pool() pool {
- return c.connPool
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/multi.go b/Godeps/_workspace/src/gopkg.in/redis.v2/multi.go
deleted file mode 100644
index bff38dfaa..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/multi.go
+++ /dev/null
@@ -1,138 +0,0 @@
-package redis
-
-import (
- "errors"
- "fmt"
-)
-
-var errDiscard = errors.New("redis: Discard can be used only inside Exec")
-
-// Not thread-safe.
-type Multi struct {
- *Client
-}
-
-func (c *Client) Multi() *Multi {
- return &Multi{
- Client: &Client{
- baseClient: &baseClient{
- opt: c.opt,
- connPool: newSingleConnPool(c.connPool, true),
- },
- },
- }
-}
-
-func (c *Multi) Close() error {
- if err := c.Unwatch().Err(); err != nil {
- return err
- }
- return c.Client.Close()
-}
-
-func (c *Multi) Watch(keys ...string) *StatusCmd {
- args := append([]string{"WATCH"}, keys...)
- cmd := NewStatusCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Multi) Unwatch(keys ...string) *StatusCmd {
- args := append([]string{"UNWATCH"}, keys...)
- cmd := NewStatusCmd(args...)
- c.Process(cmd)
- return cmd
-}
-
-func (c *Multi) Discard() error {
- if c.cmds == nil {
- return errDiscard
- }
- c.cmds = c.cmds[:1]
- return nil
-}
-
-// Exec always returns list of commands. If transaction fails
-// TxFailedErr is returned. Otherwise Exec returns error of the first
-// failed command or nil.
-func (c *Multi) Exec(f func() error) ([]Cmder, error) {
- c.cmds = []Cmder{NewStatusCmd("MULTI")}
- if err := f(); err != nil {
- return nil, err
- }
- c.cmds = append(c.cmds, NewSliceCmd("EXEC"))
-
- cmds := c.cmds
- c.cmds = nil
-
- if len(cmds) == 2 {
- return []Cmder{}, nil
- }
-
- cn, err := c.conn()
- if err != nil {
- setCmdsErr(cmds[1:len(cmds)-1], err)
- return cmds[1 : len(cmds)-1], err
- }
-
- err = c.execCmds(cn, cmds)
- if err != nil {
- c.freeConn(cn, err)
- return cmds[1 : len(cmds)-1], err
- }
-
- c.putConn(cn)
- return cmds[1 : len(cmds)-1], nil
-}
-
-func (c *Multi) execCmds(cn *conn, cmds []Cmder) error {
- err := c.writeCmd(cn, cmds...)
- if err != nil {
- setCmdsErr(cmds[1:len(cmds)-1], err)
- return err
- }
-
- statusCmd := NewStatusCmd()
-
- // Omit last command (EXEC).
- cmdsLen := len(cmds) - 1
-
- // Parse queued replies.
- for i := 0; i < cmdsLen; i++ {
- if err := statusCmd.parseReply(cn.rd); err != nil {
- setCmdsErr(cmds[1:len(cmds)-1], err)
- return err
- }
- }
-
- // Parse number of replies.
- line, err := readLine(cn.rd)
- if err != nil {
- setCmdsErr(cmds[1:len(cmds)-1], err)
- return err
- }
- if line[0] != '*' {
- err := fmt.Errorf("redis: expected '*', but got line %q", line)
- setCmdsErr(cmds[1:len(cmds)-1], err)
- return err
- }
- if len(line) == 3 && line[1] == '-' && line[2] == '1' {
- setCmdsErr(cmds[1:len(cmds)-1], TxFailedErr)
- return TxFailedErr
- }
-
- var firstCmdErr error
-
- // Parse replies.
- // Loop starts from 1 to omit MULTI cmd.
- for i := 1; i < cmdsLen; i++ {
- cmd := cmds[i]
- if err := cmd.parseReply(cn.rd); err != nil {
- if firstCmdErr == nil {
- firstCmdErr = err
- }
- }
- }
-
- return firstCmdErr
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/parser.go b/Godeps/_workspace/src/gopkg.in/redis.v2/parser.go
deleted file mode 100644
index b4c380c76..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/parser.go
+++ /dev/null
@@ -1,262 +0,0 @@
-package redis
-
-import (
- "errors"
- "fmt"
- "strconv"
-
- "gopkg.in/bufio.v1"
-)
-
-type multiBulkParser func(rd *bufio.Reader, n int64) (interface{}, error)
-
-var (
- errReaderTooSmall = errors.New("redis: reader is too small")
-)
-
-//------------------------------------------------------------------------------
-
-func appendArgs(buf []byte, args []string) []byte {
- buf = append(buf, '*')
- buf = strconv.AppendUint(buf, uint64(len(args)), 10)
- buf = append(buf, '\r', '\n')
- for _, arg := range args {
- buf = append(buf, '$')
- buf = strconv.AppendUint(buf, uint64(len(arg)), 10)
- buf = append(buf, '\r', '\n')
- buf = append(buf, arg...)
- buf = append(buf, '\r', '\n')
- }
- return buf
-}
-
-//------------------------------------------------------------------------------
-
-func readLine(rd *bufio.Reader) ([]byte, error) {
- line, isPrefix, err := rd.ReadLine()
- if err != nil {
- return line, err
- }
- if isPrefix {
- return line, errReaderTooSmall
- }
- return line, nil
-}
-
-func readN(rd *bufio.Reader, n int) ([]byte, error) {
- b, err := rd.ReadN(n)
- if err == bufio.ErrBufferFull {
- tmp := make([]byte, n)
- r := copy(tmp, b)
- b = tmp
-
- for {
- nn, err := rd.Read(b[r:])
- r += nn
- if r >= n {
- // Ignore error if we read enough.
- break
- }
- if err != nil {
- return nil, err
- }
- }
- } else if err != nil {
- return nil, err
- }
- return b, nil
-}
-
-//------------------------------------------------------------------------------
-
-func parseReq(rd *bufio.Reader) ([]string, error) {
- line, err := readLine(rd)
- if err != nil {
- return nil, err
- }
-
- if line[0] != '*' {
- return []string{string(line)}, nil
- }
- numReplies, err := strconv.ParseInt(string(line[1:]), 10, 64)
- if err != nil {
- return nil, err
- }
-
- args := make([]string, 0, numReplies)
- for i := int64(0); i < numReplies; i++ {
- line, err = readLine(rd)
- if err != nil {
- return nil, err
- }
- if line[0] != '$' {
- return nil, fmt.Errorf("redis: expected '$', but got %q", line)
- }
-
- argLen, err := strconv.ParseInt(string(line[1:]), 10, 32)
- if err != nil {
- return nil, err
- }
-
- arg, err := readN(rd, int(argLen)+2)
- if err != nil {
- return nil, err
- }
- args = append(args, string(arg[:argLen]))
- }
- return args, nil
-}
-
-//------------------------------------------------------------------------------
-
-func parseReply(rd *bufio.Reader, p multiBulkParser) (interface{}, error) {
- line, err := readLine(rd)
- if err != nil {
- return nil, err
- }
-
- switch line[0] {
- case '-':
- return nil, errorf(string(line[1:]))
- case '+':
- return string(line[1:]), nil
- case ':':
- v, err := strconv.ParseInt(string(line[1:]), 10, 64)
- if err != nil {
- return nil, err
- }
- return v, nil
- case '$':
- if len(line) == 3 && line[1] == '-' && line[2] == '1' {
- return nil, Nil
- }
-
- replyLen, err := strconv.Atoi(string(line[1:]))
- if err != nil {
- return nil, err
- }
-
- b, err := readN(rd, replyLen+2)
- if err != nil {
- return nil, err
- }
- return string(b[:replyLen]), nil
- case '*':
- if len(line) == 3 && line[1] == '-' && line[2] == '1' {
- return nil, Nil
- }
-
- repliesNum, err := strconv.ParseInt(string(line[1:]), 10, 64)
- if err != nil {
- return nil, err
- }
-
- return p(rd, repliesNum)
- }
- return nil, fmt.Errorf("redis: can't parse %q", line)
-}
-
-func parseSlice(rd *bufio.Reader, n int64) (interface{}, error) {
- vals := make([]interface{}, 0, n)
- for i := int64(0); i < n; i++ {
- v, err := parseReply(rd, parseSlice)
- if err == Nil {
- vals = append(vals, nil)
- } else if err != nil {
- return nil, err
- } else {
- vals = append(vals, v)
- }
- }
- return vals, nil
-}
-
-func parseStringSlice(rd *bufio.Reader, n int64) (interface{}, error) {
- vals := make([]string, 0, n)
- for i := int64(0); i < n; i++ {
- viface, err := parseReply(rd, nil)
- if err != nil {
- return nil, err
- }
- v, ok := viface.(string)
- if !ok {
- return nil, fmt.Errorf("got %T, expected string", viface)
- }
- vals = append(vals, v)
- }
- return vals, nil
-}
-
-func parseBoolSlice(rd *bufio.Reader, n int64) (interface{}, error) {
- vals := make([]bool, 0, n)
- for i := int64(0); i < n; i++ {
- viface, err := parseReply(rd, nil)
- if err != nil {
- return nil, err
- }
- v, ok := viface.(int64)
- if !ok {
- return nil, fmt.Errorf("got %T, expected int64", viface)
- }
- vals = append(vals, v == 1)
- }
- return vals, nil
-}
-
-func parseStringStringMap(rd *bufio.Reader, n int64) (interface{}, error) {
- m := make(map[string]string, n/2)
- for i := int64(0); i < n; i += 2 {
- keyiface, err := parseReply(rd, nil)
- if err != nil {
- return nil, err
- }
- key, ok := keyiface.(string)
- if !ok {
- return nil, fmt.Errorf("got %T, expected string", keyiface)
- }
-
- valueiface, err := parseReply(rd, nil)
- if err != nil {
- return nil, err
- }
- value, ok := valueiface.(string)
- if !ok {
- return nil, fmt.Errorf("got %T, expected string", valueiface)
- }
-
- m[key] = value
- }
- return m, nil
-}
-
-func parseZSlice(rd *bufio.Reader, n int64) (interface{}, error) {
- zz := make([]Z, n/2)
- for i := int64(0); i < n; i += 2 {
- z := &zz[i/2]
-
- memberiface, err := parseReply(rd, nil)
- if err != nil {
- return nil, err
- }
- member, ok := memberiface.(string)
- if !ok {
- return nil, fmt.Errorf("got %T, expected string", memberiface)
- }
- z.Member = member
-
- scoreiface, err := parseReply(rd, nil)
- if err != nil {
- return nil, err
- }
- scorestr, ok := scoreiface.(string)
- if !ok {
- return nil, fmt.Errorf("got %T, expected string", scoreiface)
- }
- score, err := strconv.ParseFloat(scorestr, 64)
- if err != nil {
- return nil, err
- }
- z.Score = score
- }
- return zz, nil
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/parser_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/parser_test.go
deleted file mode 100644
index 1b9e15810..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/parser_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package redis
-
-import (
- "testing"
-
- "gopkg.in/bufio.v1"
-)
-
-func BenchmarkParseReplyStatus(b *testing.B) {
- benchmarkParseReply(b, "+OK\r\n", nil, false)
-}
-
-func BenchmarkParseReplyInt(b *testing.B) {
- benchmarkParseReply(b, ":1\r\n", nil, false)
-}
-
-func BenchmarkParseReplyError(b *testing.B) {
- benchmarkParseReply(b, "-Error message\r\n", nil, true)
-}
-
-func BenchmarkParseReplyString(b *testing.B) {
- benchmarkParseReply(b, "$5\r\nhello\r\n", nil, false)
-}
-
-func BenchmarkParseReplySlice(b *testing.B) {
- benchmarkParseReply(b, "*2\r\n$5\r\nhello\r\n$5\r\nworld\r\n", parseSlice, false)
-}
-
-func benchmarkParseReply(b *testing.B, reply string, p multiBulkParser, wanterr bool) {
- b.StopTimer()
-
- buf := &bufio.Buffer{}
- rd := bufio.NewReader(buf)
- for i := 0; i < b.N; i++ {
- buf.WriteString(reply)
- }
-
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- _, err := parseReply(rd, p)
- if !wanterr && err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkAppendArgs(b *testing.B) {
- buf := make([]byte, 0, 64)
- args := []string{"hello", "world", "foo", "bar"}
- for i := 0; i < b.N; i++ {
- appendArgs(buf, args)
- }
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/pipeline.go b/Godeps/_workspace/src/gopkg.in/redis.v2/pipeline.go
deleted file mode 100644
index 540d6c51d..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/pipeline.go
+++ /dev/null
@@ -1,91 +0,0 @@
-package redis
-
-// Not thread-safe.
-type Pipeline struct {
- *Client
-
- closed bool
-}
-
-func (c *Client) Pipeline() *Pipeline {
- return &Pipeline{
- Client: &Client{
- baseClient: &baseClient{
- opt: c.opt,
- connPool: c.connPool,
-
- cmds: make([]Cmder, 0),
- },
- },
- }
-}
-
-func (c *Client) Pipelined(f func(*Pipeline) error) ([]Cmder, error) {
- pc := c.Pipeline()
- if err := f(pc); err != nil {
- return nil, err
- }
- cmds, err := pc.Exec()
- pc.Close()
- return cmds, err
-}
-
-func (c *Pipeline) Close() error {
- c.closed = true
- return nil
-}
-
-func (c *Pipeline) Discard() error {
- if c.closed {
- return errClosed
- }
- c.cmds = c.cmds[:0]
- return nil
-}
-
-// Exec always returns list of commands and error of the first failed
-// command if any.
-func (c *Pipeline) Exec() ([]Cmder, error) {
- if c.closed {
- return nil, errClosed
- }
-
- cmds := c.cmds
- c.cmds = make([]Cmder, 0)
-
- if len(cmds) == 0 {
- return []Cmder{}, nil
- }
-
- cn, err := c.conn()
- if err != nil {
- setCmdsErr(cmds, err)
- return cmds, err
- }
-
- if err := c.execCmds(cn, cmds); err != nil {
- c.freeConn(cn, err)
- return cmds, err
- }
-
- c.putConn(cn)
- return cmds, nil
-}
-
-func (c *Pipeline) execCmds(cn *conn, cmds []Cmder) error {
- if err := c.writeCmd(cn, cmds...); err != nil {
- setCmdsErr(cmds, err)
- return err
- }
-
- var firstCmdErr error
- for _, cmd := range cmds {
- if err := cmd.parseReply(cn.rd); err != nil {
- if firstCmdErr == nil {
- firstCmdErr = err
- }
- }
- }
-
- return firstCmdErr
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/pool.go b/Godeps/_workspace/src/gopkg.in/redis.v2/pool.go
deleted file mode 100644
index bca4d1963..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/pool.go
+++ /dev/null
@@ -1,405 +0,0 @@
-package redis
-
-import (
- "container/list"
- "errors"
- "log"
- "net"
- "sync"
- "time"
-
- "gopkg.in/bufio.v1"
-)
-
-var (
- errClosed = errors.New("redis: client is closed")
- errRateLimited = errors.New("redis: you open connections too fast")
-)
-
-var (
- zeroTime = time.Time{}
-)
-
-type pool interface {
- Get() (*conn, bool, error)
- Put(*conn) error
- Remove(*conn) error
- Len() int
- Size() int
- Close() error
- Filter(func(*conn) bool)
-}
-
-//------------------------------------------------------------------------------
-
-type conn struct {
- netcn net.Conn
- rd *bufio.Reader
- buf []byte
-
- inUse bool
- usedAt time.Time
-
- readTimeout time.Duration
- writeTimeout time.Duration
-
- elem *list.Element
-}
-
-func newConnFunc(dial func() (net.Conn, error)) func() (*conn, error) {
- return func() (*conn, error) {
- netcn, err := dial()
- if err != nil {
- return nil, err
- }
- cn := &conn{
- netcn: netcn,
- buf: make([]byte, 0, 64),
- }
- cn.rd = bufio.NewReader(cn)
- return cn, nil
- }
-}
-
-func (cn *conn) Read(b []byte) (int, error) {
- if cn.readTimeout != 0 {
- cn.netcn.SetReadDeadline(time.Now().Add(cn.readTimeout))
- } else {
- cn.netcn.SetReadDeadline(zeroTime)
- }
- return cn.netcn.Read(b)
-}
-
-func (cn *conn) Write(b []byte) (int, error) {
- if cn.writeTimeout != 0 {
- cn.netcn.SetWriteDeadline(time.Now().Add(cn.writeTimeout))
- } else {
- cn.netcn.SetWriteDeadline(zeroTime)
- }
- return cn.netcn.Write(b)
-}
-
-func (cn *conn) RemoteAddr() net.Addr {
- return cn.netcn.RemoteAddr()
-}
-
-func (cn *conn) Close() error {
- return cn.netcn.Close()
-}
-
-//------------------------------------------------------------------------------
-
-type connPool struct {
- dial func() (*conn, error)
- rl *rateLimiter
-
- opt *options
-
- cond *sync.Cond
- conns *list.List
-
- idleNum int
- closed bool
-}
-
-func newConnPool(dial func() (*conn, error), opt *options) *connPool {
- return &connPool{
- dial: dial,
- rl: newRateLimiter(time.Second, 2*opt.PoolSize),
-
- opt: opt,
-
- cond: sync.NewCond(&sync.Mutex{}),
- conns: list.New(),
- }
-}
-
-func (p *connPool) new() (*conn, error) {
- if !p.rl.Check() {
- return nil, errRateLimited
- }
- return p.dial()
-}
-
-func (p *connPool) Get() (*conn, bool, error) {
- p.cond.L.Lock()
-
- if p.closed {
- p.cond.L.Unlock()
- return nil, false, errClosed
- }
-
- if p.opt.IdleTimeout > 0 {
- for el := p.conns.Front(); el != nil; el = el.Next() {
- cn := el.Value.(*conn)
- if cn.inUse {
- break
- }
- if time.Since(cn.usedAt) > p.opt.IdleTimeout {
- if err := p.remove(cn); err != nil {
- log.Printf("remove failed: %s", err)
- }
- }
- }
- }
-
- for p.conns.Len() >= p.opt.PoolSize && p.idleNum == 0 {
- p.cond.Wait()
- }
-
- if p.idleNum > 0 {
- elem := p.conns.Front()
- cn := elem.Value.(*conn)
- if cn.inUse {
- panic("pool: precondition failed")
- }
- cn.inUse = true
- p.conns.MoveToBack(elem)
- p.idleNum--
-
- p.cond.L.Unlock()
- return cn, false, nil
- }
-
- if p.conns.Len() < p.opt.PoolSize {
- cn, err := p.new()
- if err != nil {
- p.cond.L.Unlock()
- return nil, false, err
- }
-
- cn.inUse = true
- cn.elem = p.conns.PushBack(cn)
-
- p.cond.L.Unlock()
- return cn, true, nil
- }
-
- panic("not reached")
-}
-
-func (p *connPool) Put(cn *conn) error {
- if cn.rd.Buffered() != 0 {
- b, _ := cn.rd.ReadN(cn.rd.Buffered())
- log.Printf("redis: connection has unread data: %q", b)
- return p.Remove(cn)
- }
-
- if p.opt.IdleTimeout > 0 {
- cn.usedAt = time.Now()
- }
-
- p.cond.L.Lock()
- if p.closed {
- p.cond.L.Unlock()
- return errClosed
- }
- cn.inUse = false
- p.conns.MoveToFront(cn.elem)
- p.idleNum++
- p.cond.Signal()
- p.cond.L.Unlock()
-
- return nil
-}
-
-func (p *connPool) Remove(cn *conn) error {
- p.cond.L.Lock()
- if p.closed {
- // Noop, connection is already closed.
- p.cond.L.Unlock()
- return nil
- }
- err := p.remove(cn)
- p.cond.Signal()
- p.cond.L.Unlock()
- return err
-}
-
-func (p *connPool) remove(cn *conn) error {
- p.conns.Remove(cn.elem)
- cn.elem = nil
- if !cn.inUse {
- p.idleNum--
- }
- return cn.Close()
-}
-
-// Len returns number of idle connections.
-func (p *connPool) Len() int {
- defer p.cond.L.Unlock()
- p.cond.L.Lock()
- return p.idleNum
-}
-
-// Size returns number of connections in the pool.
-func (p *connPool) Size() int {
- defer p.cond.L.Unlock()
- p.cond.L.Lock()
- return p.conns.Len()
-}
-
-func (p *connPool) Filter(f func(*conn) bool) {
- p.cond.L.Lock()
- for el, next := p.conns.Front(), p.conns.Front(); el != nil; el = next {
- next = el.Next()
- cn := el.Value.(*conn)
- if !f(cn) {
- p.remove(cn)
- }
- }
- p.cond.L.Unlock()
-}
-
-func (p *connPool) Close() error {
- defer p.cond.L.Unlock()
- p.cond.L.Lock()
- if p.closed {
- return nil
- }
- p.closed = true
- p.rl.Close()
- var retErr error
- for {
- e := p.conns.Front()
- if e == nil {
- break
- }
- if err := p.remove(e.Value.(*conn)); err != nil {
- log.Printf("cn.Close failed: %s", err)
- retErr = err
- }
- }
- return retErr
-}
-
-//------------------------------------------------------------------------------
-
-type singleConnPool struct {
- pool pool
-
- cnMtx sync.Mutex
- cn *conn
-
- reusable bool
-
- closed bool
-}
-
-func newSingleConnPool(pool pool, reusable bool) *singleConnPool {
- return &singleConnPool{
- pool: pool,
- reusable: reusable,
- }
-}
-
-func (p *singleConnPool) SetConn(cn *conn) {
- p.cnMtx.Lock()
- p.cn = cn
- p.cnMtx.Unlock()
-}
-
-func (p *singleConnPool) Get() (*conn, bool, error) {
- defer p.cnMtx.Unlock()
- p.cnMtx.Lock()
-
- if p.closed {
- return nil, false, errClosed
- }
- if p.cn != nil {
- return p.cn, false, nil
- }
-
- cn, isNew, err := p.pool.Get()
- if err != nil {
- return nil, false, err
- }
- p.cn = cn
-
- return p.cn, isNew, nil
-}
-
-func (p *singleConnPool) Put(cn *conn) error {
- defer p.cnMtx.Unlock()
- p.cnMtx.Lock()
- if p.cn != cn {
- panic("p.cn != cn")
- }
- if p.closed {
- return errClosed
- }
- return nil
-}
-
-func (p *singleConnPool) put() error {
- err := p.pool.Put(p.cn)
- p.cn = nil
- return err
-}
-
-func (p *singleConnPool) Remove(cn *conn) error {
- defer p.cnMtx.Unlock()
- p.cnMtx.Lock()
- if p.cn == nil {
- panic("p.cn == nil")
- }
- if p.cn != cn {
- panic("p.cn != cn")
- }
- if p.closed {
- return errClosed
- }
- return p.remove()
-}
-
-func (p *singleConnPool) remove() error {
- err := p.pool.Remove(p.cn)
- p.cn = nil
- return err
-}
-
-func (p *singleConnPool) Len() int {
- defer p.cnMtx.Unlock()
- p.cnMtx.Lock()
- if p.cn == nil {
- return 0
- }
- return 1
-}
-
-func (p *singleConnPool) Size() int {
- defer p.cnMtx.Unlock()
- p.cnMtx.Lock()
- if p.cn == nil {
- return 0
- }
- return 1
-}
-
-func (p *singleConnPool) Filter(f func(*conn) bool) {
- p.cnMtx.Lock()
- if p.cn != nil {
- if !f(p.cn) {
- p.remove()
- }
- }
- p.cnMtx.Unlock()
-}
-
-func (p *singleConnPool) Close() error {
- defer p.cnMtx.Unlock()
- p.cnMtx.Lock()
- if p.closed {
- return nil
- }
- p.closed = true
- var err error
- if p.cn != nil {
- if p.reusable {
- err = p.put()
- } else {
- err = p.remove()
- }
- }
- return err
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/pubsub.go b/Godeps/_workspace/src/gopkg.in/redis.v2/pubsub.go
deleted file mode 100644
index 6ac130bac..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/pubsub.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package redis
-
-import (
- "fmt"
- "time"
-)
-
-// Not thread-safe.
-type PubSub struct {
- *baseClient
-}
-
-func (c *Client) PubSub() *PubSub {
- return &PubSub{
- baseClient: &baseClient{
- opt: c.opt,
- connPool: newSingleConnPool(c.connPool, false),
- },
- }
-}
-
-func (c *Client) Publish(channel, message string) *IntCmd {
- req := NewIntCmd("PUBLISH", channel, message)
- c.Process(req)
- return req
-}
-
-type Message struct {
- Channel string
- Payload string
-}
-
-func (m *Message) String() string {
- return fmt.Sprintf("Message<%s: %s>", m.Channel, m.Payload)
-}
-
-type PMessage struct {
- Channel string
- Pattern string
- Payload string
-}
-
-func (m *PMessage) String() string {
- return fmt.Sprintf("PMessage<%s: %s>", m.Channel, m.Payload)
-}
-
-type Subscription struct {
- Kind string
- Channel string
- Count int
-}
-
-func (m *Subscription) String() string {
- return fmt.Sprintf("%s: %s", m.Kind, m.Channel)
-}
-
-func (c *PubSub) Receive() (interface{}, error) {
- return c.ReceiveTimeout(0)
-}
-
-func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error) {
- cn, err := c.conn()
- if err != nil {
- return nil, err
- }
- cn.readTimeout = timeout
-
- cmd := NewSliceCmd()
- if err := cmd.parseReply(cn.rd); err != nil {
- return nil, err
- }
-
- reply := cmd.Val()
-
- msgName := reply[0].(string)
- switch msgName {
- case "subscribe", "unsubscribe", "psubscribe", "punsubscribe":
- return &Subscription{
- Kind: msgName,
- Channel: reply[1].(string),
- Count: int(reply[2].(int64)),
- }, nil
- case "message":
- return &Message{
- Channel: reply[1].(string),
- Payload: reply[2].(string),
- }, nil
- case "pmessage":
- return &PMessage{
- Pattern: reply[1].(string),
- Channel: reply[2].(string),
- Payload: reply[3].(string),
- }, nil
- }
- return nil, fmt.Errorf("redis: unsupported message name: %q", msgName)
-}
-
-func (c *PubSub) subscribe(cmd string, channels ...string) error {
- cn, err := c.conn()
- if err != nil {
- return err
- }
-
- args := append([]string{cmd}, channels...)
- req := NewSliceCmd(args...)
- return c.writeCmd(cn, req)
-}
-
-func (c *PubSub) Subscribe(channels ...string) error {
- return c.subscribe("SUBSCRIBE", channels...)
-}
-
-func (c *PubSub) PSubscribe(patterns ...string) error {
- return c.subscribe("PSUBSCRIBE", patterns...)
-}
-
-func (c *PubSub) unsubscribe(cmd string, channels ...string) error {
- cn, err := c.conn()
- if err != nil {
- return err
- }
-
- args := append([]string{cmd}, channels...)
- req := NewSliceCmd(args...)
- return c.writeCmd(cn, req)
-}
-
-func (c *PubSub) Unsubscribe(channels ...string) error {
- return c.unsubscribe("UNSUBSCRIBE", channels...)
-}
-
-func (c *PubSub) PUnsubscribe(patterns ...string) error {
- return c.unsubscribe("PUNSUBSCRIBE", patterns...)
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit.go b/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit.go
deleted file mode 100644
index 20d851270..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package redis
-
-import (
- "sync/atomic"
- "time"
-)
-
-type rateLimiter struct {
- v int64
-
- _closed int64
-}
-
-func newRateLimiter(limit time.Duration, bucketSize int) *rateLimiter {
- rl := &rateLimiter{
- v: int64(bucketSize),
- }
- go rl.loop(limit, int64(bucketSize))
- return rl
-}
-
-func (rl *rateLimiter) loop(limit time.Duration, bucketSize int64) {
- for {
- if rl.closed() {
- break
- }
- if v := atomic.LoadInt64(&rl.v); v < bucketSize {
- atomic.AddInt64(&rl.v, 1)
- }
- time.Sleep(limit)
- }
-}
-
-func (rl *rateLimiter) Check() bool {
- for {
- if v := atomic.LoadInt64(&rl.v); v > 0 {
- if atomic.CompareAndSwapInt64(&rl.v, v, v-1) {
- return true
- }
- } else {
- return false
- }
- }
-}
-
-func (rl *rateLimiter) Close() error {
- atomic.StoreInt64(&rl._closed, 1)
- return nil
-}
-
-func (rl *rateLimiter) closed() bool {
- return atomic.LoadInt64(&rl._closed) == 1
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go
deleted file mode 100644
index 2f0d41a2e..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package redis
-
-import (
- "sync"
- "testing"
- "time"
-)
-
-func TestRateLimiter(t *testing.T) {
- var n = 100000
- if testing.Short() {
- n = 1000
- }
- rl := newRateLimiter(time.Minute, n)
-
- wg := &sync.WaitGroup{}
- for i := 0; i < n; i++ {
- wg.Add(1)
- go func() {
- if !rl.Check() {
- panic("check failed")
- }
- wg.Done()
- }()
- }
- wg.Wait()
-
- if rl.Check() && rl.Check() {
- t.Fatal("check passed")
- }
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/redis.go b/Godeps/_workspace/src/gopkg.in/redis.v2/redis.go
deleted file mode 100644
index 0d15dc8f8..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/redis.go
+++ /dev/null
@@ -1,231 +0,0 @@
-package redis
-
-import (
- "log"
- "net"
- "time"
-)
-
-type baseClient struct {
- connPool pool
- opt *options
- cmds []Cmder
-}
-
-func (c *baseClient) writeCmd(cn *conn, cmds ...Cmder) error {
- buf := cn.buf[:0]
- for _, cmd := range cmds {
- buf = appendArgs(buf, cmd.args())
- }
-
- _, err := cn.Write(buf)
- return err
-}
-
-func (c *baseClient) conn() (*conn, error) {
- cn, isNew, err := c.connPool.Get()
- if err != nil {
- return nil, err
- }
-
- if isNew {
- if err := c.initConn(cn); err != nil {
- c.removeConn(cn)
- return nil, err
- }
- }
-
- return cn, nil
-}
-
-func (c *baseClient) initConn(cn *conn) error {
- if c.opt.Password == "" && c.opt.DB == 0 {
- return nil
- }
-
- pool := newSingleConnPool(c.connPool, false)
- pool.SetConn(cn)
-
- // Client is not closed because we want to reuse underlying connection.
- client := &Client{
- baseClient: &baseClient{
- opt: c.opt,
- connPool: pool,
- },
- }
-
- if c.opt.Password != "" {
- if err := client.Auth(c.opt.Password).Err(); err != nil {
- return err
- }
- }
-
- if c.opt.DB > 0 {
- if err := client.Select(c.opt.DB).Err(); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (c *baseClient) freeConn(cn *conn, ei error) error {
- if cn.rd.Buffered() > 0 {
- return c.connPool.Remove(cn)
- }
- if _, ok := ei.(redisError); ok {
- return c.connPool.Put(cn)
- }
- return c.connPool.Remove(cn)
-}
-
-func (c *baseClient) removeConn(cn *conn) {
- if err := c.connPool.Remove(cn); err != nil {
- log.Printf("pool.Remove failed: %s", err)
- }
-}
-
-func (c *baseClient) putConn(cn *conn) {
- if err := c.connPool.Put(cn); err != nil {
- log.Printf("pool.Put failed: %s", err)
- }
-}
-
-func (c *baseClient) Process(cmd Cmder) {
- if c.cmds == nil {
- c.run(cmd)
- } else {
- c.cmds = append(c.cmds, cmd)
- }
-}
-
-func (c *baseClient) run(cmd Cmder) {
- cn, err := c.conn()
- if err != nil {
- cmd.setErr(err)
- return
- }
-
- if timeout := cmd.writeTimeout(); timeout != nil {
- cn.writeTimeout = *timeout
- } else {
- cn.writeTimeout = c.opt.WriteTimeout
- }
-
- if timeout := cmd.readTimeout(); timeout != nil {
- cn.readTimeout = *timeout
- } else {
- cn.readTimeout = c.opt.ReadTimeout
- }
-
- if err := c.writeCmd(cn, cmd); err != nil {
- c.freeConn(cn, err)
- cmd.setErr(err)
- return
- }
-
- if err := cmd.parseReply(cn.rd); err != nil {
- c.freeConn(cn, err)
- return
- }
-
- c.putConn(cn)
-}
-
-// Close closes the client, releasing any open resources.
-func (c *baseClient) Close() error {
- return c.connPool.Close()
-}
-
-//------------------------------------------------------------------------------
-
-type options struct {
- Password string
- DB int64
-
- DialTimeout time.Duration
- ReadTimeout time.Duration
- WriteTimeout time.Duration
-
- PoolSize int
- IdleTimeout time.Duration
-}
-
-type Options struct {
- Network string
- Addr string
-
- // Dialer creates new network connection and has priority over
- // Network and Addr options.
- Dialer func() (net.Conn, error)
-
- Password string
- DB int64
-
- DialTimeout time.Duration
- ReadTimeout time.Duration
- WriteTimeout time.Duration
-
- PoolSize int
- IdleTimeout time.Duration
-}
-
-func (opt *Options) getPoolSize() int {
- if opt.PoolSize == 0 {
- return 10
- }
- return opt.PoolSize
-}
-
-func (opt *Options) getDialTimeout() time.Duration {
- if opt.DialTimeout == 0 {
- return 5 * time.Second
- }
- return opt.DialTimeout
-}
-
-func (opt *Options) options() *options {
- return &options{
- DB: opt.DB,
- Password: opt.Password,
-
- DialTimeout: opt.getDialTimeout(),
- ReadTimeout: opt.ReadTimeout,
- WriteTimeout: opt.WriteTimeout,
-
- PoolSize: opt.getPoolSize(),
- IdleTimeout: opt.IdleTimeout,
- }
-}
-
-type Client struct {
- *baseClient
-}
-
-func NewClient(clOpt *Options) *Client {
- opt := clOpt.options()
- dialer := clOpt.Dialer
- if dialer == nil {
- dialer = func() (net.Conn, error) {
- return net.DialTimeout(clOpt.Network, clOpt.Addr, opt.DialTimeout)
- }
- }
- return &Client{
- baseClient: &baseClient{
- opt: opt,
- connPool: newConnPool(newConnFunc(dialer), opt),
- },
- }
-}
-
-// Deprecated. Use NewClient instead.
-func NewTCPClient(opt *Options) *Client {
- opt.Network = "tcp"
- return NewClient(opt)
-}
-
-// Deprecated. Use NewClient instead.
-func NewUnixClient(opt *Options) *Client {
- opt.Network = "unix"
- return NewClient(opt)
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/redis_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/redis_test.go
deleted file mode 100644
index 49f84d0e1..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/redis_test.go
+++ /dev/null
@@ -1,3333 +0,0 @@
-package redis_test
-
-import (
- "bytes"
- "fmt"
- "io"
- "net"
- "sort"
- "strconv"
- "sync"
- "testing"
- "time"
-
- "gopkg.in/redis.v2"
-
- . "gopkg.in/check.v1"
-)
-
-const redisAddr = ":6379"
-
-//------------------------------------------------------------------------------
-
-func sortStrings(slice []string) []string {
- sort.Strings(slice)
- return slice
-}
-
-//------------------------------------------------------------------------------
-
-type RedisConnectorTest struct{}
-
-var _ = Suite(&RedisConnectorTest{})
-
-func (t *RedisConnectorTest) TestShutdown(c *C) {
- c.Skip("shutdowns server")
-
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
-
- shutdown := client.Shutdown()
- c.Check(shutdown.Err(), Equals, io.EOF)
- c.Check(shutdown.Val(), Equals, "")
-
- ping := client.Ping()
- c.Check(ping.Err(), ErrorMatches, "dial tcp <nil>:[0-9]+: connection refused")
- c.Check(ping.Val(), Equals, "")
-}
-
-func (t *RedisConnectorTest) TestNewTCPClient(c *C) {
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- ping := client.Ping()
- c.Check(ping.Err(), IsNil)
- c.Check(ping.Val(), Equals, "PONG")
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestNewUnixClient(c *C) {
- c.Skip("not available on Travis CI")
-
- client := redis.NewUnixClient(&redis.Options{
- Addr: "/tmp/redis.sock",
- })
- ping := client.Ping()
- c.Check(ping.Err(), IsNil)
- c.Check(ping.Val(), Equals, "PONG")
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestDialer(c *C) {
- client := redis.NewClient(&redis.Options{
- Dialer: func() (net.Conn, error) {
- return net.Dial("tcp", redisAddr)
- },
- })
- ping := client.Ping()
- c.Check(ping.Err(), IsNil)
- c.Check(ping.Val(), Equals, "PONG")
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestClose(c *C) {
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- c.Assert(client.Close(), IsNil)
-
- ping := client.Ping()
- c.Assert(ping.Err(), Not(IsNil))
- c.Assert(ping.Err().Error(), Equals, "redis: client is closed")
-
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestPubSubClose(c *C) {
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
-
- pubsub := client.PubSub()
- c.Assert(pubsub.Close(), IsNil)
-
- _, err := pubsub.Receive()
- c.Assert(err, Not(IsNil))
- c.Assert(err.Error(), Equals, "redis: client is closed")
-
- ping := client.Ping()
- c.Assert(ping.Err(), IsNil)
-
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestMultiClose(c *C) {
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
-
- multi := client.Multi()
- c.Assert(multi.Close(), IsNil)
-
- _, err := multi.Exec(func() error {
- multi.Ping()
- return nil
- })
- c.Assert(err, Not(IsNil))
- c.Assert(err.Error(), Equals, "redis: client is closed")
-
- ping := client.Ping()
- c.Assert(ping.Err(), IsNil)
-
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestPipelineClose(c *C) {
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
-
- _, err := client.Pipelined(func(pipeline *redis.Pipeline) error {
- c.Assert(pipeline.Close(), IsNil)
- pipeline.Ping()
- return nil
- })
- c.Assert(err, Not(IsNil))
- c.Assert(err.Error(), Equals, "redis: client is closed")
-
- ping := client.Ping()
- c.Assert(ping.Err(), IsNil)
-
- c.Assert(client.Close(), IsNil)
-}
-
-func (t *RedisConnectorTest) TestIdleTimeout(c *C) {
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- IdleTimeout: time.Nanosecond,
- })
- for i := 0; i < 10; i++ {
- c.Assert(client.Ping().Err(), IsNil)
- }
-}
-
-func (t *RedisConnectorTest) TestSelectDb(c *C) {
- client1 := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- DB: 1,
- })
- c.Assert(client1.Set("key", "db1").Err(), IsNil)
-
- client2 := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- DB: 2,
- })
- c.Assert(client2.Get("key").Err(), Equals, redis.Nil)
-}
-
-//------------------------------------------------------------------------------
-
-type RedisConnPoolTest struct {
- client *redis.Client
-}
-
-var _ = Suite(&RedisConnPoolTest{})
-
-func (t *RedisConnPoolTest) SetUpTest(c *C) {
- t.client = redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
-}
-
-func (t *RedisConnPoolTest) TearDownTest(c *C) {
- c.Assert(t.client.FlushDb().Err(), IsNil)
- c.Assert(t.client.Close(), IsNil)
-}
-
-func (t *RedisConnPoolTest) TestConnPoolMaxSize(c *C) {
- wg := &sync.WaitGroup{}
- for i := 0; i < 1000; i++ {
- wg.Add(1)
- go func() {
- ping := t.client.Ping()
- c.Assert(ping.Err(), IsNil)
- c.Assert(ping.Val(), Equals, "PONG")
- wg.Done()
- }()
- }
- wg.Wait()
-
- c.Assert(t.client.Pool().Size(), Equals, 10)
- c.Assert(t.client.Pool().Len(), Equals, 10)
-}
-
-func (t *RedisConnPoolTest) TestConnPoolMaxSizeOnPipelineClient(c *C) {
- const N = 1000
-
- wg := &sync.WaitGroup{}
- wg.Add(N)
- for i := 0; i < N; i++ {
- go func() {
- pipeline := t.client.Pipeline()
- ping := pipeline.Ping()
- cmds, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 1)
- c.Assert(ping.Err(), IsNil)
- c.Assert(ping.Val(), Equals, "PONG")
-
- c.Assert(pipeline.Close(), IsNil)
-
- wg.Done()
- }()
- }
- wg.Wait()
-
- c.Assert(t.client.Pool().Size(), Equals, 10)
- c.Assert(t.client.Pool().Len(), Equals, 10)
-}
-
-func (t *RedisConnPoolTest) TestConnPoolMaxSizeOnMultiClient(c *C) {
- const N = 1000
-
- wg := &sync.WaitGroup{}
- wg.Add(N)
- for i := 0; i < N; i++ {
- go func() {
- multi := t.client.Multi()
- var ping *redis.StatusCmd
- cmds, err := multi.Exec(func() error {
- ping = multi.Ping()
- return nil
- })
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 1)
- c.Assert(ping.Err(), IsNil)
- c.Assert(ping.Val(), Equals, "PONG")
-
- c.Assert(multi.Close(), IsNil)
-
- wg.Done()
- }()
- }
- wg.Wait()
-
- c.Assert(t.client.Pool().Size(), Equals, 10)
- c.Assert(t.client.Pool().Len(), Equals, 10)
-}
-
-func (t *RedisConnPoolTest) TestConnPoolMaxSizeOnPubSub(c *C) {
- const N = 10
-
- wg := &sync.WaitGroup{}
- wg.Add(N)
- for i := 0; i < N; i++ {
- go func() {
- defer wg.Done()
- pubsub := t.client.PubSub()
- c.Assert(pubsub.Subscribe(), IsNil)
- c.Assert(pubsub.Close(), IsNil)
- }()
- }
- wg.Wait()
-
- c.Assert(t.client.Pool().Size(), Equals, 0)
- c.Assert(t.client.Pool().Len(), Equals, 0)
-}
-
-func (t *RedisConnPoolTest) TestConnPoolRemovesBrokenConn(c *C) {
- cn, _, err := t.client.Pool().Get()
- c.Assert(err, IsNil)
- c.Assert(cn.Close(), IsNil)
- c.Assert(t.client.Pool().Put(cn), IsNil)
-
- ping := t.client.Ping()
- c.Assert(ping.Err().Error(), Equals, "use of closed network connection")
- c.Assert(ping.Val(), Equals, "")
-
- ping = t.client.Ping()
- c.Assert(ping.Err(), IsNil)
- c.Assert(ping.Val(), Equals, "PONG")
-
- c.Assert(t.client.Pool().Size(), Equals, 1)
- c.Assert(t.client.Pool().Len(), Equals, 1)
-}
-
-func (t *RedisConnPoolTest) TestConnPoolReusesConn(c *C) {
- for i := 0; i < 1000; i++ {
- ping := t.client.Ping()
- c.Assert(ping.Err(), IsNil)
- c.Assert(ping.Val(), Equals, "PONG")
- }
-
- c.Assert(t.client.Pool().Size(), Equals, 1)
- c.Assert(t.client.Pool().Len(), Equals, 1)
-}
-
-//------------------------------------------------------------------------------
-
-type RedisTest struct {
- client *redis.Client
-}
-
-var _ = Suite(&RedisTest{})
-
-func Test(t *testing.T) { TestingT(t) }
-
-func (t *RedisTest) SetUpTest(c *C) {
- t.client = redis.NewTCPClient(&redis.Options{
- Addr: ":6379",
- })
-
- // This is much faster than Flushall.
- c.Assert(t.client.Select(1).Err(), IsNil)
- c.Assert(t.client.FlushDb().Err(), IsNil)
- c.Assert(t.client.Select(0).Err(), IsNil)
- c.Assert(t.client.FlushDb().Err(), IsNil)
-}
-
-func (t *RedisTest) TearDownTest(c *C) {
- c.Assert(t.client.Close(), IsNil)
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestCmdStringMethod(c *C) {
- set := t.client.Set("foo", "bar")
- c.Assert(set.String(), Equals, "SET foo bar: OK")
-
- get := t.client.Get("foo")
- c.Assert(get.String(), Equals, "GET foo: bar")
-}
-
-func (t *RedisTest) TestCmdStringMethodError(c *C) {
- get2 := t.client.Get("key_does_not_exists")
- c.Assert(get2.String(), Equals, "GET key_does_not_exists: redis: nil")
-}
-
-func (t *RedisTest) TestRunWithouthCheckingErrVal(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-}
-
-func (t *RedisTest) TestGetSpecChars(c *C) {
- set := t.client.Set("key", "hello1\r\nhello2\r\n")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello1\r\nhello2\r\n")
-}
-
-func (t *RedisTest) TestGetBigVal(c *C) {
- val := string(bytes.Repeat([]byte{'*'}, 1<<16))
-
- set := t.client.Set("key", val)
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, val)
-}
-
-func (t *RedisTest) TestManyKeys(c *C) {
- var n = 100000
-
- for i := 0; i < n; i++ {
- t.client.Set("keys.key"+strconv.Itoa(i), "hello"+strconv.Itoa(i))
- }
- keys := t.client.Keys("keys.*")
- c.Assert(keys.Err(), IsNil)
- c.Assert(len(keys.Val()), Equals, n)
-}
-
-func (t *RedisTest) TestManyKeys2(c *C) {
- var n = 100000
-
- keys := []string{"non-existent-key"}
- for i := 0; i < n; i++ {
- key := "keys.key" + strconv.Itoa(i)
- t.client.Set(key, "hello"+strconv.Itoa(i))
- keys = append(keys, key)
- }
- keys = append(keys, "non-existent-key")
-
- mget := t.client.MGet(keys...)
- c.Assert(mget.Err(), IsNil)
- c.Assert(len(mget.Val()), Equals, n+2)
- vals := mget.Val()
- for i := 0; i < n; i++ {
- c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
- }
- c.Assert(vals[0], Equals, nil)
- c.Assert(vals[n+1], Equals, nil)
-}
-
-func (t *RedisTest) TestStringCmdHelpers(c *C) {
- set := t.client.Set("key", "10")
- c.Assert(set.Err(), IsNil)
-
- n, err := t.client.Get("key").Int64()
- c.Assert(err, IsNil)
- c.Assert(n, Equals, int64(10))
-
- un, err := t.client.Get("key").Uint64()
- c.Assert(err, IsNil)
- c.Assert(un, Equals, uint64(10))
-
- f, err := t.client.Get("key").Float64()
- c.Assert(err, IsNil)
- c.Assert(f, Equals, float64(10))
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestAuth(c *C) {
- auth := t.client.Auth("password")
- c.Assert(auth.Err(), ErrorMatches, "ERR Client sent AUTH, but no password is set")
- c.Assert(auth.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestEcho(c *C) {
- echo := t.client.Echo("hello")
- c.Assert(echo.Err(), IsNil)
- c.Assert(echo.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestPing(c *C) {
- ping := t.client.Ping()
- c.Assert(ping.Err(), IsNil)
- c.Assert(ping.Val(), Equals, "PONG")
-}
-
-func (t *RedisTest) TestSelect(c *C) {
- sel := t.client.Select(1)
- c.Assert(sel.Err(), IsNil)
- c.Assert(sel.Val(), Equals, "OK")
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestCmdKeysDel(c *C) {
- set := t.client.Set("key1", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
- set = t.client.Set("key2", "World")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- del := t.client.Del("key1", "key2", "key3")
- c.Assert(del.Err(), IsNil)
- c.Assert(del.Val(), Equals, int64(2))
-}
-
-func (t *RedisTest) TestCmdKeysDump(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- dump := t.client.Dump("key")
- c.Assert(dump.Err(), IsNil)
- c.Assert(dump.Val(), Equals, "\x00\x05hello\x06\x00\xf5\x9f\xb7\xf6\x90a\x1c\x99")
-}
-
-func (t *RedisTest) TestCmdKeysExists(c *C) {
- set := t.client.Set("key1", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- exists := t.client.Exists("key1")
- c.Assert(exists.Err(), IsNil)
- c.Assert(exists.Val(), Equals, true)
-
- exists = t.client.Exists("key2")
- c.Assert(exists.Err(), IsNil)
- c.Assert(exists.Val(), Equals, false)
-}
-
-func (t *RedisTest) TestCmdKeysExpire(c *C) {
- set := t.client.Set("key", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- expire := t.client.Expire("key", 10*time.Second)
- c.Assert(expire.Err(), IsNil)
- c.Assert(expire.Val(), Equals, true)
-
- ttl := t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val(), Equals, 10*time.Second)
-
- set = t.client.Set("key", "Hello World")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- ttl = t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val() < 0, Equals, true)
-}
-
-func (t *RedisTest) TestCmdKeysExpireAt(c *C) {
- set := t.client.Set("key", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- exists := t.client.Exists("key")
- c.Assert(exists.Err(), IsNil)
- c.Assert(exists.Val(), Equals, true)
-
- expireAt := t.client.ExpireAt("key", time.Now().Add(-time.Hour))
- c.Assert(expireAt.Err(), IsNil)
- c.Assert(expireAt.Val(), Equals, true)
-
- exists = t.client.Exists("key")
- c.Assert(exists.Err(), IsNil)
- c.Assert(exists.Val(), Equals, false)
-}
-
-func (t *RedisTest) TestCmdKeysKeys(c *C) {
- mset := t.client.MSet("one", "1", "two", "2", "three", "3", "four", "4")
- c.Assert(mset.Err(), IsNil)
- c.Assert(mset.Val(), Equals, "OK")
-
- keys := t.client.Keys("*o*")
- c.Assert(keys.Err(), IsNil)
- c.Assert(sortStrings(keys.Val()), DeepEquals, []string{"four", "one", "two"})
-
- keys = t.client.Keys("t??")
- c.Assert(keys.Err(), IsNil)
- c.Assert(keys.Val(), DeepEquals, []string{"two"})
-
- keys = t.client.Keys("*")
- c.Assert(keys.Err(), IsNil)
- c.Assert(
- sortStrings(keys.Val()),
- DeepEquals,
- []string{"four", "one", "three", "two"},
- )
-}
-
-func (t *RedisTest) TestCmdKeysMigrate(c *C) {
- migrate := t.client.Migrate("localhost", "6380", "key", 0, 0)
- c.Assert(migrate.Err(), IsNil)
- c.Assert(migrate.Val(), Equals, "NOKEY")
-
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- migrate = t.client.Migrate("localhost", "6380", "key", 0, 0)
- c.Assert(migrate.Err(), ErrorMatches, "IOERR error or timeout writing to target instance")
- c.Assert(migrate.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestCmdKeysMove(c *C) {
- move := t.client.Move("key", 1)
- c.Assert(move.Err(), IsNil)
- c.Assert(move.Val(), Equals, false)
-
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- move = t.client.Move("key", 1)
- c.Assert(move.Err(), IsNil)
- c.Assert(move.Val(), Equals, true)
-
- get := t.client.Get("key")
- c.Assert(get.Err(), Equals, redis.Nil)
- c.Assert(get.Val(), Equals, "")
-
- sel := t.client.Select(1)
- c.Assert(sel.Err(), IsNil)
- c.Assert(sel.Val(), Equals, "OK")
-
- get = t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestCmdKeysObject(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- refCount := t.client.ObjectRefCount("key")
- c.Assert(refCount.Err(), IsNil)
- c.Assert(refCount.Val(), Equals, int64(1))
-
- enc := t.client.ObjectEncoding("key")
- c.Assert(enc.Err(), IsNil)
- c.Assert(enc.Val(), Equals, "raw")
-
- idleTime := t.client.ObjectIdleTime("key")
- c.Assert(idleTime.Err(), IsNil)
- c.Assert(idleTime.Val(), Equals, time.Duration(0))
-}
-
-func (t *RedisTest) TestCmdKeysPersist(c *C) {
- set := t.client.Set("key", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- expire := t.client.Expire("key", 10*time.Second)
- c.Assert(expire.Err(), IsNil)
- c.Assert(expire.Val(), Equals, true)
-
- ttl := t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val(), Equals, 10*time.Second)
-
- persist := t.client.Persist("key")
- c.Assert(persist.Err(), IsNil)
- c.Assert(persist.Val(), Equals, true)
-
- ttl = t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val() < 0, Equals, true)
-}
-
-func (t *RedisTest) TestCmdKeysPExpire(c *C) {
- set := t.client.Set("key", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- expiration := 900 * time.Millisecond
- pexpire := t.client.PExpire("key", expiration)
- c.Assert(pexpire.Err(), IsNil)
- c.Assert(pexpire.Val(), Equals, true)
-
- ttl := t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val(), Equals, time.Second)
-
- pttl := t.client.PTTL("key")
- c.Assert(pttl.Err(), IsNil)
- c.Assert(pttl.Val() <= expiration, Equals, true)
- c.Assert(pttl.Val() >= expiration-time.Millisecond, Equals, true)
-}
-
-func (t *RedisTest) TestCmdKeysPExpireAt(c *C) {
- set := t.client.Set("key", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- expiration := 900 * time.Millisecond
- pexpireat := t.client.PExpireAt("key", time.Now().Add(expiration))
- c.Assert(pexpireat.Err(), IsNil)
- c.Assert(pexpireat.Val(), Equals, true)
-
- ttl := t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val(), Equals, time.Second)
-
- pttl := t.client.PTTL("key")
- c.Assert(pttl.Err(), IsNil)
- c.Assert(pttl.Val() <= expiration, Equals, true)
- c.Assert(pttl.Val() >= expiration-time.Millisecond, Equals, true)
-}
-
-func (t *RedisTest) TestCmdKeysPTTL(c *C) {
- set := t.client.Set("key", "Hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- expiration := time.Second
- expire := t.client.Expire("key", expiration)
- c.Assert(expire.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- pttl := t.client.PTTL("key")
- c.Assert(pttl.Err(), IsNil)
- c.Assert(pttl.Val() <= expiration, Equals, true)
- c.Assert(pttl.Val() >= expiration-time.Millisecond, Equals, true)
-}
-
-func (t *RedisTest) TestCmdKeysRandomKey(c *C) {
- randomKey := t.client.RandomKey()
- c.Assert(randomKey.Err(), Equals, redis.Nil)
- c.Assert(randomKey.Val(), Equals, "")
-
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- randomKey = t.client.RandomKey()
- c.Assert(randomKey.Err(), IsNil)
- c.Assert(randomKey.Val(), Equals, "key")
-}
-
-func (t *RedisTest) TestCmdKeysRename(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- status := t.client.Rename("key", "key1")
- c.Assert(status.Err(), IsNil)
- c.Assert(status.Val(), Equals, "OK")
-
- get := t.client.Get("key1")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestCmdKeysRenameNX(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- renameNX := t.client.RenameNX("key", "key1")
- c.Assert(renameNX.Err(), IsNil)
- c.Assert(renameNX.Val(), Equals, true)
-
- get := t.client.Get("key1")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestCmdKeysRestore(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- dump := t.client.Dump("key")
- c.Assert(dump.Err(), IsNil)
-
- del := t.client.Del("key")
- c.Assert(del.Err(), IsNil)
-
- restore := t.client.Restore("key", 0, dump.Val())
- c.Assert(restore.Err(), IsNil)
- c.Assert(restore.Val(), Equals, "OK")
-
- type_ := t.client.Type("key")
- c.Assert(type_.Err(), IsNil)
- c.Assert(type_.Val(), Equals, "string")
-
- lRange := t.client.Get("key")
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestCmdKeysSort(c *C) {
- lPush := t.client.LPush("list", "1")
- c.Assert(lPush.Err(), IsNil)
- c.Assert(lPush.Val(), Equals, int64(1))
- lPush = t.client.LPush("list", "3")
- c.Assert(lPush.Err(), IsNil)
- c.Assert(lPush.Val(), Equals, int64(2))
- lPush = t.client.LPush("list", "2")
- c.Assert(lPush.Err(), IsNil)
- c.Assert(lPush.Val(), Equals, int64(3))
-
- sort := t.client.Sort("list", redis.Sort{Offset: 0, Count: 2, Order: "ASC"})
- c.Assert(sort.Err(), IsNil)
- c.Assert(sort.Val(), DeepEquals, []string{"1", "2"})
-}
-
-func (t *RedisTest) TestCmdKeysSortBy(c *C) {
- lPush := t.client.LPush("list", "1")
- c.Assert(lPush.Err(), IsNil)
- c.Assert(lPush.Val(), Equals, int64(1))
- lPush = t.client.LPush("list", "3")
- c.Assert(lPush.Err(), IsNil)
- c.Assert(lPush.Val(), Equals, int64(2))
- lPush = t.client.LPush("list", "2")
- c.Assert(lPush.Err(), IsNil)
- c.Assert(lPush.Val(), Equals, int64(3))
-
- set := t.client.Set("weight_1", "5")
- c.Assert(set.Err(), IsNil)
- set = t.client.Set("weight_2", "2")
- c.Assert(set.Err(), IsNil)
- set = t.client.Set("weight_3", "8")
- c.Assert(set.Err(), IsNil)
-
- sort := t.client.Sort("list", redis.Sort{Offset: 0, Count: 2, Order: "ASC", By: "weight_*"})
- c.Assert(sort.Err(), IsNil)
- c.Assert(sort.Val(), DeepEquals, []string{"2", "1"})
-}
-
-func (t *RedisTest) TestCmdKeysTTL(c *C) {
- ttl := t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val() < 0, Equals, true)
-
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- expire := t.client.Expire("key", 60*time.Second)
- c.Assert(expire.Err(), IsNil)
- c.Assert(expire.Val(), Equals, true)
-
- ttl = t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val(), Equals, 60*time.Second)
-}
-
-func (t *RedisTest) TestCmdKeysType(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- type_ := t.client.Type("key")
- c.Assert(type_.Err(), IsNil)
- c.Assert(type_.Val(), Equals, "string")
-}
-
-func (t *RedisTest) TestCmdScan(c *C) {
- for i := 0; i < 1000; i++ {
- set := t.client.Set(fmt.Sprintf("key%d", i), "hello")
- c.Assert(set.Err(), IsNil)
- }
-
- cursor, keys, err := t.client.Scan(0, "", 0).Result()
- c.Assert(err, IsNil)
- c.Assert(cursor > 0, Equals, true)
- c.Assert(len(keys) > 0, Equals, true)
-}
-
-func (t *RedisTest) TestCmdSScan(c *C) {
- for i := 0; i < 1000; i++ {
- sadd := t.client.SAdd("myset", fmt.Sprintf("member%d", i))
- c.Assert(sadd.Err(), IsNil)
- }
-
- cursor, keys, err := t.client.SScan("myset", 0, "", 0).Result()
- c.Assert(err, IsNil)
- c.Assert(cursor > 0, Equals, true)
- c.Assert(len(keys) > 0, Equals, true)
-}
-
-func (t *RedisTest) TestCmdHScan(c *C) {
- for i := 0; i < 1000; i++ {
- sadd := t.client.HSet("myhash", fmt.Sprintf("key%d", i), "hello")
- c.Assert(sadd.Err(), IsNil)
- }
-
- cursor, keys, err := t.client.HScan("myhash", 0, "", 0).Result()
- c.Assert(err, IsNil)
- c.Assert(cursor > 0, Equals, true)
- c.Assert(len(keys) > 0, Equals, true)
-}
-
-func (t *RedisTest) TestCmdZScan(c *C) {
- for i := 0; i < 1000; i++ {
- sadd := t.client.ZAdd("myset", redis.Z{float64(i), fmt.Sprintf("member%d", i)})
- c.Assert(sadd.Err(), IsNil)
- }
-
- cursor, keys, err := t.client.ZScan("myset", 0, "", 0).Result()
- c.Assert(err, IsNil)
- c.Assert(cursor > 0, Equals, true)
- c.Assert(len(keys) > 0, Equals, true)
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestStringsAppend(c *C) {
- exists := t.client.Exists("key")
- c.Assert(exists.Err(), IsNil)
- c.Assert(exists.Val(), Equals, false)
-
- append := t.client.Append("key", "Hello")
- c.Assert(append.Err(), IsNil)
- c.Assert(append.Val(), Equals, int64(5))
-
- append = t.client.Append("key", " World")
- c.Assert(append.Err(), IsNil)
- c.Assert(append.Val(), Equals, int64(11))
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "Hello World")
-}
-
-func (t *RedisTest) TestStringsBitCount(c *C) {
- set := t.client.Set("key", "foobar")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- bitCount := t.client.BitCount("key", nil)
- c.Assert(bitCount.Err(), IsNil)
- c.Assert(bitCount.Val(), Equals, int64(26))
-
- bitCount = t.client.BitCount("key", &redis.BitCount{0, 0})
- c.Assert(bitCount.Err(), IsNil)
- c.Assert(bitCount.Val(), Equals, int64(4))
-
- bitCount = t.client.BitCount("key", &redis.BitCount{1, 1})
- c.Assert(bitCount.Err(), IsNil)
- c.Assert(bitCount.Val(), Equals, int64(6))
-}
-
-func (t *RedisTest) TestStringsBitOpAnd(c *C) {
- set := t.client.Set("key1", "1")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- set = t.client.Set("key2", "0")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- bitOpAnd := t.client.BitOpAnd("dest", "key1", "key2")
- c.Assert(bitOpAnd.Err(), IsNil)
- c.Assert(bitOpAnd.Val(), Equals, int64(1))
-
- get := t.client.Get("dest")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "0")
-}
-
-func (t *RedisTest) TestStringsBitOpOr(c *C) {
- set := t.client.Set("key1", "1")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- set = t.client.Set("key2", "0")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- bitOpOr := t.client.BitOpOr("dest", "key1", "key2")
- c.Assert(bitOpOr.Err(), IsNil)
- c.Assert(bitOpOr.Val(), Equals, int64(1))
-
- get := t.client.Get("dest")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "1")
-}
-
-func (t *RedisTest) TestStringsBitOpXor(c *C) {
- set := t.client.Set("key1", "\xff")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- set = t.client.Set("key2", "\x0f")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- bitOpXor := t.client.BitOpXor("dest", "key1", "key2")
- c.Assert(bitOpXor.Err(), IsNil)
- c.Assert(bitOpXor.Val(), Equals, int64(1))
-
- get := t.client.Get("dest")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "\xf0")
-}
-
-func (t *RedisTest) TestStringsBitOpNot(c *C) {
- set := t.client.Set("key1", "\x00")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- bitOpNot := t.client.BitOpNot("dest", "key1")
- c.Assert(bitOpNot.Err(), IsNil)
- c.Assert(bitOpNot.Val(), Equals, int64(1))
-
- get := t.client.Get("dest")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "\xff")
-}
-
-func (t *RedisTest) TestStringsDecr(c *C) {
- set := t.client.Set("key", "10")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- decr := t.client.Decr("key")
- c.Assert(decr.Err(), IsNil)
- c.Assert(decr.Val(), Equals, int64(9))
-
- set = t.client.Set("key", "234293482390480948029348230948")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- decr = t.client.Decr("key")
- c.Assert(decr.Err(), ErrorMatches, "ERR value is not an integer or out of range")
- c.Assert(decr.Val(), Equals, int64(0))
-}
-
-func (t *RedisTest) TestStringsDecrBy(c *C) {
- set := t.client.Set("key", "10")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- decrBy := t.client.DecrBy("key", 5)
- c.Assert(decrBy.Err(), IsNil)
- c.Assert(decrBy.Val(), Equals, int64(5))
-}
-
-func (t *RedisTest) TestStringsGet(c *C) {
- get := t.client.Get("_")
- c.Assert(get.Err(), Equals, redis.Nil)
- c.Assert(get.Val(), Equals, "")
-
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- get = t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestStringsGetBit(c *C) {
- setBit := t.client.SetBit("key", 7, 1)
- c.Assert(setBit.Err(), IsNil)
- c.Assert(setBit.Val(), Equals, int64(0))
-
- getBit := t.client.GetBit("key", 0)
- c.Assert(getBit.Err(), IsNil)
- c.Assert(getBit.Val(), Equals, int64(0))
-
- getBit = t.client.GetBit("key", 7)
- c.Assert(getBit.Err(), IsNil)
- c.Assert(getBit.Val(), Equals, int64(1))
-
- getBit = t.client.GetBit("key", 100)
- c.Assert(getBit.Err(), IsNil)
- c.Assert(getBit.Val(), Equals, int64(0))
-}
-
-func (t *RedisTest) TestStringsGetRange(c *C) {
- set := t.client.Set("key", "This is a string")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- getRange := t.client.GetRange("key", 0, 3)
- c.Assert(getRange.Err(), IsNil)
- c.Assert(getRange.Val(), Equals, "This")
-
- getRange = t.client.GetRange("key", -3, -1)
- c.Assert(getRange.Err(), IsNil)
- c.Assert(getRange.Val(), Equals, "ing")
-
- getRange = t.client.GetRange("key", 0, -1)
- c.Assert(getRange.Err(), IsNil)
- c.Assert(getRange.Val(), Equals, "This is a string")
-
- getRange = t.client.GetRange("key", 10, 100)
- c.Assert(getRange.Err(), IsNil)
- c.Assert(getRange.Val(), Equals, "string")
-}
-
-func (t *RedisTest) TestStringsGetSet(c *C) {
- incr := t.client.Incr("key")
- c.Assert(incr.Err(), IsNil)
- c.Assert(incr.Val(), Equals, int64(1))
-
- getSet := t.client.GetSet("key", "0")
- c.Assert(getSet.Err(), IsNil)
- c.Assert(getSet.Val(), Equals, "1")
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "0")
-}
-
-func (t *RedisTest) TestStringsIncr(c *C) {
- set := t.client.Set("key", "10")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- incr := t.client.Incr("key")
- c.Assert(incr.Err(), IsNil)
- c.Assert(incr.Val(), Equals, int64(11))
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "11")
-}
-
-func (t *RedisTest) TestStringsIncrBy(c *C) {
- set := t.client.Set("key", "10")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- incrBy := t.client.IncrBy("key", 5)
- c.Assert(incrBy.Err(), IsNil)
- c.Assert(incrBy.Val(), Equals, int64(15))
-}
-
-func (t *RedisTest) TestIncrByFloat(c *C) {
- set := t.client.Set("key", "10.50")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- incrByFloat := t.client.IncrByFloat("key", 0.1)
- c.Assert(incrByFloat.Err(), IsNil)
- c.Assert(incrByFloat.Val(), Equals, 10.6)
-
- set = t.client.Set("key", "5.0e3")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- incrByFloat = t.client.IncrByFloat("key", 2.0e2)
- c.Assert(incrByFloat.Err(), IsNil)
- c.Assert(incrByFloat.Val(), Equals, float64(5200))
-}
-
-func (t *RedisTest) TestIncrByFloatOverflow(c *C) {
- incrByFloat := t.client.IncrByFloat("key", 996945661)
- c.Assert(incrByFloat.Err(), IsNil)
- c.Assert(incrByFloat.Val(), Equals, float64(996945661))
-}
-
-func (t *RedisTest) TestStringsMSetMGet(c *C) {
- mSet := t.client.MSet("key1", "hello1", "key2", "hello2")
- c.Assert(mSet.Err(), IsNil)
- c.Assert(mSet.Val(), Equals, "OK")
-
- mGet := t.client.MGet("key1", "key2", "_")
- c.Assert(mGet.Err(), IsNil)
- c.Assert(mGet.Val(), DeepEquals, []interface{}{"hello1", "hello2", nil})
-}
-
-func (t *RedisTest) TestStringsMSetNX(c *C) {
- mSetNX := t.client.MSetNX("key1", "hello1", "key2", "hello2")
- c.Assert(mSetNX.Err(), IsNil)
- c.Assert(mSetNX.Val(), Equals, true)
-
- mSetNX = t.client.MSetNX("key2", "hello1", "key3", "hello2")
- c.Assert(mSetNX.Err(), IsNil)
- c.Assert(mSetNX.Val(), Equals, false)
-}
-
-func (t *RedisTest) TestStringsPSetEx(c *C) {
- expiration := 50 * time.Millisecond
- psetex := t.client.PSetEx("key", expiration, "hello")
- c.Assert(psetex.Err(), IsNil)
- c.Assert(psetex.Val(), Equals, "OK")
-
- pttl := t.client.PTTL("key")
- c.Assert(pttl.Err(), IsNil)
- c.Assert(pttl.Val() <= expiration, Equals, true)
- c.Assert(pttl.Val() >= expiration-time.Millisecond, Equals, true)
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestStringsSetGet(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestStringsSetEx(c *C) {
- setEx := t.client.SetEx("key", 10*time.Second, "hello")
- c.Assert(setEx.Err(), IsNil)
- c.Assert(setEx.Val(), Equals, "OK")
-
- ttl := t.client.TTL("key")
- c.Assert(ttl.Err(), IsNil)
- c.Assert(ttl.Val(), Equals, 10*time.Second)
-}
-
-func (t *RedisTest) TestStringsSetNX(c *C) {
- setNX := t.client.SetNX("key", "hello")
- c.Assert(setNX.Err(), IsNil)
- c.Assert(setNX.Val(), Equals, true)
-
- setNX = t.client.SetNX("key", "hello2")
- c.Assert(setNX.Err(), IsNil)
- c.Assert(setNX.Val(), Equals, false)
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestStringsSetRange(c *C) {
- set := t.client.Set("key", "Hello World")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- range_ := t.client.SetRange("key", 6, "Redis")
- c.Assert(range_.Err(), IsNil)
- c.Assert(range_.Val(), Equals, int64(11))
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "Hello Redis")
-}
-
-func (t *RedisTest) TestStringsStrLen(c *C) {
- set := t.client.Set("key", "hello")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- strLen := t.client.StrLen("key")
- c.Assert(strLen.Err(), IsNil)
- c.Assert(strLen.Val(), Equals, int64(5))
-
- strLen = t.client.StrLen("_")
- c.Assert(strLen.Err(), IsNil)
- c.Assert(strLen.Val(), Equals, int64(0))
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestCmdHDel(c *C) {
- hSet := t.client.HSet("hash", "key", "hello")
- c.Assert(hSet.Err(), IsNil)
-
- hDel := t.client.HDel("hash", "key")
- c.Assert(hDel.Err(), IsNil)
- c.Assert(hDel.Val(), Equals, int64(1))
-
- hDel = t.client.HDel("hash", "key")
- c.Assert(hDel.Err(), IsNil)
- c.Assert(hDel.Val(), Equals, int64(0))
-}
-
-func (t *RedisTest) TestCmdHExists(c *C) {
- hSet := t.client.HSet("hash", "key", "hello")
- c.Assert(hSet.Err(), IsNil)
-
- hExists := t.client.HExists("hash", "key")
- c.Assert(hExists.Err(), IsNil)
- c.Assert(hExists.Val(), Equals, true)
-
- hExists = t.client.HExists("hash", "key1")
- c.Assert(hExists.Err(), IsNil)
- c.Assert(hExists.Val(), Equals, false)
-}
-
-func (t *RedisTest) TestCmdHGet(c *C) {
- hSet := t.client.HSet("hash", "key", "hello")
- c.Assert(hSet.Err(), IsNil)
-
- hGet := t.client.HGet("hash", "key")
- c.Assert(hGet.Err(), IsNil)
- c.Assert(hGet.Val(), Equals, "hello")
-
- hGet = t.client.HGet("hash", "key1")
- c.Assert(hGet.Err(), Equals, redis.Nil)
- c.Assert(hGet.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestCmdHGetAll(c *C) {
- hSet := t.client.HSet("hash", "key1", "hello1")
- c.Assert(hSet.Err(), IsNil)
- hSet = t.client.HSet("hash", "key2", "hello2")
- c.Assert(hSet.Err(), IsNil)
-
- hGetAll := t.client.HGetAll("hash")
- c.Assert(hGetAll.Err(), IsNil)
- c.Assert(hGetAll.Val(), DeepEquals, []string{"key1", "hello1", "key2", "hello2"})
-}
-
-func (t *RedisTest) TestCmdHGetAllMap(c *C) {
- hSet := t.client.HSet("hash", "key1", "hello1")
- c.Assert(hSet.Err(), IsNil)
- hSet = t.client.HSet("hash", "key2", "hello2")
- c.Assert(hSet.Err(), IsNil)
-
- hGetAll := t.client.HGetAllMap("hash")
- c.Assert(hGetAll.Err(), IsNil)
- c.Assert(hGetAll.Val(), DeepEquals, map[string]string{"key1": "hello1", "key2": "hello2"})
-}
-
-func (t *RedisTest) TestCmdHIncrBy(c *C) {
- hSet := t.client.HSet("hash", "key", "5")
- c.Assert(hSet.Err(), IsNil)
-
- hIncrBy := t.client.HIncrBy("hash", "key", 1)
- c.Assert(hIncrBy.Err(), IsNil)
- c.Assert(hIncrBy.Val(), Equals, int64(6))
-
- hIncrBy = t.client.HIncrBy("hash", "key", -1)
- c.Assert(hIncrBy.Err(), IsNil)
- c.Assert(hIncrBy.Val(), Equals, int64(5))
-
- hIncrBy = t.client.HIncrBy("hash", "key", -10)
- c.Assert(hIncrBy.Err(), IsNil)
- c.Assert(hIncrBy.Val(), Equals, int64(-5))
-}
-
-func (t *RedisTest) TestCmdHIncrByFloat(c *C) {
- hSet := t.client.HSet("hash", "field", "10.50")
- c.Assert(hSet.Err(), IsNil)
- c.Assert(hSet.Val(), Equals, true)
-
- hIncrByFloat := t.client.HIncrByFloat("hash", "field", 0.1)
- c.Assert(hIncrByFloat.Err(), IsNil)
- c.Assert(hIncrByFloat.Val(), Equals, 10.6)
-
- hSet = t.client.HSet("hash", "field", "5.0e3")
- c.Assert(hSet.Err(), IsNil)
- c.Assert(hSet.Val(), Equals, false)
-
- hIncrByFloat = t.client.HIncrByFloat("hash", "field", 2.0e2)
- c.Assert(hIncrByFloat.Err(), IsNil)
- c.Assert(hIncrByFloat.Val(), Equals, float64(5200))
-}
-
-func (t *RedisTest) TestCmdHKeys(c *C) {
- hkeys := t.client.HKeys("hash")
- c.Assert(hkeys.Err(), IsNil)
- c.Assert(hkeys.Val(), DeepEquals, []string{})
-
- hset := t.client.HSet("hash", "key1", "hello1")
- c.Assert(hset.Err(), IsNil)
- hset = t.client.HSet("hash", "key2", "hello2")
- c.Assert(hset.Err(), IsNil)
-
- hkeys = t.client.HKeys("hash")
- c.Assert(hkeys.Err(), IsNil)
- c.Assert(hkeys.Val(), DeepEquals, []string{"key1", "key2"})
-}
-
-func (t *RedisTest) TestCmdHLen(c *C) {
- hSet := t.client.HSet("hash", "key1", "hello1")
- c.Assert(hSet.Err(), IsNil)
- hSet = t.client.HSet("hash", "key2", "hello2")
- c.Assert(hSet.Err(), IsNil)
-
- hLen := t.client.HLen("hash")
- c.Assert(hLen.Err(), IsNil)
- c.Assert(hLen.Val(), Equals, int64(2))
-}
-
-func (t *RedisTest) TestCmdHMGet(c *C) {
- hSet := t.client.HSet("hash", "key1", "hello1")
- c.Assert(hSet.Err(), IsNil)
- hSet = t.client.HSet("hash", "key2", "hello2")
- c.Assert(hSet.Err(), IsNil)
-
- hMGet := t.client.HMGet("hash", "key1", "key2", "_")
- c.Assert(hMGet.Err(), IsNil)
- c.Assert(hMGet.Val(), DeepEquals, []interface{}{"hello1", "hello2", nil})
-}
-
-func (t *RedisTest) TestCmdHMSet(c *C) {
- hMSet := t.client.HMSet("hash", "key1", "hello1", "key2", "hello2")
- c.Assert(hMSet.Err(), IsNil)
- c.Assert(hMSet.Val(), Equals, "OK")
-
- hGet := t.client.HGet("hash", "key1")
- c.Assert(hGet.Err(), IsNil)
- c.Assert(hGet.Val(), Equals, "hello1")
-
- hGet = t.client.HGet("hash", "key2")
- c.Assert(hGet.Err(), IsNil)
- c.Assert(hGet.Val(), Equals, "hello2")
-}
-
-func (t *RedisTest) TestCmdHSet(c *C) {
- hSet := t.client.HSet("hash", "key", "hello")
- c.Assert(hSet.Err(), IsNil)
- c.Assert(hSet.Val(), Equals, true)
-
- hGet := t.client.HGet("hash", "key")
- c.Assert(hGet.Err(), IsNil)
- c.Assert(hGet.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestCmdHSetNX(c *C) {
- hSetNX := t.client.HSetNX("hash", "key", "hello")
- c.Assert(hSetNX.Err(), IsNil)
- c.Assert(hSetNX.Val(), Equals, true)
-
- hSetNX = t.client.HSetNX("hash", "key", "hello")
- c.Assert(hSetNX.Err(), IsNil)
- c.Assert(hSetNX.Val(), Equals, false)
-
- hGet := t.client.HGet("hash", "key")
- c.Assert(hGet.Err(), IsNil)
- c.Assert(hGet.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestCmdHVals(c *C) {
- hSet := t.client.HSet("hash", "key1", "hello1")
- c.Assert(hSet.Err(), IsNil)
- hSet = t.client.HSet("hash", "key2", "hello2")
- c.Assert(hSet.Err(), IsNil)
-
- hVals := t.client.HVals("hash")
- c.Assert(hVals.Err(), IsNil)
- c.Assert(hVals.Val(), DeepEquals, []string{"hello1", "hello2"})
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestCmdListsBLPop(c *C) {
- rPush := t.client.RPush("list1", "a", "b", "c")
- c.Assert(rPush.Err(), IsNil)
-
- bLPop := t.client.BLPop(0, "list1", "list2")
- c.Assert(bLPop.Err(), IsNil)
- c.Assert(bLPop.Val(), DeepEquals, []string{"list1", "a"})
-}
-
-func (t *RedisTest) TestCmdListsBLPopBlocks(c *C) {
- started := make(chan bool)
- done := make(chan bool)
- go func() {
- started <- true
- bLPop := t.client.BLPop(0, "list")
- c.Assert(bLPop.Err(), IsNil)
- c.Assert(bLPop.Val(), DeepEquals, []string{"list", "a"})
- done <- true
- }()
- <-started
-
- select {
- case <-done:
- c.Error("BLPop is not blocked")
- case <-time.After(time.Second):
- // ok
- }
-
- rPush := t.client.RPush("list", "a")
- c.Assert(rPush.Err(), IsNil)
-
- select {
- case <-done:
- // ok
- case <-time.After(time.Second):
- c.Error("BLPop is still blocked")
- // ok
- }
-}
-
-func (t *RedisTest) TestCmdListsBLPopTimeout(c *C) {
- bLPop := t.client.BLPop(1, "list1")
- c.Assert(bLPop.Err(), Equals, redis.Nil)
- c.Assert(bLPop.Val(), IsNil)
-}
-
-func (t *RedisTest) TestCmdListsBRPop(c *C) {
- rPush := t.client.RPush("list1", "a", "b", "c")
- c.Assert(rPush.Err(), IsNil)
-
- bRPop := t.client.BRPop(0, "list1", "list2")
- c.Assert(bRPop.Err(), IsNil)
- c.Assert(bRPop.Val(), DeepEquals, []string{"list1", "c"})
-}
-
-func (t *RedisTest) TestCmdListsBRPopBlocks(c *C) {
- started := make(chan bool)
- done := make(chan bool)
- go func() {
- started <- true
- brpop := t.client.BRPop(0, "list")
- c.Assert(brpop.Err(), IsNil)
- c.Assert(brpop.Val(), DeepEquals, []string{"list", "a"})
- done <- true
- }()
- <-started
-
- select {
- case <-done:
- c.Error("BRPop is not blocked")
- case <-time.After(time.Second):
- // ok
- }
-
- rPush := t.client.RPush("list", "a")
- c.Assert(rPush.Err(), IsNil)
-
- select {
- case <-done:
- // ok
- case <-time.After(time.Second):
- c.Error("BRPop is still blocked")
- // ok
- }
-}
-
-func (t *RedisTest) TestCmdListsBRPopLPush(c *C) {
- rPush := t.client.RPush("list1", "a", "b", "c")
- c.Assert(rPush.Err(), IsNil)
-
- bRPopLPush := t.client.BRPopLPush("list1", "list2", 0)
- c.Assert(bRPopLPush.Err(), IsNil)
- c.Assert(bRPopLPush.Val(), Equals, "c")
-}
-
-func (t *RedisTest) TestCmdListsLIndex(c *C) {
- lPush := t.client.LPush("list", "World")
- c.Assert(lPush.Err(), IsNil)
- lPush = t.client.LPush("list", "Hello")
- c.Assert(lPush.Err(), IsNil)
-
- lIndex := t.client.LIndex("list", 0)
- c.Assert(lIndex.Err(), IsNil)
- c.Assert(lIndex.Val(), Equals, "Hello")
-
- lIndex = t.client.LIndex("list", -1)
- c.Assert(lIndex.Err(), IsNil)
- c.Assert(lIndex.Val(), Equals, "World")
-
- lIndex = t.client.LIndex("list", 3)
- c.Assert(lIndex.Err(), Equals, redis.Nil)
- c.Assert(lIndex.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestCmdListsLInsert(c *C) {
- rPush := t.client.RPush("list", "Hello")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "World")
- c.Assert(rPush.Err(), IsNil)
-
- lInsert := t.client.LInsert("list", "BEFORE", "World", "There")
- c.Assert(lInsert.Err(), IsNil)
- c.Assert(lInsert.Val(), Equals, int64(3))
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"Hello", "There", "World"})
-}
-
-func (t *RedisTest) TestCmdListsLLen(c *C) {
- lPush := t.client.LPush("list", "World")
- c.Assert(lPush.Err(), IsNil)
- lPush = t.client.LPush("list", "Hello")
- c.Assert(lPush.Err(), IsNil)
-
- lLen := t.client.LLen("list")
- c.Assert(lLen.Err(), IsNil)
- c.Assert(lLen.Val(), Equals, int64(2))
-}
-
-func (t *RedisTest) TestCmdListsLPop(c *C) {
- rPush := t.client.RPush("list", "one")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "two")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "three")
- c.Assert(rPush.Err(), IsNil)
-
- lPop := t.client.LPop("list")
- c.Assert(lPop.Err(), IsNil)
- c.Assert(lPop.Val(), Equals, "one")
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"two", "three"})
-}
-
-func (t *RedisTest) TestCmdListsLPush(c *C) {
- lPush := t.client.LPush("list", "World")
- c.Assert(lPush.Err(), IsNil)
- lPush = t.client.LPush("list", "Hello")
- c.Assert(lPush.Err(), IsNil)
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"Hello", "World"})
-}
-
-func (t *RedisTest) TestCmdListsLPushX(c *C) {
- lPush := t.client.LPush("list", "World")
- c.Assert(lPush.Err(), IsNil)
-
- lPushX := t.client.LPushX("list", "Hello")
- c.Assert(lPushX.Err(), IsNil)
- c.Assert(lPushX.Val(), Equals, int64(2))
-
- lPushX = t.client.LPushX("list2", "Hello")
- c.Assert(lPushX.Err(), IsNil)
- c.Assert(lPushX.Val(), Equals, int64(0))
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"Hello", "World"})
-
- lRange = t.client.LRange("list2", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{})
-}
-
-func (t *RedisTest) TestCmdListsLRange(c *C) {
- rPush := t.client.RPush("list", "one")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "two")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "three")
- c.Assert(rPush.Err(), IsNil)
-
- lRange := t.client.LRange("list", 0, 0)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"one"})
-
- lRange = t.client.LRange("list", -3, 2)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"one", "two", "three"})
-
- lRange = t.client.LRange("list", -100, 100)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"one", "two", "three"})
-
- lRange = t.client.LRange("list", 5, 10)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{})
-}
-
-func (t *RedisTest) TestCmdListsLRem(c *C) {
- rPush := t.client.RPush("list", "hello")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "hello")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "key")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "hello")
- c.Assert(rPush.Err(), IsNil)
-
- lRem := t.client.LRem("list", -2, "hello")
- c.Assert(lRem.Err(), IsNil)
- c.Assert(lRem.Val(), Equals, int64(2))
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"hello", "key"})
-}
-
-func (t *RedisTest) TestCmdListsLSet(c *C) {
- rPush := t.client.RPush("list", "one")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "two")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "three")
- c.Assert(rPush.Err(), IsNil)
-
- lSet := t.client.LSet("list", 0, "four")
- c.Assert(lSet.Err(), IsNil)
- c.Assert(lSet.Val(), Equals, "OK")
-
- lSet = t.client.LSet("list", -2, "five")
- c.Assert(lSet.Err(), IsNil)
- c.Assert(lSet.Val(), Equals, "OK")
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"four", "five", "three"})
-}
-
-func (t *RedisTest) TestCmdListsLTrim(c *C) {
- rPush := t.client.RPush("list", "one")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "two")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "three")
- c.Assert(rPush.Err(), IsNil)
-
- lTrim := t.client.LTrim("list", 1, -1)
- c.Assert(lTrim.Err(), IsNil)
- c.Assert(lTrim.Val(), Equals, "OK")
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"two", "three"})
-}
-
-func (t *RedisTest) TestCmdListsRPop(c *C) {
- rPush := t.client.RPush("list", "one")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "two")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "three")
- c.Assert(rPush.Err(), IsNil)
-
- rPop := t.client.RPop("list")
- c.Assert(rPop.Err(), IsNil)
- c.Assert(rPop.Val(), Equals, "three")
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"one", "two"})
-}
-
-func (t *RedisTest) TestCmdListsRPopLPush(c *C) {
- rPush := t.client.RPush("list", "one")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "two")
- c.Assert(rPush.Err(), IsNil)
- rPush = t.client.RPush("list", "three")
- c.Assert(rPush.Err(), IsNil)
-
- rPopLPush := t.client.RPopLPush("list", "list2")
- c.Assert(rPopLPush.Err(), IsNil)
- c.Assert(rPopLPush.Val(), Equals, "three")
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"one", "two"})
-
- lRange = t.client.LRange("list2", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"three"})
-}
-
-func (t *RedisTest) TestCmdListsRPush(c *C) {
- rPush := t.client.RPush("list", "Hello")
- c.Assert(rPush.Err(), IsNil)
- c.Assert(rPush.Val(), Equals, int64(1))
-
- rPush = t.client.RPush("list", "World")
- c.Assert(rPush.Err(), IsNil)
- c.Assert(rPush.Val(), Equals, int64(2))
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"Hello", "World"})
-}
-
-func (t *RedisTest) TestCmdListsRPushX(c *C) {
- rPush := t.client.RPush("list", "Hello")
- c.Assert(rPush.Err(), IsNil)
- c.Assert(rPush.Val(), Equals, int64(1))
-
- rPushX := t.client.RPushX("list", "World")
- c.Assert(rPushX.Err(), IsNil)
- c.Assert(rPushX.Val(), Equals, int64(2))
-
- rPushX = t.client.RPushX("list2", "World")
- c.Assert(rPushX.Err(), IsNil)
- c.Assert(rPushX.Val(), Equals, int64(0))
-
- lRange := t.client.LRange("list", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{"Hello", "World"})
-
- lRange = t.client.LRange("list2", 0, -1)
- c.Assert(lRange.Err(), IsNil)
- c.Assert(lRange.Val(), DeepEquals, []string{})
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestSAdd(c *C) {
- sAdd := t.client.SAdd("set", "Hello")
- c.Assert(sAdd.Err(), IsNil)
- c.Assert(sAdd.Val(), Equals, int64(1))
-
- sAdd = t.client.SAdd("set", "World")
- c.Assert(sAdd.Err(), IsNil)
- c.Assert(sAdd.Val(), Equals, int64(1))
-
- sAdd = t.client.SAdd("set", "World")
- c.Assert(sAdd.Err(), IsNil)
- c.Assert(sAdd.Val(), Equals, int64(0))
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sortStrings(sMembers.Val()), DeepEquals, []string{"Hello", "World"})
-}
-
-func (t *RedisTest) TestSCard(c *C) {
- sAdd := t.client.SAdd("set", "Hello")
- c.Assert(sAdd.Err(), IsNil)
- c.Assert(sAdd.Val(), Equals, int64(1))
-
- sAdd = t.client.SAdd("set", "World")
- c.Assert(sAdd.Err(), IsNil)
- c.Assert(sAdd.Val(), Equals, int64(1))
-
- sCard := t.client.SCard("set")
- c.Assert(sCard.Err(), IsNil)
- c.Assert(sCard.Val(), Equals, int64(2))
-}
-
-func (t *RedisTest) TestSDiff(c *C) {
- sAdd := t.client.SAdd("set1", "a")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "b")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "c")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "c")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "d")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "e")
- c.Assert(sAdd.Err(), IsNil)
-
- sDiff := t.client.SDiff("set1", "set2")
- c.Assert(sDiff.Err(), IsNil)
- c.Assert(sortStrings(sDiff.Val()), DeepEquals, []string{"a", "b"})
-}
-
-func (t *RedisTest) TestSDiffStore(c *C) {
- sAdd := t.client.SAdd("set1", "a")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "b")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "c")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "c")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "d")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "e")
- c.Assert(sAdd.Err(), IsNil)
-
- sDiffStore := t.client.SDiffStore("set", "set1", "set2")
- c.Assert(sDiffStore.Err(), IsNil)
- c.Assert(sDiffStore.Val(), Equals, int64(2))
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sortStrings(sMembers.Val()), DeepEquals, []string{"a", "b"})
-}
-
-func (t *RedisTest) TestSInter(c *C) {
- sAdd := t.client.SAdd("set1", "a")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "b")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "c")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "c")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "d")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "e")
- c.Assert(sAdd.Err(), IsNil)
-
- sInter := t.client.SInter("set1", "set2")
- c.Assert(sInter.Err(), IsNil)
- c.Assert(sInter.Val(), DeepEquals, []string{"c"})
-}
-
-func (t *RedisTest) TestSInterStore(c *C) {
- sAdd := t.client.SAdd("set1", "a")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "b")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "c")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "c")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "d")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "e")
- c.Assert(sAdd.Err(), IsNil)
-
- sInterStore := t.client.SInterStore("set", "set1", "set2")
- c.Assert(sInterStore.Err(), IsNil)
- c.Assert(sInterStore.Val(), Equals, int64(1))
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sMembers.Val(), DeepEquals, []string{"c"})
-}
-
-func (t *RedisTest) TestIsMember(c *C) {
- sAdd := t.client.SAdd("set", "one")
- c.Assert(sAdd.Err(), IsNil)
-
- sIsMember := t.client.SIsMember("set", "one")
- c.Assert(sIsMember.Err(), IsNil)
- c.Assert(sIsMember.Val(), Equals, true)
-
- sIsMember = t.client.SIsMember("set", "two")
- c.Assert(sIsMember.Err(), IsNil)
- c.Assert(sIsMember.Val(), Equals, false)
-}
-
-func (t *RedisTest) TestSMembers(c *C) {
- sAdd := t.client.SAdd("set", "Hello")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "World")
- c.Assert(sAdd.Err(), IsNil)
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sortStrings(sMembers.Val()), DeepEquals, []string{"Hello", "World"})
-}
-
-func (t *RedisTest) TestSMove(c *C) {
- sAdd := t.client.SAdd("set1", "one")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "two")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "three")
- c.Assert(sAdd.Err(), IsNil)
-
- sMove := t.client.SMove("set1", "set2", "two")
- c.Assert(sMove.Err(), IsNil)
- c.Assert(sMove.Val(), Equals, true)
-
- sMembers := t.client.SMembers("set1")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sMembers.Val(), DeepEquals, []string{"one"})
-
- sMembers = t.client.SMembers("set2")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sortStrings(sMembers.Val()), DeepEquals, []string{"three", "two"})
-}
-
-func (t *RedisTest) TestSPop(c *C) {
- sAdd := t.client.SAdd("set", "one")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "two")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "three")
- c.Assert(sAdd.Err(), IsNil)
-
- sPop := t.client.SPop("set")
- c.Assert(sPop.Err(), IsNil)
- c.Assert(sPop.Val(), Not(Equals), "")
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sMembers.Val(), HasLen, 2)
-}
-
-func (t *RedisTest) TestSRandMember(c *C) {
- sAdd := t.client.SAdd("set", "one")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "two")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "three")
- c.Assert(sAdd.Err(), IsNil)
-
- sRandMember := t.client.SRandMember("set")
- c.Assert(sRandMember.Err(), IsNil)
- c.Assert(sRandMember.Val(), Not(Equals), "")
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sMembers.Val(), HasLen, 3)
-}
-
-func (t *RedisTest) TestSRem(c *C) {
- sAdd := t.client.SAdd("set", "one")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "two")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set", "three")
- c.Assert(sAdd.Err(), IsNil)
-
- sRem := t.client.SRem("set", "one")
- c.Assert(sRem.Err(), IsNil)
- c.Assert(sRem.Val(), Equals, int64(1))
-
- sRem = t.client.SRem("set", "four")
- c.Assert(sRem.Err(), IsNil)
- c.Assert(sRem.Val(), Equals, int64(0))
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(
- sortStrings(sMembers.Val()),
- DeepEquals,
- []string{"three", "two"},
- )
-}
-
-func (t *RedisTest) TestSUnion(c *C) {
- sAdd := t.client.SAdd("set1", "a")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "b")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "c")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "c")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "d")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "e")
- c.Assert(sAdd.Err(), IsNil)
-
- sUnion := t.client.SUnion("set1", "set2")
- c.Assert(sUnion.Err(), IsNil)
- c.Assert(sUnion.Val(), HasLen, 5)
-}
-
-func (t *RedisTest) TestSUnionStore(c *C) {
- sAdd := t.client.SAdd("set1", "a")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "b")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set1", "c")
- c.Assert(sAdd.Err(), IsNil)
-
- sAdd = t.client.SAdd("set2", "c")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "d")
- c.Assert(sAdd.Err(), IsNil)
- sAdd = t.client.SAdd("set2", "e")
- c.Assert(sAdd.Err(), IsNil)
-
- sUnionStore := t.client.SUnionStore("set", "set1", "set2")
- c.Assert(sUnionStore.Err(), IsNil)
- c.Assert(sUnionStore.Val(), Equals, int64(5))
-
- sMembers := t.client.SMembers("set")
- c.Assert(sMembers.Err(), IsNil)
- c.Assert(sMembers.Val(), HasLen, 5)
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestZAdd(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- c.Assert(zAdd.Val(), Equals, int64(1))
-
- zAdd = t.client.ZAdd("zset", redis.Z{1, "uno"})
- c.Assert(zAdd.Err(), IsNil)
- c.Assert(zAdd.Val(), Equals, int64(1))
-
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- c.Assert(zAdd.Val(), Equals, int64(1))
-
- zAdd = t.client.ZAdd("zset", redis.Z{3, "two"})
- c.Assert(zAdd.Err(), IsNil)
- c.Assert(zAdd.Val(), Equals, int64(0))
-
- val, err := t.client.ZRangeWithScores("zset", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{1, "one"}, {1, "uno"}, {3, "two"}})
-}
-
-func (t *RedisTest) TestZCard(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
-
- zCard := t.client.ZCard("zset")
- c.Assert(zCard.Err(), IsNil)
- c.Assert(zCard.Val(), Equals, int64(2))
-}
-
-func (t *RedisTest) TestZCount(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zCount := t.client.ZCount("zset", "-inf", "+inf")
- c.Assert(zCount.Err(), IsNil)
- c.Assert(zCount.Val(), Equals, int64(3))
-
- zCount = t.client.ZCount("zset", "(1", "3")
- c.Assert(zCount.Err(), IsNil)
- c.Assert(zCount.Val(), Equals, int64(2))
-}
-
-func (t *RedisTest) TestZIncrBy(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
-
- zIncrBy := t.client.ZIncrBy("zset", 2, "one")
- c.Assert(zIncrBy.Err(), IsNil)
- c.Assert(zIncrBy.Val(), Equals, float64(3))
-
- val, err := t.client.ZRangeWithScores("zset", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{2, "two"}, {3, "one"}})
-}
-
-func (t *RedisTest) TestZInterStore(c *C) {
- zAdd := t.client.ZAdd("zset1", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset1", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
-
- zAdd = t.client.ZAdd("zset2", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset2", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset3", redis.Z{3, "two"})
- c.Assert(zAdd.Err(), IsNil)
-
- zInterStore := t.client.ZInterStore(
- "out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2")
- c.Assert(zInterStore.Err(), IsNil)
- c.Assert(zInterStore.Val(), Equals, int64(2))
-
- val, err := t.client.ZRangeWithScores("out", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{5, "one"}, {10, "two"}})
-}
-
-func (t *RedisTest) TestZRange(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRange := t.client.ZRange("zset", 0, -1)
- c.Assert(zRange.Err(), IsNil)
- c.Assert(zRange.Val(), DeepEquals, []string{"one", "two", "three"})
-
- zRange = t.client.ZRange("zset", 2, 3)
- c.Assert(zRange.Err(), IsNil)
- c.Assert(zRange.Val(), DeepEquals, []string{"three"})
-
- zRange = t.client.ZRange("zset", -2, -1)
- c.Assert(zRange.Err(), IsNil)
- c.Assert(zRange.Val(), DeepEquals, []string{"two", "three"})
-}
-
-func (t *RedisTest) TestZRangeWithScores(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- val, err := t.client.ZRangeWithScores("zset", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{1, "one"}, {2, "two"}, {3, "three"}})
-
- val, err = t.client.ZRangeWithScores("zset", 2, 3).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{3, "three"}})
-
- val, err = t.client.ZRangeWithScores("zset", -2, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{2, "two"}, {3, "three"}})
-}
-
-func (t *RedisTest) TestZRangeByScore(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRangeByScore := t.client.ZRangeByScore("zset", redis.ZRangeByScore{
- Min: "-inf",
- Max: "+inf",
- })
- c.Assert(zRangeByScore.Err(), IsNil)
- c.Assert(zRangeByScore.Val(), DeepEquals, []string{"one", "two", "three"})
-
- zRangeByScore = t.client.ZRangeByScore("zset", redis.ZRangeByScore{
- Min: "1",
- Max: "2",
- })
- c.Assert(zRangeByScore.Err(), IsNil)
- c.Assert(zRangeByScore.Val(), DeepEquals, []string{"one", "two"})
-
- zRangeByScore = t.client.ZRangeByScore("zset", redis.ZRangeByScore{
- Min: "(1",
- Max: "2",
- })
- c.Assert(zRangeByScore.Err(), IsNil)
- c.Assert(zRangeByScore.Val(), DeepEquals, []string{"two"})
-
- zRangeByScore = t.client.ZRangeByScore("zset", redis.ZRangeByScore{
- Min: "(1",
- Max: "(2",
- })
- c.Assert(zRangeByScore.Err(), IsNil)
- c.Assert(zRangeByScore.Val(), DeepEquals, []string{})
-}
-
-func (t *RedisTest) TestZRangeByScoreWithScoresMap(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- val, err := t.client.ZRangeByScoreWithScores("zset", redis.ZRangeByScore{
- Min: "-inf",
- Max: "+inf",
- }).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{1, "one"}, {2, "two"}, {3, "three"}})
-
- val, err = t.client.ZRangeByScoreWithScores("zset", redis.ZRangeByScore{
- Min: "1",
- Max: "2",
- }).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{1, "one"}, {2, "two"}})
-
- val, err = t.client.ZRangeByScoreWithScores("zset", redis.ZRangeByScore{
- Min: "(1",
- Max: "2",
- }).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{2, "two"}})
-
- val, err = t.client.ZRangeByScoreWithScores("zset", redis.ZRangeByScore{
- Min: "(1",
- Max: "(2",
- }).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{})
-}
-
-func (t *RedisTest) TestZRank(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRank := t.client.ZRank("zset", "three")
- c.Assert(zRank.Err(), IsNil)
- c.Assert(zRank.Val(), Equals, int64(2))
-
- zRank = t.client.ZRank("zset", "four")
- c.Assert(zRank.Err(), Equals, redis.Nil)
- c.Assert(zRank.Val(), Equals, int64(0))
-}
-
-func (t *RedisTest) TestZRem(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRem := t.client.ZRem("zset", "two")
- c.Assert(zRem.Err(), IsNil)
- c.Assert(zRem.Val(), Equals, int64(1))
-
- val, err := t.client.ZRangeWithScores("zset", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{1, "one"}, {3, "three"}})
-}
-
-func (t *RedisTest) TestZRemRangeByRank(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRemRangeByRank := t.client.ZRemRangeByRank("zset", 0, 1)
- c.Assert(zRemRangeByRank.Err(), IsNil)
- c.Assert(zRemRangeByRank.Val(), Equals, int64(2))
-
- val, err := t.client.ZRangeWithScores("zset", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{3, "three"}})
-}
-
-func (t *RedisTest) TestZRemRangeByScore(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRemRangeByScore := t.client.ZRemRangeByScore("zset", "-inf", "(2")
- c.Assert(zRemRangeByScore.Err(), IsNil)
- c.Assert(zRemRangeByScore.Val(), Equals, int64(1))
-
- val, err := t.client.ZRangeWithScores("zset", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{2, "two"}, {3, "three"}})
-}
-
-func (t *RedisTest) TestZRevRange(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRevRange := t.client.ZRevRange("zset", "0", "-1")
- c.Assert(zRevRange.Err(), IsNil)
- c.Assert(zRevRange.Val(), DeepEquals, []string{"three", "two", "one"})
-
- zRevRange = t.client.ZRevRange("zset", "2", "3")
- c.Assert(zRevRange.Err(), IsNil)
- c.Assert(zRevRange.Val(), DeepEquals, []string{"one"})
-
- zRevRange = t.client.ZRevRange("zset", "-2", "-1")
- c.Assert(zRevRange.Err(), IsNil)
- c.Assert(zRevRange.Val(), DeepEquals, []string{"two", "one"})
-}
-
-func (t *RedisTest) TestZRevRangeWithScoresMap(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- val, err := t.client.ZRevRangeWithScores("zset", "0", "-1").Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{3, "three"}, {2, "two"}, {1, "one"}})
-
- val, err = t.client.ZRevRangeWithScores("zset", "2", "3").Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{1, "one"}})
-
- val, err = t.client.ZRevRangeWithScores("zset", "-2", "-1").Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{2, "two"}, {1, "one"}})
-}
-
-func (t *RedisTest) TestZRevRangeByScore(c *C) {
- zadd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zadd.Err(), IsNil)
- zadd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zadd.Err(), IsNil)
- zadd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zadd.Err(), IsNil)
-
- vals, err := t.client.ZRevRangeByScore(
- "zset", redis.ZRangeByScore{Max: "+inf", Min: "-inf"}).Result()
- c.Assert(err, IsNil)
- c.Assert(vals, DeepEquals, []string{"three", "two", "one"})
-
- vals, err = t.client.ZRevRangeByScore(
- "zset", redis.ZRangeByScore{Max: "2", Min: "(1"}).Result()
- c.Assert(err, IsNil)
- c.Assert(vals, DeepEquals, []string{"two"})
-
- vals, err = t.client.ZRevRangeByScore(
- "zset", redis.ZRangeByScore{Max: "(2", Min: "(1"}).Result()
- c.Assert(err, IsNil)
- c.Assert(vals, DeepEquals, []string{})
-}
-
-func (t *RedisTest) TestZRevRangeByScoreWithScores(c *C) {
- zadd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zadd.Err(), IsNil)
- zadd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zadd.Err(), IsNil)
- zadd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zadd.Err(), IsNil)
-
- vals, err := t.client.ZRevRangeByScoreWithScores(
- "zset", redis.ZRangeByScore{Max: "+inf", Min: "-inf"}).Result()
- c.Assert(err, IsNil)
- c.Assert(vals, DeepEquals, []redis.Z{{3, "three"}, {2, "two"}, {1, "one"}})
-}
-
-func (t *RedisTest) TestZRevRangeByScoreWithScoresMap(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- val, err := t.client.ZRevRangeByScoreWithScores(
- "zset", redis.ZRangeByScore{Max: "+inf", Min: "-inf"}).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{3, "three"}, {2, "two"}, {1, "one"}})
-
- val, err = t.client.ZRevRangeByScoreWithScores(
- "zset", redis.ZRangeByScore{Max: "2", Min: "(1"}).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{2, "two"}})
-
- val, err = t.client.ZRevRangeByScoreWithScores(
- "zset", redis.ZRangeByScore{Max: "(2", Min: "(1"}).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{})
-}
-
-func (t *RedisTest) TestZRevRank(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zRevRank := t.client.ZRevRank("zset", "one")
- c.Assert(zRevRank.Err(), IsNil)
- c.Assert(zRevRank.Val(), Equals, int64(2))
-
- zRevRank = t.client.ZRevRank("zset", "four")
- c.Assert(zRevRank.Err(), Equals, redis.Nil)
- c.Assert(zRevRank.Val(), Equals, int64(0))
-}
-
-func (t *RedisTest) TestZScore(c *C) {
- zAdd := t.client.ZAdd("zset", redis.Z{1.001, "one"})
- c.Assert(zAdd.Err(), IsNil)
-
- zScore := t.client.ZScore("zset", "one")
- c.Assert(zScore.Err(), IsNil)
- c.Assert(zScore.Val(), Equals, float64(1.001))
-}
-
-func (t *RedisTest) TestZUnionStore(c *C) {
- zAdd := t.client.ZAdd("zset1", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset1", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
-
- zAdd = t.client.ZAdd("zset2", redis.Z{1, "one"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset2", redis.Z{2, "two"})
- c.Assert(zAdd.Err(), IsNil)
- zAdd = t.client.ZAdd("zset2", redis.Z{3, "three"})
- c.Assert(zAdd.Err(), IsNil)
-
- zUnionStore := t.client.ZUnionStore(
- "out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2")
- c.Assert(zUnionStore.Err(), IsNil)
- c.Assert(zUnionStore.Val(), Equals, int64(3))
-
- val, err := t.client.ZRangeWithScores("out", 0, -1).Result()
- c.Assert(err, IsNil)
- c.Assert(val, DeepEquals, []redis.Z{{5, "one"}, {9, "three"}, {10, "two"}})
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestPatternPubSub(c *C) {
- pubsub := t.client.PubSub()
- defer func() {
- c.Assert(pubsub.Close(), IsNil)
- }()
-
- c.Assert(pubsub.PSubscribe("mychannel*"), IsNil)
-
- pub := t.client.Publish("mychannel1", "hello")
- c.Assert(pub.Err(), IsNil)
- c.Assert(pub.Val(), Equals, int64(1))
-
- c.Assert(pubsub.PUnsubscribe("mychannel*"), IsNil)
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Subscription)
- c.Assert(subscr.Kind, Equals, "psubscribe")
- c.Assert(subscr.Channel, Equals, "mychannel*")
- c.Assert(subscr.Count, Equals, 1)
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.PMessage)
- c.Assert(subscr.Channel, Equals, "mychannel1")
- c.Assert(subscr.Pattern, Equals, "mychannel*")
- c.Assert(subscr.Payload, Equals, "hello")
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Subscription)
- c.Assert(subscr.Kind, Equals, "punsubscribe")
- c.Assert(subscr.Channel, Equals, "mychannel*")
- c.Assert(subscr.Count, Equals, 0)
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err.(net.Error).Timeout(), Equals, true)
- c.Assert(msgi, IsNil)
- }
-}
-
-func (t *RedisTest) TestPubSub(c *C) {
- pubsub := t.client.PubSub()
- defer func() {
- c.Assert(pubsub.Close(), IsNil)
- }()
-
- c.Assert(pubsub.Subscribe("mychannel", "mychannel2"), IsNil)
-
- pub := t.client.Publish("mychannel", "hello")
- c.Assert(pub.Err(), IsNil)
- c.Assert(pub.Val(), Equals, int64(1))
-
- pub = t.client.Publish("mychannel2", "hello2")
- c.Assert(pub.Err(), IsNil)
- c.Assert(pub.Val(), Equals, int64(1))
-
- c.Assert(pubsub.Unsubscribe("mychannel", "mychannel2"), IsNil)
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Subscription)
- c.Assert(subscr.Kind, Equals, "subscribe")
- c.Assert(subscr.Channel, Equals, "mychannel")
- c.Assert(subscr.Count, Equals, 1)
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Subscription)
- c.Assert(subscr.Kind, Equals, "subscribe")
- c.Assert(subscr.Channel, Equals, "mychannel2")
- c.Assert(subscr.Count, Equals, 2)
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Message)
- c.Assert(subscr.Channel, Equals, "mychannel")
- c.Assert(subscr.Payload, Equals, "hello")
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- msg := msgi.(*redis.Message)
- c.Assert(msg.Channel, Equals, "mychannel2")
- c.Assert(msg.Payload, Equals, "hello2")
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Subscription)
- c.Assert(subscr.Kind, Equals, "unsubscribe")
- c.Assert(subscr.Channel, Equals, "mychannel")
- c.Assert(subscr.Count, Equals, 1)
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err, IsNil)
- subscr := msgi.(*redis.Subscription)
- c.Assert(subscr.Kind, Equals, "unsubscribe")
- c.Assert(subscr.Channel, Equals, "mychannel2")
- c.Assert(subscr.Count, Equals, 0)
- }
-
- {
- msgi, err := pubsub.ReceiveTimeout(time.Second)
- c.Assert(err.(net.Error).Timeout(), Equals, true)
- c.Assert(msgi, IsNil)
- }
-}
-
-func (t *RedisTest) TestPubSubChannels(c *C) {
- channels, err := t.client.PubSubChannels("mychannel*").Result()
- c.Assert(err, IsNil)
- c.Assert(channels, HasLen, 0)
- c.Assert(channels, Not(IsNil))
-
- pubsub := t.client.PubSub()
- defer pubsub.Close()
-
- c.Assert(pubsub.Subscribe("mychannel", "mychannel2"), IsNil)
-
- channels, err = t.client.PubSubChannels("mychannel*").Result()
- c.Assert(err, IsNil)
- c.Assert(sortStrings(channels), DeepEquals, []string{"mychannel", "mychannel2"})
-
- channels, err = t.client.PubSubChannels("").Result()
- c.Assert(err, IsNil)
- c.Assert(channels, HasLen, 0)
-
- channels, err = t.client.PubSubChannels("*").Result()
- c.Assert(err, IsNil)
- c.Assert(len(channels) >= 2, Equals, true)
-}
-
-func (t *RedisTest) TestPubSubNumSub(c *C) {
- pubsub := t.client.PubSub()
- defer pubsub.Close()
-
- c.Assert(pubsub.Subscribe("mychannel", "mychannel2"), IsNil)
-
- channels, err := t.client.PubSubNumSub("mychannel", "mychannel2", "mychannel3").Result()
- c.Assert(err, IsNil)
- c.Assert(
- channels,
- DeepEquals,
- []interface{}{"mychannel", int64(1), "mychannel2", int64(1), "mychannel3", int64(0)},
- )
-}
-
-func (t *RedisTest) TestPubSubNumPat(c *C) {
- num, err := t.client.PubSubNumPat().Result()
- c.Assert(err, IsNil)
- c.Assert(num, Equals, int64(0))
-
- pubsub := t.client.PubSub()
- defer pubsub.Close()
-
- c.Assert(pubsub.PSubscribe("mychannel*"), IsNil)
-
- num, err = t.client.PubSubNumPat().Result()
- c.Assert(err, IsNil)
- c.Assert(num, Equals, int64(1))
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestPipeline(c *C) {
- set := t.client.Set("key2", "hello2")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- pipeline := t.client.Pipeline()
- defer func() {
- c.Assert(pipeline.Close(), IsNil)
- }()
-
- set = pipeline.Set("key1", "hello1")
- get := pipeline.Get("key2")
- incr := pipeline.Incr("key3")
- getNil := pipeline.Get("key4")
-
- cmds, err := pipeline.Exec()
- c.Assert(err, Equals, redis.Nil)
- c.Assert(cmds, HasLen, 4)
-
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello2")
-
- c.Assert(incr.Err(), IsNil)
- c.Assert(incr.Val(), Equals, int64(1))
-
- c.Assert(getNil.Err(), Equals, redis.Nil)
- c.Assert(getNil.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestPipelineDiscardQueued(c *C) {
- pipeline := t.client.Pipeline()
-
- pipeline.Get("key")
- pipeline.Discard()
- cmds, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 0)
-
- c.Assert(pipeline.Close(), IsNil)
-}
-
-func (t *RedisTest) TestPipelined(c *C) {
- var get *redis.StringCmd
- cmds, err := t.client.Pipelined(func(pipe *redis.Pipeline) error {
- get = pipe.Get("foo")
- return nil
- })
- c.Assert(err, Equals, redis.Nil)
- c.Assert(cmds, HasLen, 1)
- c.Assert(cmds[0], Equals, get)
- c.Assert(get.Err(), Equals, redis.Nil)
- c.Assert(get.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestPipelineErrValNotSet(c *C) {
- pipeline := t.client.Pipeline()
- defer func() {
- c.Assert(pipeline.Close(), IsNil)
- }()
-
- get := pipeline.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestPipelineRunQueuedOnEmptyQueue(c *C) {
- pipeline := t.client.Pipeline()
- defer func() {
- c.Assert(pipeline.Close(), IsNil)
- }()
-
- cmds, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 0)
-}
-
-// TODO: make thread safe?
-func (t *RedisTest) TestPipelineIncr(c *C) {
- const N = 20000
- key := "TestPipelineIncr"
-
- pipeline := t.client.Pipeline()
-
- wg := &sync.WaitGroup{}
- wg.Add(N)
- for i := 0; i < N; i++ {
- pipeline.Incr(key)
- wg.Done()
- }
- wg.Wait()
-
- cmds, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(len(cmds), Equals, 20000)
- for _, cmd := range cmds {
- if cmd.Err() != nil {
- c.Errorf("got %v, expected nil", cmd.Err())
- }
- }
-
- get := t.client.Get(key)
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, strconv.Itoa(N))
-
- c.Assert(pipeline.Close(), IsNil)
-}
-
-func (t *RedisTest) TestPipelineEcho(c *C) {
- const N = 1000
-
- wg := &sync.WaitGroup{}
- wg.Add(N)
- for i := 0; i < N; i++ {
- go func(i int) {
- pipeline := t.client.Pipeline()
-
- msg1 := "echo" + strconv.Itoa(i)
- msg2 := "echo" + strconv.Itoa(i+1)
-
- echo1 := pipeline.Echo(msg1)
- echo2 := pipeline.Echo(msg2)
-
- cmds, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 2)
-
- c.Assert(echo1.Err(), IsNil)
- c.Assert(echo1.Val(), Equals, msg1)
-
- c.Assert(echo2.Err(), IsNil)
- c.Assert(echo2.Val(), Equals, msg2)
-
- c.Assert(pipeline.Close(), IsNil)
-
- wg.Done()
- }(i)
- }
- wg.Wait()
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestMultiExec(c *C) {
- multi := t.client.Multi()
- defer func() {
- c.Assert(multi.Close(), IsNil)
- }()
-
- var (
- set *redis.StatusCmd
- get *redis.StringCmd
- )
- cmds, err := multi.Exec(func() error {
- set = multi.Set("key", "hello")
- get = multi.Get("key")
- return nil
- })
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 2)
-
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello")
-}
-
-func (t *RedisTest) TestMultiExecDiscard(c *C) {
- multi := t.client.Multi()
- defer func() {
- c.Assert(multi.Close(), IsNil)
- }()
-
- cmds, err := multi.Exec(func() error {
- multi.Set("key1", "hello1")
- multi.Discard()
- multi.Set("key2", "hello2")
- return nil
- })
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 1)
-
- get := t.client.Get("key1")
- c.Assert(get.Err(), Equals, redis.Nil)
- c.Assert(get.Val(), Equals, "")
-
- get = t.client.Get("key2")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "hello2")
-}
-
-func (t *RedisTest) TestMultiExecEmpty(c *C) {
- multi := t.client.Multi()
- defer func() {
- c.Assert(multi.Close(), IsNil)
- }()
-
- cmds, err := multi.Exec(func() error { return nil })
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 0)
-
- ping := multi.Ping()
- c.Check(ping.Err(), IsNil)
- c.Check(ping.Val(), Equals, "PONG")
-}
-
-func (t *RedisTest) TestMultiExecOnEmptyQueue(c *C) {
- multi := t.client.Multi()
- defer func() {
- c.Assert(multi.Close(), IsNil)
- }()
-
- cmds, err := multi.Exec(func() error { return nil })
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 0)
-}
-
-func (t *RedisTest) TestMultiExecIncr(c *C) {
- multi := t.client.Multi()
- defer func() {
- c.Assert(multi.Close(), IsNil)
- }()
-
- cmds, err := multi.Exec(func() error {
- for i := int64(0); i < 20000; i++ {
- multi.Incr("key")
- }
- return nil
- })
- c.Assert(err, IsNil)
- c.Assert(len(cmds), Equals, 20000)
- for _, cmd := range cmds {
- if cmd.Err() != nil {
- c.Errorf("got %v, expected nil", cmd.Err())
- }
- }
-
- get := t.client.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Equals, "20000")
-}
-
-func (t *RedisTest) transactionalIncr(c *C) ([]redis.Cmder, error) {
- multi := t.client.Multi()
- defer func() {
- c.Assert(multi.Close(), IsNil)
- }()
-
- watch := multi.Watch("key")
- c.Assert(watch.Err(), IsNil)
- c.Assert(watch.Val(), Equals, "OK")
-
- get := multi.Get("key")
- c.Assert(get.Err(), IsNil)
- c.Assert(get.Val(), Not(Equals), redis.Nil)
-
- v, err := strconv.ParseInt(get.Val(), 10, 64)
- c.Assert(err, IsNil)
-
- return multi.Exec(func() error {
- multi.Set("key", strconv.FormatInt(v+1, 10))
- return nil
- })
-}
-
-func (t *RedisTest) TestWatchUnwatch(c *C) {
- var n = 10000
- if testing.Short() {
- n = 1000
- }
-
- set := t.client.Set("key", "0")
- c.Assert(set.Err(), IsNil)
-
- wg := &sync.WaitGroup{}
- for i := 0; i < n; i++ {
- wg.Add(1)
- go func() {
- defer wg.Done()
- for {
- cmds, err := t.transactionalIncr(c)
- if err == redis.TxFailedErr {
- continue
- }
- c.Assert(err, IsNil)
- c.Assert(cmds, HasLen, 1)
- c.Assert(cmds[0].Err(), IsNil)
- break
- }
- }()
- }
- wg.Wait()
-
- val, err := t.client.Get("key").Int64()
- c.Assert(err, IsNil)
- c.Assert(val, Equals, int64(n))
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestRaceEcho(c *C) {
- var n = 10000
- if testing.Short() {
- n = 1000
- }
-
- wg := &sync.WaitGroup{}
- wg.Add(n)
- for i := 0; i < n; i++ {
- go func(i int) {
- msg := "echo" + strconv.Itoa(i)
- echo := t.client.Echo(msg)
- c.Assert(echo.Err(), IsNil)
- c.Assert(echo.Val(), Equals, msg)
- wg.Done()
- }(i)
- }
- wg.Wait()
-}
-
-func (t *RedisTest) TestRaceIncr(c *C) {
- var n = 10000
- if testing.Short() {
- n = 1000
- }
-
- wg := &sync.WaitGroup{}
- wg.Add(n)
- for i := 0; i < n; i++ {
- go func() {
- incr := t.client.Incr("TestRaceIncr")
- if err := incr.Err(); err != nil {
- panic(err)
- }
- wg.Done()
- }()
- }
- wg.Wait()
-
- val, err := t.client.Get("TestRaceIncr").Result()
- c.Assert(err, IsNil)
- c.Assert(val, Equals, strconv.Itoa(n))
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestCmdBgRewriteAOF(c *C) {
- r := t.client.BgRewriteAOF()
- c.Assert(r.Err(), IsNil)
- c.Assert(r.Val(), Equals, "Background append only file rewriting started")
-}
-
-func (t *RedisTest) TestCmdBgSave(c *C) {
- // workaround for "ERR Can't BGSAVE while AOF log rewriting is in progress"
- time.Sleep(time.Second)
-
- r := t.client.BgSave()
- c.Assert(r.Err(), IsNil)
- c.Assert(r.Val(), Equals, "Background saving started")
-}
-
-func (t *RedisTest) TestCmdClientKill(c *C) {
- r := t.client.ClientKill("1.1.1.1:1111")
- c.Assert(r.Err(), ErrorMatches, "ERR No such client")
- c.Assert(r.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestCmdConfigGet(c *C) {
- r := t.client.ConfigGet("*")
- c.Assert(r.Err(), IsNil)
- c.Assert(len(r.Val()) > 0, Equals, true)
-}
-
-func (t *RedisTest) TestCmdConfigResetStat(c *C) {
- r := t.client.ConfigResetStat()
- c.Assert(r.Err(), IsNil)
- c.Assert(r.Val(), Equals, "OK")
-}
-
-func (t *RedisTest) TestCmdConfigSet(c *C) {
- configGet := t.client.ConfigGet("maxmemory")
- c.Assert(configGet.Err(), IsNil)
- c.Assert(configGet.Val(), HasLen, 2)
- c.Assert(configGet.Val()[0], Equals, "maxmemory")
-
- configSet := t.client.ConfigSet("maxmemory", configGet.Val()[1].(string))
- c.Assert(configSet.Err(), IsNil)
- c.Assert(configSet.Val(), Equals, "OK")
-}
-
-func (t *RedisTest) TestCmdDbSize(c *C) {
- dbSize := t.client.DbSize()
- c.Assert(dbSize.Err(), IsNil)
- c.Assert(dbSize.Val(), Equals, int64(0))
-}
-
-func (t *RedisTest) TestCmdFlushAll(c *C) {
- // TODO
-}
-
-func (t *RedisTest) TestCmdFlushDb(c *C) {
- // TODO
-}
-
-func (t *RedisTest) TestCmdInfo(c *C) {
- info := t.client.Info()
- c.Assert(info.Err(), IsNil)
- c.Assert(info.Val(), Not(Equals), "")
-}
-
-func (t *RedisTest) TestCmdLastSave(c *C) {
- lastSave := t.client.LastSave()
- c.Assert(lastSave.Err(), IsNil)
- c.Assert(lastSave.Val(), Not(Equals), 0)
-}
-
-func (t *RedisTest) TestCmdSave(c *C) {
- save := t.client.Save()
- c.Assert(save.Err(), IsNil)
- c.Assert(save.Val(), Equals, "OK")
-}
-
-func (t *RedisTest) TestSlaveOf(c *C) {
- slaveOf := t.client.SlaveOf("localhost", "8888")
- c.Assert(slaveOf.Err(), IsNil)
- c.Assert(slaveOf.Val(), Equals, "OK")
-
- slaveOf = t.client.SlaveOf("NO", "ONE")
- c.Assert(slaveOf.Err(), IsNil)
- c.Assert(slaveOf.Val(), Equals, "OK")
-}
-
-func (t *RedisTest) TestTime(c *C) {
- time := t.client.Time()
- c.Assert(time.Err(), IsNil)
- c.Assert(time.Val(), HasLen, 2)
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestScriptingEval(c *C) {
- eval := t.client.Eval(
- "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}",
- []string{"key1", "key2"},
- []string{"first", "second"},
- )
- c.Assert(eval.Err(), IsNil)
- c.Assert(eval.Val(), DeepEquals, []interface{}{"key1", "key2", "first", "second"})
-
- eval = t.client.Eval(
- "return redis.call('set',KEYS[1],'bar')",
- []string{"foo"},
- []string{},
- )
- c.Assert(eval.Err(), IsNil)
- c.Assert(eval.Val(), Equals, "OK")
-
- eval = t.client.Eval("return 10", []string{}, []string{})
- c.Assert(eval.Err(), IsNil)
- c.Assert(eval.Val(), Equals, int64(10))
-
- eval = t.client.Eval("return {1,2,{3,'Hello World!'}}", []string{}, []string{})
- c.Assert(eval.Err(), IsNil)
- // DeepEquals can't compare nested slices.
- c.Assert(
- fmt.Sprintf("%#v", eval.Val()),
- Equals,
- `[]interface {}{1, 2, []interface {}{3, "Hello World!"}}`,
- )
-}
-
-func (t *RedisTest) TestScriptingEvalSha(c *C) {
- set := t.client.Set("foo", "bar")
- c.Assert(set.Err(), IsNil)
- c.Assert(set.Val(), Equals, "OK")
-
- eval := t.client.Eval("return redis.call('get','foo')", nil, nil)
- c.Assert(eval.Err(), IsNil)
- c.Assert(eval.Val(), Equals, "bar")
-
- evalSha := t.client.EvalSha("6b1bf486c81ceb7edf3c093f4c48582e38c0e791", nil, nil)
- c.Assert(evalSha.Err(), IsNil)
- c.Assert(evalSha.Val(), Equals, "bar")
-
- evalSha = t.client.EvalSha("ffffffffffffffffffffffffffffffffffffffff", nil, nil)
- c.Assert(evalSha.Err(), ErrorMatches, "NOSCRIPT No matching script. Please use EVAL.")
- c.Assert(evalSha.Val(), Equals, nil)
-}
-
-func (t *RedisTest) TestScriptingScriptExists(c *C) {
- scriptLoad := t.client.ScriptLoad("return 1")
- c.Assert(scriptLoad.Err(), IsNil)
- c.Assert(scriptLoad.Val(), Equals, "e0e1f9fabfc9d4800c877a703b823ac0578ff8db")
-
- scriptExists := t.client.ScriptExists(
- "e0e1f9fabfc9d4800c877a703b823ac0578ff8db",
- "ffffffffffffffffffffffffffffffffffffffff",
- )
- c.Assert(scriptExists.Err(), IsNil)
- c.Assert(scriptExists.Val(), DeepEquals, []bool{true, false})
-}
-
-func (t *RedisTest) TestScriptingScriptFlush(c *C) {
- scriptFlush := t.client.ScriptFlush()
- c.Assert(scriptFlush.Err(), IsNil)
- c.Assert(scriptFlush.Val(), Equals, "OK")
-}
-
-func (t *RedisTest) TestScriptingScriptKill(c *C) {
- scriptKill := t.client.ScriptKill()
- c.Assert(scriptKill.Err(), ErrorMatches, ".*No scripts in execution right now.")
- c.Assert(scriptKill.Val(), Equals, "")
-}
-
-func (t *RedisTest) TestScriptingScriptLoad(c *C) {
- scriptLoad := t.client.ScriptLoad("return redis.call('get','foo')")
- c.Assert(scriptLoad.Err(), IsNil)
- c.Assert(scriptLoad.Val(), Equals, "6b1bf486c81ceb7edf3c093f4c48582e38c0e791")
-}
-
-func (t *RedisTest) TestScriptingNewScript(c *C) {
- s := redis.NewScript("return 1")
- run := s.Run(t.client, nil, nil)
- c.Assert(run.Err(), IsNil)
- c.Assert(run.Val(), Equals, int64(1))
-}
-
-func (t *RedisTest) TestScriptingEvalAndPipeline(c *C) {
- pipeline := t.client.Pipeline()
- s := redis.NewScript("return 1")
- run := s.Eval(pipeline, nil, nil)
- _, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(run.Err(), IsNil)
- c.Assert(run.Val(), Equals, int64(1))
-}
-
-func (t *RedisTest) TestScriptingEvalShaAndPipeline(c *C) {
- s := redis.NewScript("return 1")
- c.Assert(s.Load(t.client).Err(), IsNil)
-
- pipeline := t.client.Pipeline()
- run := s.Eval(pipeline, nil, nil)
- _, err := pipeline.Exec()
- c.Assert(err, IsNil)
- c.Assert(run.Err(), IsNil)
- c.Assert(run.Val(), Equals, int64(1))
-}
-
-//------------------------------------------------------------------------------
-
-func (t *RedisTest) TestCmdDebugObject(c *C) {
- {
- debug := t.client.DebugObject("foo")
- c.Assert(debug.Err(), Not(IsNil))
- c.Assert(debug.Err().Error(), Equals, "ERR no such key")
- }
-
- {
- t.client.Set("foo", "bar")
- debug := t.client.DebugObject("foo")
- c.Assert(debug.Err(), IsNil)
- c.Assert(debug.Val(), FitsTypeOf, "")
- c.Assert(debug.Val(), Not(Equals), "")
- }
-}
-
-//------------------------------------------------------------------------------
-
-func BenchmarkRedisPing(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- if err := client.Ping().Err(); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkRedisSet(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- if err := client.Set("key", "hello").Err(); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkRedisGetNil(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- if err := client.FlushDb().Err(); err != nil {
- b.Fatal(err)
- }
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- if err := client.Get("key").Err(); err != redis.Nil {
- b.Fatal(err)
- }
- }
-}
-
-func BenchmarkRedisGet(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- if err := client.Set("key", "hello").Err(); err != nil {
- b.Fatal(err)
- }
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- if err := client.Get("key").Err(); err != nil {
- b.Fatal(err)
- }
- }
-}
-
-func BenchmarkRedisMGet(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- if err := client.MSet("key1", "hello1", "key2", "hello2").Err(); err != nil {
- b.Fatal(err)
- }
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- if err := client.MGet("key1", "key2").Err(); err != nil {
- b.Fatal(err)
- }
- }
-}
-
-func BenchmarkSetExpire(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- if err := client.Set("key", "hello").Err(); err != nil {
- b.Fatal(err)
- }
- if err := client.Expire("key", time.Second).Err(); err != nil {
- b.Fatal(err)
- }
- }
-}
-
-func BenchmarkPipeline(b *testing.B) {
- b.StopTimer()
- client := redis.NewTCPClient(&redis.Options{
- Addr: redisAddr,
- })
- b.StartTimer()
-
- for i := 0; i < b.N; i++ {
- _, err := client.Pipelined(func(pipe *redis.Pipeline) error {
- pipe.Set("key", "hello")
- pipe.Expire("key", time.Second)
- return nil
- })
- if err != nil {
- b.Fatal(err)
- }
- }
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/script.go b/Godeps/_workspace/src/gopkg.in/redis.v2/script.go
deleted file mode 100644
index 96c35f514..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/script.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package redis
-
-import (
- "crypto/sha1"
- "encoding/hex"
- "io"
- "strings"
-)
-
-type scripter interface {
- Eval(script string, keys []string, args []string) *Cmd
- EvalSha(sha1 string, keys []string, args []string) *Cmd
- ScriptExists(scripts ...string) *BoolSliceCmd
- ScriptLoad(script string) *StringCmd
-}
-
-type Script struct {
- src, hash string
-}
-
-func NewScript(src string) *Script {
- h := sha1.New()
- io.WriteString(h, src)
- return &Script{
- src: src,
- hash: hex.EncodeToString(h.Sum(nil)),
- }
-}
-
-func (s *Script) Load(c scripter) *StringCmd {
- return c.ScriptLoad(s.src)
-}
-
-func (s *Script) Exists(c scripter) *BoolSliceCmd {
- return c.ScriptExists(s.src)
-}
-
-func (s *Script) Eval(c scripter, keys []string, args []string) *Cmd {
- return c.Eval(s.src, keys, args)
-}
-
-func (s *Script) EvalSha(c scripter, keys []string, args []string) *Cmd {
- return c.EvalSha(s.hash, keys, args)
-}
-
-func (s *Script) Run(c *Client, keys []string, args []string) *Cmd {
- r := s.EvalSha(c, keys, args)
- if err := r.Err(); err != nil && strings.HasPrefix(err.Error(), "NOSCRIPT ") {
- return s.Eval(c, keys, args)
- }
- return r
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/sentinel.go b/Godeps/_workspace/src/gopkg.in/redis.v2/sentinel.go
deleted file mode 100644
index d3ffeca9a..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/sentinel.go
+++ /dev/null
@@ -1,291 +0,0 @@
-package redis
-
-import (
- "errors"
- "log"
- "net"
- "strings"
- "sync"
- "time"
-)
-
-//------------------------------------------------------------------------------
-
-type FailoverOptions struct {
- MasterName string
- SentinelAddrs []string
-
- Password string
- DB int64
-
- PoolSize int
-
- DialTimeout time.Duration
- ReadTimeout time.Duration
- WriteTimeout time.Duration
- IdleTimeout time.Duration
-}
-
-func (opt *FailoverOptions) getPoolSize() int {
- if opt.PoolSize == 0 {
- return 10
- }
- return opt.PoolSize
-}
-
-func (opt *FailoverOptions) getDialTimeout() time.Duration {
- if opt.DialTimeout == 0 {
- return 5 * time.Second
- }
- return opt.DialTimeout
-}
-
-func (opt *FailoverOptions) options() *options {
- return &options{
- DB: opt.DB,
- Password: opt.Password,
-
- DialTimeout: opt.getDialTimeout(),
- ReadTimeout: opt.ReadTimeout,
- WriteTimeout: opt.WriteTimeout,
-
- PoolSize: opt.getPoolSize(),
- IdleTimeout: opt.IdleTimeout,
- }
-}
-
-func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
- opt := failoverOpt.options()
- failover := &sentinelFailover{
- masterName: failoverOpt.MasterName,
- sentinelAddrs: failoverOpt.SentinelAddrs,
-
- opt: opt,
- }
- return &Client{
- baseClient: &baseClient{
- opt: opt,
- connPool: failover.Pool(),
- },
- }
-}
-
-//------------------------------------------------------------------------------
-
-type sentinelClient struct {
- *baseClient
-}
-
-func newSentinel(clOpt *Options) *sentinelClient {
- opt := clOpt.options()
- opt.Password = ""
- opt.DB = 0
- dialer := func() (net.Conn, error) {
- return net.DialTimeout("tcp", clOpt.Addr, opt.DialTimeout)
- }
- return &sentinelClient{
- baseClient: &baseClient{
- opt: opt,
- connPool: newConnPool(newConnFunc(dialer), opt),
- },
- }
-}
-
-func (c *sentinelClient) PubSub() *PubSub {
- return &PubSub{
- baseClient: &baseClient{
- opt: c.opt,
- connPool: newSingleConnPool(c.connPool, false),
- },
- }
-}
-
-func (c *sentinelClient) GetMasterAddrByName(name string) *StringSliceCmd {
- cmd := NewStringSliceCmd("SENTINEL", "get-master-addr-by-name", name)
- c.Process(cmd)
- return cmd
-}
-
-func (c *sentinelClient) Sentinels(name string) *SliceCmd {
- cmd := NewSliceCmd("SENTINEL", "sentinels", name)
- c.Process(cmd)
- return cmd
-}
-
-type sentinelFailover struct {
- masterName string
- sentinelAddrs []string
-
- opt *options
-
- pool pool
- poolOnce sync.Once
-
- lock sync.RWMutex
- _sentinel *sentinelClient
-}
-
-func (d *sentinelFailover) dial() (net.Conn, error) {
- addr, err := d.MasterAddr()
- if err != nil {
- return nil, err
- }
- return net.DialTimeout("tcp", addr, d.opt.DialTimeout)
-}
-
-func (d *sentinelFailover) Pool() pool {
- d.poolOnce.Do(func() {
- d.pool = newConnPool(newConnFunc(d.dial), d.opt)
- })
- return d.pool
-}
-
-func (d *sentinelFailover) MasterAddr() (string, error) {
- defer d.lock.Unlock()
- d.lock.Lock()
-
- // Try last working sentinel.
- if d._sentinel != nil {
- addr, err := d._sentinel.GetMasterAddrByName(d.masterName).Result()
- if err != nil {
- log.Printf("redis-sentinel: GetMasterAddrByName %q failed: %s", d.masterName, err)
- d.resetSentinel()
- } else {
- addr := net.JoinHostPort(addr[0], addr[1])
- log.Printf("redis-sentinel: %q addr is %s", d.masterName, addr)
- return addr, nil
- }
- }
-
- for i, sentinelAddr := range d.sentinelAddrs {
- sentinel := newSentinel(&Options{
- Addr: sentinelAddr,
-
- DB: d.opt.DB,
- Password: d.opt.Password,
-
- DialTimeout: d.opt.DialTimeout,
- ReadTimeout: d.opt.ReadTimeout,
- WriteTimeout: d.opt.WriteTimeout,
-
- PoolSize: d.opt.PoolSize,
- IdleTimeout: d.opt.IdleTimeout,
- })
- masterAddr, err := sentinel.GetMasterAddrByName(d.masterName).Result()
- if err != nil {
- log.Printf("redis-sentinel: GetMasterAddrByName %q failed: %s", d.masterName, err)
- sentinel.Close()
- continue
- }
-
- // Push working sentinel to the top.
- d.sentinelAddrs[0], d.sentinelAddrs[i] = d.sentinelAddrs[i], d.sentinelAddrs[0]
-
- d.setSentinel(sentinel)
- addr := net.JoinHostPort(masterAddr[0], masterAddr[1])
- log.Printf("redis-sentinel: %q addr is %s", d.masterName, addr)
- return addr, nil
- }
-
- return "", errors.New("redis: all sentinels are unreachable")
-}
-
-func (d *sentinelFailover) setSentinel(sentinel *sentinelClient) {
- d.discoverSentinels(sentinel)
- d._sentinel = sentinel
- go d.listen()
-}
-
-func (d *sentinelFailover) discoverSentinels(sentinel *sentinelClient) {
- sentinels, err := sentinel.Sentinels(d.masterName).Result()
- if err != nil {
- log.Printf("redis-sentinel: Sentinels %q failed: %s", d.masterName, err)
- return
- }
- for _, sentinel := range sentinels {
- vals := sentinel.([]interface{})
- for i := 0; i < len(vals); i += 2 {
- key := vals[i].(string)
- if key == "name" {
- sentinelAddr := vals[i+1].(string)
- if !contains(d.sentinelAddrs, sentinelAddr) {
- log.Printf(
- "redis-sentinel: discovered new %q sentinel: %s",
- d.masterName, sentinelAddr,
- )
- d.sentinelAddrs = append(d.sentinelAddrs, sentinelAddr)
- }
- }
- }
- }
-}
-
-func (d *sentinelFailover) listen() {
- var pubsub *PubSub
- for {
- if pubsub == nil {
- pubsub = d._sentinel.PubSub()
- if err := pubsub.Subscribe("+switch-master"); err != nil {
- log.Printf("redis-sentinel: Subscribe failed: %s", err)
- d.lock.Lock()
- d.resetSentinel()
- d.lock.Unlock()
- return
- }
- }
-
- msgIface, err := pubsub.Receive()
- if err != nil {
- log.Printf("redis-sentinel: Receive failed: %s", err)
- pubsub.Close()
- return
- }
-
- switch msg := msgIface.(type) {
- case *Message:
- switch msg.Channel {
- case "+switch-master":
- parts := strings.Split(msg.Payload, " ")
- if parts[0] != d.masterName {
- log.Printf("redis-sentinel: ignore new %s addr", parts[0])
- continue
- }
- addr := net.JoinHostPort(parts[3], parts[4])
- log.Printf(
- "redis-sentinel: new %q addr is %s",
- d.masterName, addr,
- )
- d.pool.Filter(func(cn *conn) bool {
- if cn.RemoteAddr().String() != addr {
- log.Printf(
- "redis-sentinel: closing connection to old master %s",
- cn.RemoteAddr(),
- )
- return false
- }
- return true
- })
- default:
- log.Printf("redis-sentinel: unsupported message: %s", msg)
- }
- case *Subscription:
- // Ignore.
- default:
- log.Printf("redis-sentinel: unsupported message: %s", msgIface)
- }
- }
-}
-
-func (d *sentinelFailover) resetSentinel() {
- d._sentinel.Close()
- d._sentinel = nil
-}
-
-func contains(slice []string, str string) bool {
- for _, s := range slice {
- if s == str {
- return true
- }
- }
- return false
-}
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/sentinel_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/sentinel_test.go
deleted file mode 100644
index ede59bd51..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/sentinel_test.go
+++ /dev/null
@@ -1,185 +0,0 @@
-package redis_test
-
-import (
- "io/ioutil"
- "os"
- "os/exec"
- "path/filepath"
- "testing"
- "text/template"
- "time"
-
- "gopkg.in/redis.v2"
-)
-
-func startRedis(port string) (*exec.Cmd, error) {
- cmd := exec.Command("redis-server", "--port", port)
- if false {
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- }
- if err := cmd.Start(); err != nil {
- return nil, err
- }
- return cmd, nil
-}
-
-func startRedisSlave(port, slave string) (*exec.Cmd, error) {
- cmd := exec.Command("redis-server", "--port", port, "--slaveof", "127.0.0.1", slave)
- if false {
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- }
- if err := cmd.Start(); err != nil {
- return nil, err
- }
- return cmd, nil
-}
-
-func startRedisSentinel(port, masterName, masterPort string) (*exec.Cmd, error) {
- dir, err := ioutil.TempDir("", "sentinel")
- if err != nil {
- return nil, err
- }
-
- sentinelConfFilepath := filepath.Join(dir, "sentinel.conf")
- tpl, err := template.New("sentinel.conf").Parse(sentinelConf)
- if err != nil {
- return nil, err
- }
-
- data := struct {
- Port string
- MasterName string
- MasterPort string
- }{
- Port: port,
- MasterName: masterName,
- MasterPort: masterPort,
- }
- if err := writeTemplateToFile(sentinelConfFilepath, tpl, data); err != nil {
- return nil, err
- }
-
- cmd := exec.Command("redis-server", sentinelConfFilepath, "--sentinel")
- if true {
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- }
- if err := cmd.Start(); err != nil {
- return nil, err
- }
-
- return cmd, nil
-}
-
-func writeTemplateToFile(path string, t *template.Template, data interface{}) error {
- f, err := os.Create(path)
- if err != nil {
- return err
- }
- defer f.Close()
- return t.Execute(f, data)
-}
-
-func TestSentinel(t *testing.T) {
- masterName := "mymaster"
- masterPort := "8123"
- slavePort := "8124"
- sentinelPort := "8125"
-
- masterCmd, err := startRedis(masterPort)
- if err != nil {
- t.Fatal(err)
- }
- defer masterCmd.Process.Kill()
-
- // Wait for master to start.
- time.Sleep(200 * time.Millisecond)
-
- master := redis.NewTCPClient(&redis.Options{
- Addr: ":" + masterPort,
- })
- if err := master.Ping().Err(); err != nil {
- t.Fatal(err)
- }
-
- slaveCmd, err := startRedisSlave(slavePort, masterPort)
- if err != nil {
- t.Fatal(err)
- }
- defer slaveCmd.Process.Kill()
-
- // Wait for slave to start.
- time.Sleep(200 * time.Millisecond)
-
- slave := redis.NewTCPClient(&redis.Options{
- Addr: ":" + slavePort,
- })
- if err := slave.Ping().Err(); err != nil {
- t.Fatal(err)
- }
-
- sentinelCmd, err := startRedisSentinel(sentinelPort, masterName, masterPort)
- if err != nil {
- t.Fatal(err)
- }
- defer sentinelCmd.Process.Kill()
-
- // Wait for sentinel to start.
- time.Sleep(200 * time.Millisecond)
-
- sentinel := redis.NewTCPClient(&redis.Options{
- Addr: ":" + sentinelPort,
- })
- if err := sentinel.Ping().Err(); err != nil {
- t.Fatal(err)
- }
- defer sentinel.Shutdown()
-
- client := redis.NewFailoverClient(&redis.FailoverOptions{
- MasterName: masterName,
- SentinelAddrs: []string{":" + sentinelPort},
- })
-
- if err := client.Set("foo", "master").Err(); err != nil {
- t.Fatal(err)
- }
-
- val, err := master.Get("foo").Result()
- if err != nil {
- t.Fatal(err)
- }
- if val != "master" {
- t.Fatalf(`got %q, expected "master"`, val)
- }
-
- // Kill Redis master.
- if err := masterCmd.Process.Kill(); err != nil {
- t.Fatal(err)
- }
- if err := master.Ping().Err(); err == nil {
- t.Fatalf("master was not killed")
- }
-
- // Wait for Redis sentinel to elect new master.
- time.Sleep(5 * time.Second)
-
- // Check that client picked up new master.
- val, err = client.Get("foo").Result()
- if err != nil {
- t.Fatal(err)
- }
- if val != "master" {
- t.Fatalf(`got %q, expected "master"`, val)
- }
-}
-
-var sentinelConf = `
-port {{ .Port }}
-
-sentinel monitor {{ .MasterName }} 127.0.0.1 {{ .MasterPort }} 1
-sentinel down-after-milliseconds {{ .MasterName }} 1000
-sentinel failover-timeout {{ .MasterName }} 2000
-sentinel parallel-syncs {{ .MasterName }} 1
-`
diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/testdata/sentinel.conf b/Godeps/_workspace/src/gopkg.in/redis.v2/testdata/sentinel.conf
deleted file mode 100644
index 3da90b380..000000000
--- a/Godeps/_workspace/src/gopkg.in/redis.v2/testdata/sentinel.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-port 26379
-
-sentinel monitor master 127.0.0.1 6379 1
-sentinel down-after-milliseconds master 2000
-sentinel failover-timeout master 5000
-sentinel parallel-syncs master 4