diff options
Diffstat (limited to 'src/dma/vendor/github.com/streadway')
13 files changed, 141 insertions, 52 deletions
diff --git a/src/dma/vendor/github.com/streadway/amqp/.gitignore b/src/dma/vendor/github.com/streadway/amqp/.gitignore index ba8a7056..667fb50c 100644 --- a/src/dma/vendor/github.com/streadway/amqp/.gitignore +++ b/src/dma/vendor/github.com/streadway/amqp/.gitignore @@ -2,3 +2,11 @@ certs/* spec/spec examples/simple-consumer/simple-consumer examples/simple-producer/simple-producer + +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +.idea/**/contentModel.xml diff --git a/src/dma/vendor/github.com/streadway/amqp/.travis.yml b/src/dma/vendor/github.com/streadway/amqp/.travis.yml index 7166964c..2d22a7af 100644 --- a/src/dma/vendor/github.com/streadway/amqp/.travis.yml +++ b/src/dma/vendor/github.com/streadway/amqp/.travis.yml @@ -1,17 +1,18 @@ language: go go: - - 1.9.x - 1.10.x + - 1.11.x + - 1.12.x services: - rabbitmq env: - - AMQP_URL=amqp://guest:guest@127.0.0.1:5672/ + - GO111MODULE=on AMQP_URL=amqp://guest:guest@127.0.0.1:5672/ before_install: - - go get -v github.com/golang/lint/golint + - go get -v golang.org/x/lint/golint script: - ./pre-commit diff --git a/src/dma/vendor/github.com/streadway/amqp/LICENSE b/src/dma/vendor/github.com/streadway/amqp/LICENSE index 243c0ce7..07b89680 100644 --- a/src/dma/vendor/github.com/streadway/amqp/LICENSE +++ b/src/dma/vendor/github.com/streadway/amqp/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012, Sean Treadway, SoundCloud Ltd. +Copyright (c) 2012-2019, Sean Treadway, SoundCloud Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/dma/vendor/github.com/streadway/amqp/README.md b/src/dma/vendor/github.com/streadway/amqp/README.md index 099db276..287830b2 100644 --- a/src/dma/vendor/github.com/streadway/amqp/README.md +++ b/src/dma/vendor/github.com/streadway/amqp/README.md @@ -15,7 +15,7 @@ enhancements. ## Supported Go Versions -This library supports two most recent Go release series, currently 1.8 and 1.9. +This library supports two most recent Go release series, currently 1.10 and 1.11. ## Supported RabbitMQ Versions diff --git a/src/dma/vendor/github.com/streadway/amqp/auth.go b/src/dma/vendor/github.com/streadway/amqp/auth.go index ebc765b6..435c94b1 100644 --- a/src/dma/vendor/github.com/streadway/amqp/auth.go +++ b/src/dma/vendor/github.com/streadway/amqp/auth.go @@ -32,6 +32,22 @@ func (auth *PlainAuth) Response() string { return fmt.Sprintf("\000%s\000%s", auth.Username, auth.Password) } +// AMQPlainAuth is similar to PlainAuth +type AMQPlainAuth struct { + Username string + Password string +} + +// Mechanism returns "AMQPLAIN" +func (auth *AMQPlainAuth) Mechanism() string { + return "AMQPLAIN" +} + +// Response returns the null character delimited encoding for the SASL PLAIN Mechanism. +func (auth *AMQPlainAuth) Response() string { + return fmt.Sprintf("LOGIN:%sPASSWORD:%s", auth.Username, auth.Password) +} + // Finds the first mechanism preferred by the client that the server supports. func pickSASLMechanism(client []Authentication, serverMechanisms []string) (auth Authentication, ok bool) { for _, auth = range client { diff --git a/src/dma/vendor/github.com/streadway/amqp/channel.go b/src/dma/vendor/github.com/streadway/amqp/channel.go index dd2552ca..3898ed78 100644 --- a/src/dma/vendor/github.com/streadway/amqp/channel.go +++ b/src/dma/vendor/github.com/streadway/amqp/channel.go @@ -889,7 +889,7 @@ and exchanges will also be restored on server restart. If the binding could not complete, an error will be returned and the channel will be closed. -When noWait is true and the queue could not be bound, the channel will be +When noWait is false and the queue could not be bound, the channel will be closed with an error. */ @@ -1580,6 +1580,9 @@ multiple messages, reducing the amount of protocol messages to exchange. See also Delivery.Reject */ func (ch *Channel) Reject(tag uint64, requeue bool) error { + ch.m.Lock() + defer ch.m.Unlock() + return ch.send(&basicReject{ DeliveryTag: tag, Requeue: requeue, diff --git a/src/dma/vendor/github.com/streadway/amqp/connection.go b/src/dma/vendor/github.com/streadway/amqp/connection.go index ca1372d0..b9d8e8ee 100644 --- a/src/dma/vendor/github.com/streadway/amqp/connection.go +++ b/src/dma/vendor/github.com/streadway/amqp/connection.go @@ -111,21 +111,23 @@ type readDeadliner interface { SetReadDeadline(time.Time) error } -// defaultDial establishes a connection when config.Dial is not provided -func defaultDial(network, addr string) (net.Conn, error) { - conn, err := net.DialTimeout(network, addr, defaultConnectionTimeout) - if err != nil { - return nil, err - } +// DefaultDial establishes a connection when config.Dial is not provided +func DefaultDial(connectionTimeout time.Duration) func(network, addr string) (net.Conn, error) { + return func(network, addr string) (net.Conn, error) { + conn, err := net.DialTimeout(network, addr, connectionTimeout) + if err != nil { + return nil, err + } - // Heartbeating hasn't started yet, don't stall forever on a dead server. - // A deadline is set for TLS and AMQP handshaking. After AMQP is established, - // the deadline is cleared in openComplete. - if err := conn.SetDeadline(time.Now().Add(defaultConnectionTimeout)); err != nil { - return nil, err - } + // Heartbeating hasn't started yet, don't stall forever on a dead server. + // A deadline is set for TLS and AMQP handshaking. After AMQP is established, + // the deadline is cleared in openComplete. + if err := conn.SetDeadline(time.Now().Add(connectionTimeout)); err != nil { + return nil, err + } - return conn, nil + return conn, nil + } } // Dial accepts a string in the AMQP URI format and returns a new Connection @@ -180,7 +182,7 @@ func DialConfig(url string, config Config) (*Connection, error) { dialer := config.Dial if dialer == nil { - dialer = defaultDial + dialer = DefaultDial(defaultConnectionTimeout) } conn, err = dialer("tcp", addr) @@ -201,6 +203,7 @@ func DialConfig(url string, config Config) (*Connection, error) { client := tls.Client(conn, config.TLSClientConfig) if err := client.Handshake(); err != nil { + conn.Close() return nil, err } @@ -317,7 +320,7 @@ including the underlying io, Channels, Notify listeners and Channel consumers will also be closed. */ func (c *Connection) Close() error { - if c.isClosed() { + if c.IsClosed() { return ErrClosed } @@ -332,7 +335,7 @@ func (c *Connection) Close() error { } func (c *Connection) closeWith(err *Error) error { - if c.isClosed() { + if c.IsClosed() { return ErrClosed } @@ -346,12 +349,14 @@ func (c *Connection) closeWith(err *Error) error { ) } -func (c *Connection) isClosed() bool { +// IsClosed returns true if the connection is marked as closed, otherwise false +// is returned. +func (c *Connection) IsClosed() bool { return (atomic.LoadInt32(&c.closed) == 1) } func (c *Connection) send(f frame) error { - if c.isClosed() { + if c.IsClosed() { return ErrClosed } @@ -591,7 +596,7 @@ func (c *Connection) allocateChannel() (*Channel, error) { c.m.Lock() defer c.m.Unlock() - if c.isClosed() { + if c.IsClosed() { return nil, ErrClosed } diff --git a/src/dma/vendor/github.com/streadway/amqp/delivery.go b/src/dma/vendor/github.com/streadway/amqp/delivery.go index 304c8346..72412644 100644 --- a/src/dma/vendor/github.com/streadway/amqp/delivery.go +++ b/src/dma/vendor/github.com/streadway/amqp/delivery.go @@ -52,7 +52,7 @@ type Delivery struct { DeliveryTag uint64 Redelivered bool - Exchange string // basic.publish exhange + Exchange string // basic.publish exchange RoutingKey string // basic.publish routing key Body []byte diff --git a/src/dma/vendor/github.com/streadway/amqp/go.mod b/src/dma/vendor/github.com/streadway/amqp/go.mod new file mode 100644 index 00000000..4eeab334 --- /dev/null +++ b/src/dma/vendor/github.com/streadway/amqp/go.mod @@ -0,0 +1,3 @@ +module github.com/streadway/amqp + +go 1.10 diff --git a/src/dma/vendor/github.com/streadway/amqp/pre-commit b/src/dma/vendor/github.com/streadway/amqp/pre-commit index 7607f467..37155300 100755 --- a/src/dma/vendor/github.com/streadway/amqp/pre-commit +++ b/src/dma/vendor/github.com/streadway/amqp/pre-commit @@ -1,29 +1,67 @@ #!/bin/sh -GOFMT_FILES=$(gofmt -l .) -if [ -n "${GOFMT_FILES}" ]; then - printf >&2 'gofmt failed for the following files:\n%s\n\nplease run "gofmt -w ." on your changes before committing.\n' "${GOFMT_FILES}" - exit 1 -fi - -GOLINT_ERRORS=$(golint ./... | grep -v "Id should be") -if [ -n "${GOLINT_ERRORS}" ]; then - printf >&2 'golint failed for the following reasons:\n%s\n\nplease run 'golint ./...' on your changes before committing.\n' "${GOLINT_ERRORS}" - exit 1 -fi - -GOVET_ERRORS=$(go tool vet *.go 2>&1) -if [ -n "${GOVET_ERRORS}" ]; then - printf >&2 'go vet failed for the following reasons:\n%s\n\nplease run "go tool vet *.go" on your changes before committing.\n' "${GOVET_ERRORS}" - exit 1 -fi - -if [ -z "${NOTEST}" ]; then - printf >&2 'Running short tests...\n' - env AMQP_URL= go test -short -v | egrep 'PASS|ok' - - if [ $? -ne 0 ]; then - printf >&2 'go test failed, please fix before committing.\n' +LATEST_STABLE_SUPPORTED_GO_VERSION="1.11" + +main() { + if local_go_version_is_latest_stable + then + run_gofmt + run_golint + run_govet + fi + run_unit_tests +} + +local_go_version_is_latest_stable() { + go version | grep -q $LATEST_STABLE_SUPPORTED_GO_VERSION +} + +log_error() { + echo "$*" 1>&2 +} + +run_gofmt() { + GOFMT_FILES=$(gofmt -l .) + if [ -n "$GOFMT_FILES" ] + then + log_error "gofmt failed for the following files: +$GOFMT_FILES + +please run 'gofmt -w .' on your changes before committing." exit 1 fi -fi +} + +run_golint() { + GOLINT_ERRORS=$(golint ./... | grep -v "Id should be") + if [ -n "$GOLINT_ERRORS" ] + then + log_error "golint failed for the following reasons: +$GOLINT_ERRORS + +please run 'golint ./...' on your changes before committing." + exit 1 + fi +} + +run_govet() { + GOVET_ERRORS=$(go tool vet ./*.go 2>&1) + if [ -n "$GOVET_ERRORS" ] + then + log_error "go vet failed for the following reasons: +$GOVET_ERRORS + +please run 'go tool vet ./*.go' on your changes before committing." + exit 1 + fi +} + +run_unit_tests() { + if [ -z "$NOTEST" ] + then + log_error 'Running short tests...' + env AMQP_URL= go test -short + fi +} + +main diff --git a/src/dma/vendor/github.com/streadway/amqp/types.go b/src/dma/vendor/github.com/streadway/amqp/types.go index ff5ea3cb..d3ece707 100644 --- a/src/dma/vendor/github.com/streadway/amqp/types.go +++ b/src/dma/vendor/github.com/streadway/amqp/types.go @@ -200,6 +200,7 @@ type Decimal struct { // byte // float32 // float64 +// int // int16 // int32 // int64 @@ -225,7 +226,7 @@ type Table map[string]interface{} func validateField(f interface{}) error { switch fv := f.(type) { - case nil, bool, byte, int16, int32, int64, float32, float64, string, []byte, Decimal, time.Time: + case nil, bool, byte, int, int16, int32, int64, float32, float64, string, []byte, Decimal, time.Time: return nil case []interface{}: diff --git a/src/dma/vendor/github.com/streadway/amqp/uri.go b/src/dma/vendor/github.com/streadway/amqp/uri.go index 35fefdc2..e5847154 100644 --- a/src/dma/vendor/github.com/streadway/amqp/uri.go +++ b/src/dma/vendor/github.com/streadway/amqp/uri.go @@ -125,6 +125,15 @@ func (uri URI) PlainAuth() *PlainAuth { } } +// AMQPlainAuth returns a PlainAuth structure based on the parsed URI's +// Username and Password fields. +func (uri URI) AMQPlainAuth() *AMQPlainAuth { + return &AMQPlainAuth{ + Username: uri.Username, + Password: uri.Password, + } +} + func (uri URI) String() string { authority, err := url.Parse("") if err != nil { diff --git a/src/dma/vendor/github.com/streadway/amqp/write.go b/src/dma/vendor/github.com/streadway/amqp/write.go index 58ed20d6..94a46d11 100644 --- a/src/dma/vendor/github.com/streadway/amqp/write.go +++ b/src/dma/vendor/github.com/streadway/amqp/write.go @@ -308,6 +308,11 @@ func writeField(w io.Writer, value interface{}) (err error) { binary.BigEndian.PutUint16(buf[1:3], uint16(v)) enc = buf[:3] + case int: + buf[0] = 'I' + binary.BigEndian.PutUint32(buf[1:5], uint32(v)) + enc = buf[:5] + case int32: buf[0] = 'I' binary.BigEndian.PutUint32(buf[1:5], uint32(v)) |