From a3b7703318ed6b7db5ce88d40a56e109b08cf29b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 04:04:01 +0000 Subject: [PATCH] Renovate: Update module github.com/sapcc/go-bits to v0.0.0-20240516084938-1c041b7a84ce --- go.mod | 6 +- go.sum | 21 +-- .../gofrs/uuid/v5/.pre-commit-config.yaml | 14 ++ vendor/github.com/gofrs/uuid/v5/README.md | 24 ++- vendor/github.com/gofrs/uuid/v5/codec.go | 33 ++-- vendor/github.com/gofrs/uuid/v5/error.go | 40 +++++ vendor/github.com/gofrs/uuid/v5/generator.go | 153 +++++++++--------- vendor/github.com/gofrs/uuid/v5/sql.go | 2 +- vendor/github.com/gofrs/uuid/v5/uuid.go | 64 +++----- .../rabbitmq/amqp091-go/CHANGELOG.md | 68 ++++++++ .../github.com/rabbitmq/amqp091-go/channel.go | 56 +++---- .../rabbitmq/amqp091-go/connection.go | 79 +++++++-- vendor/github.com/rabbitmq/amqp091-go/doc.go | 33 ++-- .../github.com/rabbitmq/amqp091-go/types.go | 57 +++++-- vendor/github.com/rabbitmq/amqp091-go/uri.go | 78 +++++++-- vendor/modules.txt | 8 +- 16 files changed, 477 insertions(+), 259 deletions(-) create mode 100644 vendor/github.com/gofrs/uuid/v5/.pre-commit-config.yaml create mode 100644 vendor/github.com/gofrs/uuid/v5/error.go diff --git a/go.mod b/go.mod index fe9d308d..b33ba1d1 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/prometheus/common v0.53.0 github.com/rs/cors v1.11.0 github.com/sapcc/go-api-declarations v1.11.2 - github.com/sapcc/go-bits v0.0.0-20240510084529-cd25c4e3bda0 + github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce go.uber.org/automaxprocs v1.5.3 gopkg.in/yaml.v2 v2.4.0 ) @@ -21,7 +21,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/databus23/goslo.policy v0.0.0-20210929125152-81bf2876dbdb // indirect - github.com/gofrs/uuid/v5 v5.1.0 // indirect + github.com/gofrs/uuid/v5 v5.2.0 // indirect github.com/golang-migrate/migrate/v4 v4.17.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -34,7 +34,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/prometheus/client_model v0.6.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/rabbitmq/amqp091-go v1.9.0 // indirect + github.com/rabbitmq/amqp091-go v1.10.0 // indirect github.com/sergi/go-diff v1.3.1 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/sys v0.18.0 // indirect diff --git a/go.sum b/go.sum index e6602e14..b2bf5ee5 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gofrs/uuid/v5 v5.1.0 h1:S5rqVKIigghZTCBKPCw0Y+bXkn26K3TB5mvQq2Ix8dk= -github.com/gofrs/uuid/v5 v5.1.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= +github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM= +github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -141,28 +141,25 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc3Aoo= -github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc= +github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= +github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po= github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/sapcc/go-api-declarations v1.11.2 h1:CFVxgWqrs4WBJhbA0nJNQ/0mBpAxmNFuUZtuEITltFU= github.com/sapcc/go-api-declarations v1.11.2/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI= -github.com/sapcc/go-bits v0.0.0-20240510084529-cd25c4e3bda0 h1:tu/b+NfEXbKCHrma8d0Ev9Z+5TcyEJ7Xh4/b4gk0o04= -github.com/sapcc/go-bits v0.0.0-20240510084529-cd25c4e3bda0/go.mod h1:5kvPafmHVqIEx8qzSsuCVe4Or9XVi6yLnIf1CE1QHkc= +github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce h1:cMrOXCHbUuxCJX3vkaXvMcmUKkQQ65BPwtCj7MMebCA= +github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce/go.mod h1:dGC65DP50Yuu0P+DsrtXIZU+P0HluN7HXnAA3xNCVBk= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -170,8 +167,8 @@ go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -228,7 +225,6 @@ google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGm google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -236,6 +232,5 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/vendor/github.com/gofrs/uuid/v5/.pre-commit-config.yaml b/vendor/github.com/gofrs/uuid/v5/.pre-commit-config.yaml new file mode 100644 index 00000000..919f2c44 --- /dev/null +++ b/vendor/github.com/gofrs/uuid/v5/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: +- repo: https://github.com/gitleaks/gitleaks + rev: v8.16.3 + hooks: + - id: gitleaks +- repo: https://github.com/golangci/golangci-lint + rev: v1.52.2 + hooks: + - id: golangci-lint +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/vendor/github.com/gofrs/uuid/v5/README.md b/vendor/github.com/gofrs/uuid/v5/README.md index 3df33d69..4ae7bd0a 100644 --- a/vendor/github.com/gofrs/uuid/v5/README.md +++ b/vendor/github.com/gofrs/uuid/v5/README.md @@ -7,22 +7,17 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/uuid)](https://goreportcard.com/report/github.com/gofrs/uuid) Package uuid provides a pure Go implementation of Universally Unique Identifiers -(UUID) variant as defined in RFC-4122. This package supports both the creation +(UUID) variant as defined in RFC-9562. This package supports both the creation and parsing of UUIDs in different formats. This package supports the following UUID versions: -* Version 1, based on timestamp and MAC address (RFC-4122) -* Version 3, based on MD5 hashing of a named value (RFC-4122) -* Version 4, based on random numbers (RFC-4122) -* Version 5, based on SHA-1 hashing of a named value (RFC-4122) -This package also supports experimental Universally Unique Identifier implementations based on a -[draft RFC](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html) that updates RFC-4122 -* Version 6, a k-sortable id based on timestamp, and field-compatible with v1 (draft-peabody-dispatch-new-uuid-format, RFC-4122) -* Version 7, a k-sortable id based on timestamp (draft-peabody-dispatch-new-uuid-format, RFC-4122) - -The v6 and v7 IDs are **not** considered a part of the stable API, and may be subject to behavior or API changes as part of minor releases -to this package. They will be updated as the draft RFC changes, and will become stable if and when the draft RFC is accepted. +* Version 1, based on timestamp and MAC address +* Version 3, based on MD5 hashing of a named value +* Version 4, based on random numbers +* Version 5, based on SHA-1 hashing of a named value +* Version 6, a k-sortable id based on timestamp, and field-compatible with v1 +* Version 7, a k-sortable id based on timestamp ## Project History @@ -50,7 +45,7 @@ deficiencies. ## Requirements -This package requires Go 1.17 or later +This package requires Go 1.19 or later ## Usage @@ -90,6 +85,5 @@ func main() { ## References -* [RFC-4122](https://tools.ietf.org/html/rfc4122) +* [RFC-9562](https://tools.ietf.org/html/rfc9563) (replaces RFC-4122) * [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) -* [New UUID Formats RFC Draft (Peabody) Rev 04](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#) diff --git a/vendor/github.com/gofrs/uuid/v5/codec.go b/vendor/github.com/gofrs/uuid/v5/codec.go index 66502641..8087955d 100644 --- a/vendor/github.com/gofrs/uuid/v5/codec.go +++ b/vendor/github.com/gofrs/uuid/v5/codec.go @@ -21,10 +21,7 @@ package uuid -import ( - "errors" - "fmt" -) +import "fmt" // FromBytes returns a UUID generated from the raw byte slice input. // It will return an error if the slice isn't 16 bytes long. @@ -44,8 +41,6 @@ func FromBytesOrNil(input []byte) UUID { return uuid } -var errInvalidFormat = errors.New("uuid: invalid UUID format") - func fromHexChar(c byte) byte { switch { case '0' <= c && c <= '9': @@ -66,21 +61,21 @@ func (u *UUID) Parse(s string) error { case 36: // canonical case 34, 38: if s[0] != '{' || s[len(s)-1] != '}' { - return fmt.Errorf("uuid: incorrect UUID format in string %q", s) + return fmt.Errorf("%w %q", ErrIncorrectFormatInString, s) } s = s[1 : len(s)-1] case 41, 45: if s[:9] != "urn:uuid:" { - return fmt.Errorf("uuid: incorrect UUID format in string %q", s[:9]) + return fmt.Errorf("%w %q", ErrIncorrectFormatInString, s[:9]) } s = s[9:] default: - return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(s), s) + return fmt.Errorf("%w %d in string %q", ErrIncorrectLength, len(s), s) } // canonical if len(s) == 36 { if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { - return fmt.Errorf("uuid: incorrect UUID format in string %q", s) + return fmt.Errorf("%w %q", ErrIncorrectFormatInString, s) } for i, x := range [16]byte{ 0, 2, 4, 6, @@ -92,7 +87,7 @@ func (u *UUID) Parse(s string) error { v1 := fromHexChar(s[x]) v2 := fromHexChar(s[x+1]) if v1|v2 == 255 { - return errInvalidFormat + return ErrInvalidFormat } u[i] = (v1 << 4) | v2 } @@ -103,7 +98,7 @@ func (u *UUID) Parse(s string) error { v1 := fromHexChar(s[i]) v2 := fromHexChar(s[i+1]) if v1|v2 == 255 { - return errInvalidFormat + return ErrInvalidFormat } u[i/2] = (v1 << 4) | v2 } @@ -175,20 +170,20 @@ func (u *UUID) UnmarshalText(b []byte) error { case 36: // canonical case 34, 38: if b[0] != '{' || b[len(b)-1] != '}' { - return fmt.Errorf("uuid: incorrect UUID format in string %q", b) + return fmt.Errorf("%w %q", ErrIncorrectFormatInString, b) } b = b[1 : len(b)-1] case 41, 45: if string(b[:9]) != "urn:uuid:" { - return fmt.Errorf("uuid: incorrect UUID format in string %q", b[:9]) + return fmt.Errorf("%w %q", ErrIncorrectFormatInString, b[:9]) } b = b[9:] default: - return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(b), b) + return fmt.Errorf("%w %d in string %q", ErrIncorrectLength, len(b), b) } if len(b) == 36 { if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' { - return fmt.Errorf("uuid: incorrect UUID format in string %q", b) + return fmt.Errorf("%w %q", ErrIncorrectFormatInString, b) } for i, x := range [16]byte{ 0, 2, 4, 6, @@ -200,7 +195,7 @@ func (u *UUID) UnmarshalText(b []byte) error { v1 := fromHexChar(b[x]) v2 := fromHexChar(b[x+1]) if v1|v2 == 255 { - return errInvalidFormat + return ErrInvalidFormat } u[i] = (v1 << 4) | v2 } @@ -210,7 +205,7 @@ func (u *UUID) UnmarshalText(b []byte) error { v1 := fromHexChar(b[i]) v2 := fromHexChar(b[i+1]) if v1|v2 == 255 { - return errInvalidFormat + return ErrInvalidFormat } u[i/2] = (v1 << 4) | v2 } @@ -226,7 +221,7 @@ func (u UUID) MarshalBinary() ([]byte, error) { // It will return an error if the slice isn't 16 bytes long. func (u *UUID) UnmarshalBinary(data []byte) error { if len(data) != Size { - return fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) + return fmt.Errorf("%w, got %d bytes", ErrIncorrectByteLength, len(data)) } copy(u[:], data) diff --git a/vendor/github.com/gofrs/uuid/v5/error.go b/vendor/github.com/gofrs/uuid/v5/error.go new file mode 100644 index 00000000..7ca0be49 --- /dev/null +++ b/vendor/github.com/gofrs/uuid/v5/error.go @@ -0,0 +1,40 @@ +package uuid + +// Error is a custom error type for UUID-related errors +type Error string + +// The strings defined in the errors is matching the previous behavior before +// the custom error type was implemented. The reason is that some people might +// be relying on the exact string representation to handle errors in their code. +const ( + // ErrInvalidFormat is returned when the UUID string representation does not + // match the expected format. See also ErrIncorrectFormatInString. + ErrInvalidFormat = Error("uuid: invalid UUID format") + + // ErrIncorrectFormatInString can be returned instead of ErrInvalidFormat. + // A separate error type is used because of how errors used to be formatted + // before custom error types were introduced. + ErrIncorrectFormatInString = Error("uuid: incorrect UUID format in string") + + // ErrIncorrectLength is returned when the UUID does not have the + // appropriate string length for parsing the UUID. + ErrIncorrectLength = Error("uuid: incorrect UUID length") + + // ErrIncorrectByteLength indicates the UUID byte slice length is invalid. + ErrIncorrectByteLength = Error("uuid: UUID must be exactly 16 bytes long") + + // ErrNoHwAddressFound is returned when a hardware (MAC) address cannot be + // found for UUID generation. + ErrNoHwAddressFound = Error("uuid: no HW address found") + + // ErrTypeConvertError is returned for type conversion operation fails. + ErrTypeConvertError = Error("uuid: cannot convert") + + // ErrInvalidVersion indicates an unsupported or invalid UUID version. + ErrInvalidVersion = Error("uuid:") +) + +// Error returns the string representation of the UUID error. +func (e Error) Error() string { + return string(e) +} diff --git a/vendor/github.com/gofrs/uuid/v5/generator.go b/vendor/github.com/gofrs/uuid/v5/generator.go index 44be9e15..7bfe50cf 100644 --- a/vendor/github.com/gofrs/uuid/v5/generator.go +++ b/vendor/github.com/gofrs/uuid/v5/generator.go @@ -26,7 +26,6 @@ import ( "crypto/rand" "crypto/sha1" "encoding/binary" - "fmt" "hash" "io" "net" @@ -70,24 +69,12 @@ func NewV5(ns UUID, name string) UUID { // NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of // pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit // order being adjusted to allow the UUID to be k-sortable. -// -// This is implemented based on revision 03 of the Peabody UUID draft, and may -// be subject to change pending further revisions. Until the final specification -// revision is finished, changes required to implement updates to the spec will -// not be considered a breaking change. They will happen as a minor version -// releases until the spec is final. func NewV6() (UUID, error) { return DefaultGenerator.NewV6() } // NewV7 returns a k-sortable UUID based on the current millisecond precision // UNIX epoch and 74 bits of pseudorandom data. It supports single-node batch generation (multiple UUIDs in the same timestamp) with a Monotonic Random counter. -// -// This is implemented based on revision 04 of the Peabody UUID draft, and may -// be subject to change pending further revisions. Until the final specification -// revision is finished, changes required to implement updates to the spec will -// not be considered a breaking change. They will happen as a minor version -// releases until the spec is final. func NewV7() (UUID, error) { return DefaultGenerator.NewV7() } @@ -103,7 +90,7 @@ type Generator interface { } // Gen is a reference UUID generator based on the specifications laid out in -// RFC-4122 and DCE 1.1: Authentication and Security Services. This type +// RFC-9562 and DCE 1.1: Authentication and Security Services. This type // satisfies the Generator interface as defined in this package. // // For consumers who are generating V1 UUIDs, but don't want to expose the MAC @@ -242,7 +229,7 @@ func (g *Gen) NewV1() (UUID, error) { copy(u[10:], hardwareAddr) u.SetVersion(V1) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } @@ -251,7 +238,7 @@ func (g *Gen) NewV1() (UUID, error) { func (g *Gen) NewV3(ns UUID, name string) UUID { u := newFromHash(md5.New(), ns, name) u.SetVersion(V3) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u } @@ -263,7 +250,7 @@ func (g *Gen) NewV4() (UUID, error) { return Nil, err } u.SetVersion(V4) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } @@ -272,7 +259,7 @@ func (g *Gen) NewV4() (UUID, error) { func (g *Gen) NewV5(ns UUID, name string) UUID { u := newFromHash(sha1.New(), ns, name) u.SetVersion(V5) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u } @@ -280,20 +267,22 @@ func (g *Gen) NewV5(ns UUID, name string) UUID { // NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of // pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit // order being adjusted to allow the UUID to be k-sortable. -// -// This is implemented based on revision 03 of the Peabody UUID draft, and may -// be subject to change pending further revisions. Until the final specification -// revision is finished, changes required to implement updates to the spec will -// not be considered a breaking change. They will happen as a minor version -// releases until the spec is final. func (g *Gen) NewV6() (UUID, error) { + /* https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-6 + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | time_high | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | time_mid | ver | time_low | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |var| clock_seq | node | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | node | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ var u UUID - if _, err := io.ReadFull(g.rand, u[10:]); err != nil { - return Nil, err - } - - timeNow, clockSeq, err := g.getClockSequence(false) + timeNow, _, err := g.getClockSequence(false) if err != nil { return Nil, err } @@ -301,63 +290,28 @@ func (g *Gen) NewV6() (UUID, error) { binary.BigEndian.PutUint32(u[0:], uint32(timeNow>>28)) // set time_high binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>12)) // set time_mid binary.BigEndian.PutUint16(u[6:], uint16(timeNow&0xfff)) // set time_low (minus four version bits) - binary.BigEndian.PutUint16(u[8:], clockSeq&0x3fff) // set clk_seq_hi_res (minus two variant bits) - - u.SetVersion(V6) - u.SetVariant(VariantRFC4122) - - return u, nil -} -// getClockSequence returns the epoch and clock sequence for V1,V6 and V7 UUIDs. -// -// When useUnixTSMs is false, it uses the Coordinated Universal Time (UTC) as a count of 100- -// -// nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar). -func (g *Gen) getClockSequence(useUnixTSMs bool) (uint64, uint16, error) { - var err error - g.clockSequenceOnce.Do(func() { - buf := make([]byte, 2) - if _, err = io.ReadFull(g.rand, buf); err != nil { - return - } - g.clockSequence = binary.BigEndian.Uint16(buf) - }) - if err != nil { - return 0, 0, err + // Based on the RFC 9562 recommendation that this data be fully random and not a monotonic counter, + //we do NOT support batching version 6 UUIDs. + //set clock_seq (14 bits) and node (48 bits) pseudo-random bits (first 2 bits will be overridden) + if _, err = io.ReadFull(g.rand, u[8:]); err != nil { + return Nil, err } - g.storageMutex.Lock() - defer g.storageMutex.Unlock() + u.SetVersion(V6) - var timeNow uint64 - if useUnixTSMs { - timeNow = uint64(g.epochFunc().UnixMilli()) - } else { - timeNow = g.getEpoch() - } - // Clock didn't change since last UUID generation. - // Should increase clock sequence. - if timeNow <= g.lastTime { - g.clockSequence++ - } - g.lastTime = timeNow + //overwrite first 2 bits of byte[8] for the variant + u.SetVariant(VariantRFC9562) - return timeNow, g.clockSequence, nil + return u, nil } // NewV7 returns a k-sortable UUID based on the current millisecond precision // UNIX epoch and 74 bits of pseudorandom data. -// -// This is implemented based on revision 04 of the Peabody UUID draft, and may -// be subject to change pending further revisions. Until the final specification -// revision is finished, changes required to implement updates to the spec will -// not be considered a breaking change. They will happen as a minor version -// releases until the spec is final. func (g *Gen) NewV7() (UUID, error) { var u UUID - /* https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7 - 0 1 2 3 + /* https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7 + 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | unix_ts_ms | @@ -381,9 +335,11 @@ func (g *Gen) NewV7() (UUID, error) { u[4] = byte(ms >> 8) u[5] = byte(ms) - //support batching by using a monotonic pseudo-random sequence + //Support batching by using a monotonic pseudo-random sequence, + //as described in RFC 9562 section 6.2, Method 1. //The 6th byte contains the version and partially rand_a data. - //We will lose the most significant bites from the clockSeq (with SetVersion), but it is ok, we need the least significant that contains the counter to ensure the monotonic property + //We will lose the most significant bites from the clockSeq (with SetVersion), but it is ok, + //we need the least significant that contains the counter to ensure the monotonic property binary.BigEndian.PutUint16(u[6:8], clockSeq) // set rand_a with clock seq which is random and monotonic //override first 4bits of u[6]. @@ -394,11 +350,48 @@ func (g *Gen) NewV7() (UUID, error) { return Nil, err } //override first 2 bits of byte[8] for the variant - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } +// getClockSequence returns the epoch and clock sequence for V1,V6 and V7 UUIDs. +// +// When useUnixTSMs is false, it uses the Coordinated Universal Time (UTC) as a count of 100- +// +// nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar). +func (g *Gen) getClockSequence(useUnixTSMs bool) (uint64, uint16, error) { + var err error + g.clockSequenceOnce.Do(func() { + buf := make([]byte, 2) + if _, err = io.ReadFull(g.rand, buf); err != nil { + return + } + g.clockSequence = binary.BigEndian.Uint16(buf) + }) + if err != nil { + return 0, 0, err + } + + g.storageMutex.Lock() + defer g.storageMutex.Unlock() + + var timeNow uint64 + if useUnixTSMs { + timeNow = uint64(g.epochFunc().UnixMilli()) + } else { + timeNow = g.getEpoch() + } + // Clock didn't change since last UUID generation. + // Should increase clock sequence. + if timeNow <= g.lastTime { + g.clockSequence++ + } + g.lastTime = timeNow + + return timeNow, g.clockSequence, nil +} + // Returns the hardware address. func (g *Gen) getHardwareAddr() ([]byte, error) { var err error @@ -414,7 +407,7 @@ func (g *Gen) getHardwareAddr() ([]byte, error) { if _, err = io.ReadFull(g.rand, g.hardwareAddr[:]); err != nil { return } - // Set multicast bit as recommended by RFC-4122 + // Set multicast bit as recommended by RFC-9562 g.hardwareAddr[0] |= 0x01 }) if err != nil { @@ -452,5 +445,5 @@ func defaultHWAddrFunc() (net.HardwareAddr, error) { return iface.HardwareAddr, nil } } - return []byte{}, fmt.Errorf("uuid: no HW address found") + return []byte{}, ErrNoHwAddressFound } diff --git a/vendor/github.com/gofrs/uuid/v5/sql.go b/vendor/github.com/gofrs/uuid/v5/sql.go index 01d5d884..cdc75182 100644 --- a/vendor/github.com/gofrs/uuid/v5/sql.go +++ b/vendor/github.com/gofrs/uuid/v5/sql.go @@ -56,7 +56,7 @@ func (u *UUID) Scan(src interface{}) error { return err } - return fmt.Errorf("uuid: cannot convert %T to UUID", src) + return fmt.Errorf("%w %T to UUID", ErrTypeConvertError, src) } // NullUUID can be used with the standard sql package to represent a diff --git a/vendor/github.com/gofrs/uuid/v5/uuid.go b/vendor/github.com/gofrs/uuid/v5/uuid.go index 032719c1..e6fc3fc1 100644 --- a/vendor/github.com/gofrs/uuid/v5/uuid.go +++ b/vendor/github.com/gofrs/uuid/v5/uuid.go @@ -20,24 +20,21 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Package uuid provides implementations of the Universally Unique Identifier -// (UUID), as specified in RFC-4122 and the Peabody RFC Draft (revision 03). +// (UUID), as specified in RFC-9562 (formerly RFC-4122). // -// RFC-4122[1] provides the specification for versions 1, 3, 4, and 5. The -// Peabody UUID RFC Draft[2] provides the specification for the new k-sortable -// UUIDs, versions 6 and 7. +// RFC-9562[1] provides the specification for versions 1, 3, 4, 5, 6 and 7. // -// DCE 1.1[3] provides the specification for version 2, but version 2 support +// DCE 1.1[2] provides the specification for version 2, but version 2 support // was removed from this package in v4 due to some concerns with the // specification itself. Reading the spec, it seems that it would result in // generating UUIDs that aren't very unique. In having read the spec it seemed // that our implementation did not meet the spec. It also seems to be at-odds -// with RFC 4122, meaning we would need quite a bit of special code to support +// with RFC 9562, meaning we would need quite a bit of special code to support // it. Lastly, there were no Version 2 implementations that we could find to // ensure we were understanding the specification correctly. // -// [1] https://tools.ietf.org/html/rfc4122 -// [2] https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03 -// [3] http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01 +// [1] https://tools.ietf.org/html/rfc9562 +// [2] http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01 package uuid import ( @@ -50,7 +47,7 @@ import ( // Size of a UUID in bytes. const Size = 16 -// UUID is an array type to represent the value of a UUID, as defined in RFC-4122. +// UUID is an array type to represent the value of a UUID, as defined in RFC-9562. type UUID [Size]byte // UUID versions. @@ -61,19 +58,22 @@ const ( V3 // Version 3 (namespace name-based) V4 // Version 4 (random) V5 // Version 5 (namespace name-based) - V6 // Version 6 (k-sortable timestamp and random data, field-compatible with v1) [peabody draft] - V7 // Version 7 (k-sortable timestamp and random data) [peabody draft] - _ // Version 8 (k-sortable timestamp, meant for custom implementations) [peabody draft] [not implemented] + V6 // Version 6 (k-sortable timestamp and random data, field-compatible with v1) + V7 // Version 7 (k-sortable timestamp and random data) + _ // Version 8 (k-sortable timestamp, meant for custom implementations) [not implemented] ) // UUID layout variants. const ( VariantNCS byte = iota - VariantRFC4122 + VariantRFC9562 VariantMicrosoft VariantFuture ) +// Backward-compatible variant for RFC 4122 +const VariantRFC4122 = VariantRFC9562 + // UUID DCE domains. const ( DomainPerson = iota @@ -100,7 +100,7 @@ func (t Timestamp) Time() (time.Time, error) { // Returns an error if the UUID is any version other than 1. func TimestampFromV1(u UUID) (Timestamp, error) { if u.Version() != 1 { - err := fmt.Errorf("uuid: %s is version %d, not version 1", u, u.Version()) + err := fmt.Errorf("%w %s is version %d, not version 1", ErrInvalidVersion, u, u.Version()) return 0, err } @@ -113,15 +113,9 @@ func TimestampFromV1(u UUID) (Timestamp, error) { // TimestampFromV6 returns the Timestamp embedded within a V6 UUID. This // function returns an error if the UUID is any version other than 6. -// -// This is implemented based on revision 03 of the Peabody UUID draft, and may -// be subject to change pending further revisions. Until the final specification -// revision is finished, changes required to implement updates to the spec will -// not be considered a breaking change. They will happen as a minor version -// releases until the spec is final. func TimestampFromV6(u UUID) (Timestamp, error) { if u.Version() != 6 { - return 0, fmt.Errorf("uuid: %s is version %d, not version 6", u, u.Version()) + return 0, fmt.Errorf("%w %s is version %d, not version 6", ErrInvalidVersion, u, u.Version()) } hi := binary.BigEndian.Uint32(u[0:4]) @@ -133,15 +127,9 @@ func TimestampFromV6(u UUID) (Timestamp, error) { // TimestampFromV7 returns the Timestamp embedded within a V7 UUID. This // function returns an error if the UUID is any version other than 7. -// -// This is implemented based on revision 03 of the Peabody UUID draft, and may -// be subject to change pending further revisions. Until the final specification -// revision is finished, changes required to implement updates to the spec will -// not be considered a breaking change. They will happen as a minor version -// releases until the spec is final. func TimestampFromV7(u UUID) (Timestamp, error) { if u.Version() != 7 { - return 0, fmt.Errorf("uuid: %s is version %d, not version 7", u, u.Version()) + return 0, fmt.Errorf("%w %s is version %d, not version 7", ErrInvalidVersion, u, u.Version()) } t := 0 | @@ -157,12 +145,12 @@ func TimestampFromV7(u UUID) (Timestamp, error) { return Timestamp(tsNanos), nil } -// Nil is the nil UUID, as specified in RFC-4122, that has all 128 bits set to +// Nil is the nil UUID, as specified in RFC-9562, that has all 128 bits set to // zero. var Nil = UUID{} -// Max is the maximum UUID, as specified in a draft of RFC-4122, that has all 128 bits -// set to one. This feature is subject to removal if it is removed from the final draft of the RFC. +// Max is the maximum UUID, as specified in RFC-9562, that has all 128 bits +// set to one. var Max = UUID{ 0xFF, 0xFF, @@ -206,7 +194,7 @@ func (u UUID) Variant() byte { case (u[8] >> 7) == 0x00: return VariantNCS case (u[8] >> 6) == 0x02: - return VariantRFC4122 + return VariantRFC9562 case (u[8] >> 5) == 0x06: return VariantMicrosoft case (u[8] >> 5) == 0x07: @@ -221,7 +209,7 @@ func (u UUID) Bytes() []byte { return u[:] } -// encodeCanonical encodes the canonical RFC-4122 form of UUID u into the +// encodeCanonical encodes the canonical RFC-9562 form of UUID u into the // first 36 bytes dst. func encodeCanonical(dst []byte, u UUID) { const hextable = "0123456789abcdef" @@ -242,7 +230,7 @@ func encodeCanonical(dst []byte, u UUID) { } } -// String returns a canonical RFC-4122 string representation of the UUID: +// String returns a canonical RFC-9562 string representation of the UUID: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. func (u UUID) String() string { var buf [36]byte @@ -254,8 +242,8 @@ func (u UUID) String() string { // // The behavior is as follows: // The 'x' and 'X' verbs output only the hex digits of the UUID, using a-f for 'x' and A-F for 'X'. -// The 'v', '+v', 's' and 'q' verbs return the canonical RFC-4122 string representation. -// The 'S' verb returns the RFC-4122 format, but with capital hex digits. +// The 'v', '+v', 's' and 'q' verbs return the canonical RFC-9562 string representation. +// The 'S' verb returns the RFC-9562 format, but with capital hex digits. // The '#v' verb returns the "Go syntax" representation, which is a 16 byte array initializer. // All other verbs not handled directly by the fmt package (like '%p') are unsupported and will return // "%!verb(uuid.UUID=value)" as recommended by the fmt package. @@ -308,7 +296,7 @@ func (u *UUID) SetVariant(v byte) { switch v { case VariantNCS: u[8] = (u[8]&(0xff>>1) | (0x00 << 7)) - case VariantRFC4122: + case VariantRFC9562: u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) case VariantMicrosoft: u[8] = (u[8]&(0xff>>3) | (0x06 << 5)) diff --git a/vendor/github.com/rabbitmq/amqp091-go/CHANGELOG.md b/vendor/github.com/rabbitmq/amqp091-go/CHANGELOG.md index db633d44..fd03c1f9 100644 --- a/vendor/github.com/rabbitmq/amqp091-go/CHANGELOG.md +++ b/vendor/github.com/rabbitmq/amqp091-go/CHANGELOG.md @@ -1,5 +1,73 @@ # Changelog +## [v1.10.0](https://github.com/rabbitmq/amqp091-go/tree/v1.10.0) (2024-05-08) + +[Full Changelog](https://github.com/rabbitmq/amqp091-go/compare/v1.9.0...v1.10.0) + +**Implemented enhancements:** + +- Undeprecate non-context publish functions [\#259](https://github.com/rabbitmq/amqp091-go/pull/259) ([Zerpet](https://github.com/Zerpet)) +- Update Go directive [\#257](https://github.com/rabbitmq/amqp091-go/pull/257) ([Zerpet](https://github.com/Zerpet)) + +**Fixed bugs:** + +- republishing on reconnect bug in the example [\#249](https://github.com/rabbitmq/amqp091-go/issues/249) +- Channel Notify Close not receive event when connection is closed by RMQ server. [\#241](https://github.com/rabbitmq/amqp091-go/issues/241) +- Inconsistent documentation [\#231](https://github.com/rabbitmq/amqp091-go/issues/231) +- Data race in the client example [\#72](https://github.com/rabbitmq/amqp091-go/issues/72) +- Fix string function of URI [\#258](https://github.com/rabbitmq/amqp091-go/pull/258) ([Zerpet](https://github.com/Zerpet)) + +**Closed issues:** + +- Documentation needed \(`PublishWithContext` does not use context\) [\#195](https://github.com/rabbitmq/amqp091-go/issues/195) +- concurrent dispatch data race [\#226](https://github.com/rabbitmq/amqp091-go/issues/226) + +**Merged pull requests:** + +- Fix data race in example [\#260](https://github.com/rabbitmq/amqp091-go/pull/260) ([Zerpet](https://github.com/Zerpet)) +- Address CodeQL warning [\#252](https://github.com/rabbitmq/amqp091-go/pull/252) ([lukebakken](https://github.com/lukebakken)) +- Add support for additional AMQP URI query parameters [\#251](https://github.com/rabbitmq/amqp091-go/pull/251) ([vilius-g](https://github.com/vilius-g)) +- Example fix [\#250](https://github.com/rabbitmq/amqp091-go/pull/250) ([Boris-Plato](https://github.com/Boris-Plato)) +- Increasing the code coverage [\#248](https://github.com/rabbitmq/amqp091-go/pull/248) ([edercarloscosta](https://github.com/edercarloscosta)) +- Use correct mutex to guard confirms.published [\#240](https://github.com/rabbitmq/amqp091-go/pull/240) ([hjr265](https://github.com/hjr265)) +- Documenting Publishing.Expiration usage [\#232](https://github.com/rabbitmq/amqp091-go/pull/232) ([niksteff](https://github.com/niksteff)) +- fix comment typo in example\_client\_test.go [\#228](https://github.com/rabbitmq/amqp091-go/pull/228) ([wisaTong](https://github.com/wisaTong)) +- Bump go.uber.org/goleak from 1.2.1 to 1.3.0 [\#227](https://github.com/rabbitmq/amqp091-go/pull/227) ([dependabot[bot]](https://github.com/apps/dependabot)) + +## [v1.9.0](https://github.com/rabbitmq/amqp091-go/tree/v1.9.0) (2023-10-02) + +[Full Changelog](https://github.com/rabbitmq/amqp091-go/compare/v1.8.1...v1.9.0) + +**Implemented enhancements:** + +- Use of buffered delivery channels when prefetch\_count is not null [\#200](https://github.com/rabbitmq/amqp091-go/issues/200) + +**Fixed bugs:** + +- connection block when write connection reset by peer [\#222](https://github.com/rabbitmq/amqp091-go/issues/222) +- Test failure on 32bit architectures [\#202](https://github.com/rabbitmq/amqp091-go/issues/202) + +**Closed issues:** + +- Add a constant to set consumer timeout as queue argument [\#201](https://github.com/rabbitmq/amqp091-go/issues/201) +- Add a constant for CQ version [\#199](https://github.com/rabbitmq/amqp091-go/issues/199) +- Examples may need to be updated after \#140 [\#153](https://github.com/rabbitmq/amqp091-go/issues/153) + +**Merged pull requests:** + +- Update spec091.go [\#224](https://github.com/rabbitmq/amqp091-go/pull/224) ([pinkfish](https://github.com/pinkfish)) +- Closes 222 [\#223](https://github.com/rabbitmq/amqp091-go/pull/223) ([yywing](https://github.com/yywing)) +- Update write.go [\#221](https://github.com/rabbitmq/amqp091-go/pull/221) ([pinkfish](https://github.com/pinkfish)) +- Bump versions [\#219](https://github.com/rabbitmq/amqp091-go/pull/219) ([lukebakken](https://github.com/lukebakken)) +- remove extra word 'accept' from ExchangeDeclare description [\#217](https://github.com/rabbitmq/amqp091-go/pull/217) ([a-sabzian](https://github.com/a-sabzian)) +- Misc Windows CI updates [\#216](https://github.com/rabbitmq/amqp091-go/pull/216) ([lukebakken](https://github.com/lukebakken)) +- Stop using deprecated Publish function [\#207](https://github.com/rabbitmq/amqp091-go/pull/207) ([Zerpet](https://github.com/Zerpet)) +- Constant for consumer timeout queue argument [\#206](https://github.com/rabbitmq/amqp091-go/pull/206) ([Zerpet](https://github.com/Zerpet)) +- Add a constant for CQ v2 queue argument [\#205](https://github.com/rabbitmq/amqp091-go/pull/205) ([Zerpet](https://github.com/Zerpet)) +- Fix example for 32-bit compatibility [\#204](https://github.com/rabbitmq/amqp091-go/pull/204) ([Zerpet](https://github.com/Zerpet)) +- Fix to increase timeout milliseconds since it's too tight [\#203](https://github.com/rabbitmq/amqp091-go/pull/203) ([t2y](https://github.com/t2y)) +- Add Channel.ConsumeWithContext to be able to cancel delivering [\#192](https://github.com/rabbitmq/amqp091-go/pull/192) ([t2y](https://github.com/t2y)) + ## [v1.8.1](https://github.com/rabbitmq/amqp091-go/tree/v1.8.1) (2023-05-04) [Full Changelog](https://github.com/rabbitmq/amqp091-go/compare/v1.8.0...v1.8.1) diff --git a/vendor/github.com/rabbitmq/amqp091-go/channel.go b/vendor/github.com/rabbitmq/amqp091-go/channel.go index 0dcec902..3dfd7faf 100644 --- a/vendor/github.com/rabbitmq/amqp091-go/channel.go +++ b/vendor/github.com/rabbitmq/amqp091-go/channel.go @@ -7,7 +7,6 @@ package amqp091 import ( "context" - "errors" "reflect" "sync" "sync/atomic" @@ -971,9 +970,6 @@ func (ch *Channel) QueueBind(name, key, exchange string, noWait bool, args Table /* QueueUnbind removes a binding between an exchange and queue matching the key and arguments. - -It is possible to send and empty string for the exchange name which means to -unbind the queue from the default exchange. */ func (ch *Channel) QueueUnbind(name, key, exchange string, args Table) error { if err := args.Validate(); err != nil { @@ -1487,17 +1483,17 @@ confirmations start at 1. Exit when all publishings are confirmed. When Publish does not return an error and the channel is in confirm mode, the internal counter for DeliveryTags with the first confirmation starts at 1. - -Deprecated: Use PublishWithContext instead. */ func (ch *Channel) Publish(exchange, key string, mandatory, immediate bool, msg Publishing) error { - _, err := ch.PublishWithDeferredConfirmWithContext(context.Background(), exchange, key, mandatory, immediate, msg) + _, err := ch.PublishWithDeferredConfirm(exchange, key, mandatory, immediate, msg) return err } /* PublishWithContext sends a Publishing from the client to an exchange on the server. +NOTE: this function is equivalent to [Channel.Publish]. Context is not honoured. + When you want a single message to be delivered to a single queue, you can publish to the default exchange with the routingKey of the queue name. This is because every declared queue gets an implicit route to the default exchange. @@ -1527,34 +1523,17 @@ confirmations start at 1. Exit when all publishings are confirmed. When Publish does not return an error and the channel is in confirm mode, the internal counter for DeliveryTags with the first confirmation starts at 1. */ -func (ch *Channel) PublishWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg Publishing) error { - _, err := ch.PublishWithDeferredConfirmWithContext(ctx, exchange, key, mandatory, immediate, msg) - return err +func (ch *Channel) PublishWithContext(_ context.Context, exchange, key string, mandatory, immediate bool, msg Publishing) error { + return ch.Publish(exchange, key, mandatory, immediate, msg) } /* -PublishWithDeferredConfirm behaves identically to Publish but additionally returns a -DeferredConfirmation, allowing the caller to wait on the publisher confirmation -for this message. If the channel has not been put into confirm mode, -the DeferredConfirmation will be nil. - -Deprecated: Use PublishWithDeferredConfirmWithContext instead. +PublishWithDeferredConfirm behaves identically to Publish, but additionally +returns a DeferredConfirmation, allowing the caller to wait on the publisher +confirmation for this message. If the channel has not been put into confirm +mode, the DeferredConfirmation will be nil. */ func (ch *Channel) PublishWithDeferredConfirm(exchange, key string, mandatory, immediate bool, msg Publishing) (*DeferredConfirmation, error) { - return ch.PublishWithDeferredConfirmWithContext(context.Background(), exchange, key, mandatory, immediate, msg) -} - -/* -PublishWithDeferredConfirmWithContext behaves identically to Publish but additionally returns a -DeferredConfirmation, allowing the caller to wait on the publisher confirmation -for this message. If the channel has not been put into confirm mode, -the DeferredConfirmation will be nil. -*/ -func (ch *Channel) PublishWithDeferredConfirmWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg Publishing) (*DeferredConfirmation, error) { - if ctx == nil { - return nil, errors.New("amqp091-go: nil Context") - } - if err := msg.Headers.Validate(); err != nil { return nil, err } @@ -1598,6 +1577,19 @@ func (ch *Channel) PublishWithDeferredConfirmWithContext(ctx context.Context, ex return dc, nil } +/* +PublishWithDeferredConfirmWithContext behaves identically to Publish but additionally returns a +DeferredConfirmation, allowing the caller to wait on the publisher confirmation +for this message. If the channel has not been put into confirm mode, +the DeferredConfirmation will be nil. + +NOTE: PublishWithDeferredConfirmWithContext is equivalent to its non-context variant. The context passed +to this function is not honoured. +*/ +func (ch *Channel) PublishWithDeferredConfirmWithContext(_ context.Context, exchange, key string, mandatory, immediate bool, msg Publishing) (*DeferredConfirmation, error) { + return ch.PublishWithDeferredConfirm(exchange, key, mandatory, immediate, msg) +} + /* Get synchronously receives a single Delivery from the head of a queue from the server to the client. In almost all cases, using Channel.Consume will be @@ -1829,8 +1821,8 @@ func (ch *Channel) Reject(tag uint64, requeue bool) error { // GetNextPublishSeqNo returns the sequence number of the next message to be // published, when in confirm mode. func (ch *Channel) GetNextPublishSeqNo() uint64 { - ch.confirms.m.Lock() - defer ch.confirms.m.Unlock() + ch.confirms.publishedMut.Lock() + defer ch.confirms.publishedMut.Unlock() return ch.confirms.published + 1 } diff --git a/vendor/github.com/rabbitmq/amqp091-go/connection.go b/vendor/github.com/rabbitmq/amqp091-go/connection.go index c8bb820d..e167a23f 100644 --- a/vendor/github.com/rabbitmq/amqp091-go/connection.go +++ b/vendor/github.com/rabbitmq/amqp091-go/connection.go @@ -28,11 +28,11 @@ const ( defaultHeartbeat = 10 * time.Second defaultConnectionTimeout = 30 * time.Second defaultProduct = "AMQP 0.9.1 Client" - buildVersion = "1.9.0" + buildVersion = "1.10.0" platform = "golang" // Safer default that makes channel leaks a lot easier to spot // before they create operational headaches. See https://github.com/rabbitmq/rabbitmq-server/issues/1593. - defaultChannelMax = (2 << 10) - 1 + defaultChannelMax = uint16((2 << 10) - 1) defaultLocale = "en_US" ) @@ -49,7 +49,7 @@ type Config struct { // bindings on the server. Dial sets this to the path parsed from the URL. Vhost string - ChannelMax int // 0 max channels means 2^16 - 1 + ChannelMax uint16 // 0 max channels means 2^16 - 1 FrameSize int // 0 max bytes means unlimited Heartbeat time.Duration // less than 1s uses the server's interval @@ -157,8 +157,7 @@ func DefaultDial(connectionTimeout time.Duration) func(network, addr string) (ne // scheme. It is equivalent to calling DialTLS(amqp, nil). func Dial(url string) (*Connection, error) { return DialConfig(url, Config{ - Heartbeat: defaultHeartbeat, - Locale: defaultLocale, + Locale: defaultLocale, }) } @@ -169,7 +168,6 @@ func Dial(url string) (*Connection, error) { // DialTLS uses the provided tls.Config when encountering an amqps:// scheme. func DialTLS(url string, amqps *tls.Config) (*Connection, error) { return DialConfig(url, Config{ - Heartbeat: defaultHeartbeat, TLSClientConfig: amqps, Locale: defaultLocale, }) @@ -186,7 +184,6 @@ func DialTLS(url string, amqps *tls.Config) (*Connection, error) { // amqps:// scheme. func DialTLS_ExternalAuth(url string, amqps *tls.Config) (*Connection, error) { return DialConfig(url, Config{ - Heartbeat: defaultHeartbeat, TLSClientConfig: amqps, SASL: []Authentication{&ExternalAuth{}}, }) @@ -195,7 +192,9 @@ func DialTLS_ExternalAuth(url string, amqps *tls.Config) (*Connection, error) { // DialConfig accepts a string in the AMQP URI format and a configuration for // the transport and connection setup, returning a new Connection. Defaults to // a server heartbeat interval of 10 seconds and sets the initial read deadline -// to 30 seconds. +// to 30 seconds. The heartbeat interval specified in the AMQP URI takes precedence +// over the value specified in the config. To disable heartbeats, you must use +// the AMQP URI and set heartbeat=0 there. func DialConfig(url string, config Config) (*Connection, error) { var err error var conn net.Conn @@ -206,18 +205,50 @@ func DialConfig(url string, config Config) (*Connection, error) { } if config.SASL == nil { - config.SASL = []Authentication{uri.PlainAuth()} + if uri.AuthMechanism != nil { + for _, identifier := range uri.AuthMechanism { + switch strings.ToUpper(identifier) { + case "PLAIN": + config.SASL = append(config.SASL, uri.PlainAuth()) + case "AMQPLAIN": + config.SASL = append(config.SASL, uri.AMQPlainAuth()) + case "EXTERNAL": + config.SASL = append(config.SASL, &ExternalAuth{}) + default: + return nil, fmt.Errorf("unsupported auth_mechanism: %v", identifier) + } + } + } else { + config.SASL = []Authentication{uri.PlainAuth()} + } } if config.Vhost == "" { config.Vhost = uri.Vhost } + if uri.Heartbeat.hasValue { + config.Heartbeat = uri.Heartbeat.value + } else { + if config.Heartbeat == 0 { + config.Heartbeat = defaultHeartbeat + } + } + + if config.ChannelMax == 0 { + config.ChannelMax = uri.ChannelMax + } + + connectionTimeout := defaultConnectionTimeout + if uri.ConnectionTimeout != 0 { + connectionTimeout = time.Duration(uri.ConnectionTimeout) * time.Millisecond + } + addr := net.JoinHostPort(uri.Host, strconv.FormatInt(int64(uri.Port), 10)) dialer := config.Dial if dialer == nil { - dialer = DefaultDial(defaultConnectionTimeout) + dialer = DefaultDial(connectionTimeout) } conn, err = dialer("tcp", addr) @@ -991,13 +1022,13 @@ func (c *Connection) openTune(config Config, auth Authentication) error { // When the server and client both use default 0, then the max channel is // only limited by uint16. - c.Config.ChannelMax = pick(config.ChannelMax, int(tune.ChannelMax)) + c.Config.ChannelMax = pickUInt16(config.ChannelMax, tune.ChannelMax) if c.Config.ChannelMax == 0 { c.Config.ChannelMax = defaultChannelMax } - c.Config.ChannelMax = min(c.Config.ChannelMax, maxChannelMax) + c.Config.ChannelMax = minUInt16(c.Config.ChannelMax, maxChannelMax) - c.allocator = newAllocator(1, c.Config.ChannelMax) + c.allocator = newAllocator(1, int(c.Config.ChannelMax)) c.m.Unlock() @@ -1104,6 +1135,13 @@ func max(a, b int) int { return b } +func maxUInt16(a, b uint16) uint16 { + if a > b { + return a + } + return b +} + func min(a, b int) int { if a < b { return a @@ -1111,6 +1149,21 @@ func min(a, b int) int { return b } +func minUInt16(a, b uint16) uint16 { + if a < b { + return a + } + return b +} + +func pickUInt16(client, server uint16) uint16 { + if client == 0 || server == 0 { + return maxUInt16(client, server) + } else { + return minUInt16(client, server) + } +} + func pick(client, server int) int { if client == 0 || server == 0 { return max(client, server) diff --git a/vendor/github.com/rabbitmq/amqp091-go/doc.go b/vendor/github.com/rabbitmq/amqp091-go/doc.go index 8cb0b64f..461173fc 100644 --- a/vendor/github.com/rabbitmq/amqp091-go/doc.go +++ b/vendor/github.com/rabbitmq/amqp091-go/doc.go @@ -95,12 +95,11 @@ prior to calling [Channel.PublishWithContext] or [Channel.Consume]. When Dial encounters an amqps:// scheme, it will use the zero value of a tls.Config. This will only perform server certificate and host verification. -Use DialTLS when you wish to provide a client certificate (recommended), -include a private certificate authority's certificate in the cert chain for -server validity, or run insecure by not verifying the server certificate dial -your own connection. DialTLS will use the provided tls.Config when it -encounters an amqps:// scheme and will dial a plain connection when it -encounters an amqp:// scheme. +Use DialTLS when you wish to provide a client certificate (recommended), include +a private certificate authority's certificate in the cert chain for server +validity, or run insecure by not verifying the server certificate. DialTLS will +use the provided tls.Config when it encounters an amqps:// scheme and will dial +a plain connection when it encounters an amqp:// scheme. SSL/TLS in RabbitMQ is documented here: http://www.rabbitmq.com/ssl.html @@ -110,17 +109,18 @@ In order to be notified when a connection or channel gets closed, both structures offer the possibility to register channels using [Channel.NotifyClose] and [Connection.NotifyClose] functions: - notifyConnCloseCh := conn.NotifyClose(make(chan *amqp.Error)) + notifyConnCloseCh := conn.NotifyClose(make(chan *amqp.Error, 1)) No errors will be sent in case of a graceful connection close. In case of a non-graceful closure due to e.g. network issue, or forced connection closure from the Management UI, the error will be notified synchronously by the library. -The error is sent synchronously to the channel, so that the flow will wait until -the receiver consumes from the channel. To avoid deadlocks in the library, it is -necessary to consume from the channels. This could be done inside a -different goroutine with a select listening on the two channels inside a for -loop like: +The library sends to notification channels just once. After sending a +notification to all channels, the library closes all registered notification +channels. After receiving a notification, the application should create and +register a new channel. To avoid deadlocks in the library, it is necessary to +consume from the channels. This could be done inside a different goroutine with +a select listening on the two channels inside a for loop like: go func() { for notifyConnClose != nil || notifyChanClose != nil { @@ -141,13 +141,8 @@ loop like: } }() -Another approach is to use buffered channels: - - notifyConnCloseCh := conn.NotifyClose(make(chan *amqp.Error, 1)) - -The library sends to notification channels just once. After sending a notification -to all channels, the library closes all registered notification channels. After -receiving a notification, the application should create and register a new channel. +It is strongly recommended to use buffered channels to avoid deadlocks inside +the library. # Best practises for NotifyPublish notifications: diff --git a/vendor/github.com/rabbitmq/amqp091-go/types.go b/vendor/github.com/rabbitmq/amqp091-go/types.go index 8f43a726..1e15ed0a 100644 --- a/vendor/github.com/rabbitmq/amqp091-go/types.go +++ b/vendor/github.com/rabbitmq/amqp091-go/types.go @@ -144,6 +144,19 @@ const ( flagReserved1 = 0x0004 ) +// Expiration. These constants can be used to set a messages expiration TTL. +// They should be viewed as a clarification of the expiration functionality in +// messages and their usage is not enforced by this pkg. +// +// The server requires a string value that is interpreted by the server as +// milliseconds. If no value is set, which translates to the nil value of +// string, the message will never expire by itself. This does not influence queue +// configured TTL configurations. +const ( + NeverExpire string = "" // empty value means never expire + ImmediatelyExpire string = "0" // 0 means immediately expire +) + // Queue captures the current server state of the queue on the server returned // from Channel.QueueDeclare or Channel.QueueInspect. type Queue struct { @@ -162,18 +175,25 @@ type Publishing struct { Headers Table // Properties - ContentType string // MIME content type - ContentEncoding string // MIME content encoding - DeliveryMode uint8 // Transient (0 or 1) or Persistent (2) - Priority uint8 // 0 to 9 - CorrelationId string // correlation identifier - ReplyTo string // address to to reply to (ex: RPC) - Expiration string // message expiration spec - MessageId string // message identifier - Timestamp time.Time // message timestamp - Type string // message type name - UserId string // creating user id - ex: "guest" - AppId string // creating application id + ContentType string // MIME content type + ContentEncoding string // MIME content encoding + DeliveryMode uint8 // Transient (0 or 1) or Persistent (2) + Priority uint8 // 0 to 9 + CorrelationId string // correlation identifier + ReplyTo string // address to to reply to (ex: RPC) + // Expiration represents the message TTL in milliseconds. A value of "0" + // indicates that the message will immediately expire if the message arrives + // at its destination and the message is not directly handled by a consumer + // that currently has the capacatity to do so. If you wish the message to + // not expire on its own, set this value to any ttl value, empty string or + // use the corresponding constants NeverExpire and ImmediatelyExpire. This + // does not influence queue configured TTL values. + Expiration string + MessageId string // message identifier + Timestamp time.Time // message timestamp + Type string // message type name + UserId string // creating user id - ex: "guest" + AppId string // creating application id // The application specific payload of the message Body []byte @@ -533,3 +553,16 @@ type bodyFrame struct { } func (f *bodyFrame) channel() uint16 { return f.ChannelId } + +type heartbeatDuration struct { + value time.Duration + hasValue bool +} + +func newHeartbeatDurationFromSeconds(s int) heartbeatDuration { + v := time.Duration(s) * time.Second + return heartbeatDuration{ + value: v, + hasValue: true, + } +} diff --git a/vendor/github.com/rabbitmq/amqp091-go/uri.go b/vendor/github.com/rabbitmq/amqp091-go/uri.go index 87ef09e6..ddc4b1ad 100644 --- a/vendor/github.com/rabbitmq/amqp091-go/uri.go +++ b/vendor/github.com/rabbitmq/amqp091-go/uri.go @@ -7,6 +7,7 @@ package amqp091 import ( "errors" + "fmt" "net" "net/url" "strconv" @@ -32,16 +33,20 @@ var defaultURI = URI{ // URI represents a parsed AMQP URI string. type URI struct { - Scheme string - Host string - Port int - Username string - Password string - Vhost string - CertFile string // client TLS auth - path to certificate (PEM) - CACertFile string // client TLS auth - path to CA certificate (PEM) - KeyFile string // client TLS auth - path to private key (PEM) - ServerName string // client TLS auth - server name + Scheme string + Host string + Port int + Username string + Password string + Vhost string + CertFile string // client TLS auth - path to certificate (PEM) + CACertFile string // client TLS auth - path to CA certificate (PEM) + KeyFile string // client TLS auth - path to private key (PEM) + ServerName string // client TLS auth - server name + AuthMechanism []string + Heartbeat heartbeatDuration + ConnectionTimeout int + ChannelMax uint16 } // ParseURI attempts to parse the given AMQP URI according to the spec. @@ -62,6 +67,10 @@ type URI struct { // keyfile: // cacertfile: // server_name_indication: +// auth_mechanism: +// heartbeat: +// connection_timeout: +// channel_max: // // If cacertfile is not provided, system CA certificates will be used. // Mutual TLS (client auth) will be enabled only in case keyfile AND certfile provided. @@ -134,6 +143,31 @@ func ParseURI(uri string) (URI, error) { builder.KeyFile = params.Get("keyfile") builder.CACertFile = params.Get("cacertfile") builder.ServerName = params.Get("server_name_indication") + builder.AuthMechanism = params["auth_mechanism"] + + if params.Has("heartbeat") { + value, err := strconv.Atoi(params.Get("heartbeat")) + if err != nil { + return builder, fmt.Errorf("heartbeat is not an integer: %v", err) + } + builder.Heartbeat = newHeartbeatDurationFromSeconds(value) + } + + if params.Has("connection_timeout") { + value, err := strconv.Atoi(params.Get("connection_timeout")) + if err != nil { + return builder, fmt.Errorf("connection_timeout is not an integer: %v", err) + } + builder.ConnectionTimeout = value + } + + if params.Has("channel_max") { + value, err := strconv.ParseUint(params.Get("channel_max"), 10, 16) + if err != nil { + return builder, fmt.Errorf("connection_timeout is not an integer: %v", err) + } + builder.ChannelMax = uint16(value) + } return builder, nil } @@ -192,5 +226,29 @@ func (uri URI) String() string { authority.Path = "/" } + if uri.CertFile != "" || uri.KeyFile != "" || uri.CACertFile != "" || uri.ServerName != "" { + rawQuery := strings.Builder{} + if uri.CertFile != "" { + rawQuery.WriteString("certfile=") + rawQuery.WriteString(uri.CertFile) + rawQuery.WriteRune('&') + } + if uri.KeyFile != "" { + rawQuery.WriteString("keyfile=") + rawQuery.WriteString(uri.KeyFile) + rawQuery.WriteRune('&') + } + if uri.CACertFile != "" { + rawQuery.WriteString("cacertfile=") + rawQuery.WriteString(uri.CACertFile) + rawQuery.WriteRune('&') + } + if uri.ServerName != "" { + rawQuery.WriteString("server_name_indication=") + rawQuery.WriteString(uri.ServerName) + } + authority.RawQuery = rawQuery.String() + } + return authority.String() } diff --git a/vendor/modules.txt b/vendor/modules.txt index 5ebd71e0..ad4b81d1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -13,7 +13,7 @@ github.com/dlmiddlecote/sqlstats # github.com/go-gorp/gorp/v3 v3.1.0 ## explicit; go 1.18 github.com/go-gorp/gorp/v3 -# github.com/gofrs/uuid/v5 v5.1.0 +# github.com/gofrs/uuid/v5 v5.2.0 ## explicit; go 1.19 github.com/gofrs/uuid/v5 # github.com/golang-migrate/migrate/v4 v4.17.1 @@ -110,8 +110,8 @@ github.com/prometheus/common/model github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/rabbitmq/amqp091-go v1.9.0 -## explicit; go 1.16 +# github.com/rabbitmq/amqp091-go v1.10.0 +## explicit; go 1.20 github.com/rabbitmq/amqp091-go # github.com/rs/cors v1.11.0 ## explicit; go 1.13 @@ -122,7 +122,7 @@ github.com/rs/cors/internal github.com/sapcc/go-api-declarations/bininfo github.com/sapcc/go-api-declarations/cadf github.com/sapcc/go-api-declarations/castellum -# github.com/sapcc/go-bits v0.0.0-20240510084529-cd25c4e3bda0 +# github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce ## explicit; go 1.22 github.com/sapcc/go-bits/assert github.com/sapcc/go-bits/audittools