Skip to content

Commit

Permalink
Merge pull request #18 from houseofcat/release/v2.1.2
Browse files Browse the repository at this point in the history
Cleaning, deps update.
  • Loading branch information
houseofcat authored Aug 24, 2021
2 parents 110270e + dc0561c commit 4e77861
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 49 deletions.
15 changes: 0 additions & 15 deletions v2/.vscode/launch.json

This file was deleted.

13 changes: 6 additions & 7 deletions v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
module github.com/houseofcat/turbocookedrabbit/v2

go 1.15
go 1.16

require (
github.com/Workiva/go-datastructures v1.0.53
github.com/fortytw2/leaktest v1.3.0
github.com/google/uuid v1.2.0
github.com/json-iterator/go v1.1.10
github.com/klauspost/compress v1.11.13
github.com/google/uuid v1.3.0
github.com/json-iterator/go v1.1.11
github.com/klauspost/compress v1.13.4
github.com/kr/text v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
26 changes: 14 additions & 12 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/klauspost/compress v1.11.13 h1:eSvu8Tmq6j2psUJqJrLcWH6K3w5Dwc+qipbaA6eVEN4=
github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s=
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -25,8 +27,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU=
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc h1:Ak86L+yDSOzKFa7WM5bf5itSOo1e3Xh8bm5YCMUXIjQ=
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -42,8 +44,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand All @@ -55,8 +57,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
11 changes: 6 additions & 5 deletions v2/pkg/tcr/channelhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/streadway/amqp"
)

// ChannelHost is an internal representation of amqp.Connection.
// ChannelHost is an internal representation of amqp.Channel.
type ChannelHost struct {
Channel *amqp.Channel
ID uint64
Expand All @@ -20,7 +20,7 @@ type ChannelHost struct {
chanLock *sync.Mutex
}

// NewChannelHost creates a simple ConnectionHost wrapper for management by end-user developer.
// NewChannelHost creates a simple ChannelHost wrapper for management by end-user developer.
func NewChannelHost(
connHost *ConnectionHost,
id uint64,
Expand Down Expand Up @@ -89,17 +89,18 @@ func (ch *ChannelHost) FlushConfirms() {
return
}

// Some weird use case where the Channel is being flooded with confirms after connection disrupt
// Some weird use case where the Channel is being flooded with confirms after connection disruption
// It lead to an infinite loop when this method was called.
select {
case <-ch.Confirmations:
return // did not used to be a return, leaving code as is for future revisit
return // return prevents the infinite loop here
default:
return
}
}
}

// PauseForFlowControl allows you to wait till sleep while receiving flow control messages.
// PauseForFlowControl allows you to wait and sleep while receiving flow control messages.
func (ch *ChannelHost) PauseForFlowControl() {

ch.connHost.PauseOnFlowControl()
Expand Down
4 changes: 2 additions & 2 deletions v2/pkg/tcr/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func CompressWithZstd(data []byte, buffer *bytes.Buffer) error {
return zstdWriter.Close()
}

// DecompressWithZstd uses an external dependency for Zstd to decompress data and places data in the supplied buffer.
// DecompressWithZstd uses an external dependency for Zstd to decompress data and replaces the supplied buffer with a new buffer with data in it.
func DecompressWithZstd(buffer *bytes.Buffer) error {

zstdReader, err := zstd.NewReader(buffer)
Expand Down Expand Up @@ -67,7 +67,7 @@ func CompressWithGzip(data []byte, buffer *bytes.Buffer) error {
return nil
}

// DecompressWithGzip uses the standard Gzip Reader to decompress data and places data in the supplied buffer.
// DecompressWithGzip uses the standard Gzip Reader to decompress data and replaces the supplied buffer with a new buffer with data in it.
func DecompressWithGzip(buffer *bytes.Buffer) error {

gzipReader, err := gzip.NewReader(buffer)
Expand Down
1 change: 1 addition & 0 deletions v2/pkg/tcr/connectionhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (ch *ConnectionHost) Connect() bool {
}

// PauseOnFlowControl allows you to wait and sleep while receiving flow control messages.
// Sleeps for one second, repeatedly until the blocking has stopped.
func (ch *ConnectionHost) PauseOnFlowControl() {

ch.connLock.Lock()
Expand Down
9 changes: 3 additions & 6 deletions v2/pkg/tcr/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
jsoniter "github.com/json-iterator/go"
)

var json = jsoniter.ConfigFastest

const (
// GzipCompressionType helps identify which compression/decompression to use.
GzipCompressionType = "gzip"
Expand All @@ -28,7 +30,6 @@ func ConvertJSONFileToConfig(fileNamePath string) (*RabbitSeasoning, error) {
}

config := &RabbitSeasoning{}
var json = jsoniter.ConfigFastest
err = json.Unmarshal(byteValue, config)

return config, err
Expand All @@ -43,7 +44,7 @@ func ConvertJSONFileToTopologyConfig(fileNamePath string) (*TopologyConfig, erro
}

config := &TopologyConfig{}
var json = jsoniter.ConfigFastest

err = json.Unmarshal(byteValue, config)

return config, err
Expand All @@ -52,7 +53,6 @@ func ConvertJSONFileToTopologyConfig(fileNamePath string) (*TopologyConfig, erro
// ReadWrappedBodyFromJSONBytes simply read the bytes as a Letter.
func ReadWrappedBodyFromJSONBytes(data []byte) (*WrappedBody, error) {

var json = jsoniter.ConfigFastest
body := &WrappedBody{}
err := json.Unmarshal(data, body)
if err != nil {
Expand All @@ -71,7 +71,6 @@ func ReadJSONFileToInterface(fileNamePath string) (interface{}, error) {
}

var data interface{}
var json = jsoniter.ConfigFastest
err = json.Unmarshal(byteValue, data)

return &data, err
Expand All @@ -83,7 +82,6 @@ func CreatePayload(
compression *CompressionConfig,
encryption *EncryptionConfig) ([]byte, error) {

var json = jsoniter.ConfigFastest
data, err := json.Marshal(&input)
if err != nil {
return nil, err
Expand Down Expand Up @@ -127,7 +125,6 @@ func CreateWrappedPayload(
Body: &ModdedBody{},
}

var json = jsoniter.ConfigFastest
var err error
var innerData []byte
innerData, err = json.Marshal(&input)
Expand Down
2 changes: 0 additions & 2 deletions v2/pkg/tcr/letters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/google/uuid"
jsoniter "github.com/json-iterator/go"
"github.com/streadway/amqp"
)

Expand Down Expand Up @@ -96,7 +95,6 @@ func CreateMockRandomWrappedBodyLetter(queueName string) *Letter {
},
}

var json = jsoniter.ConfigFastest
data, _ := json.Marshal(wrappedBody)

letter := &Letter{
Expand Down

0 comments on commit 4e77861

Please sign in to comment.