diff --git a/gateway/errors_test.go b/gateway/errors_test.go index 7ab7576..bd005b4 100644 --- a/gateway/errors_test.go +++ b/gateway/errors_test.go @@ -14,8 +14,8 @@ import ( "github.com/mailgun/multibuf" // nolint:revive // Allow dot imports for readability in tests . "github.com/smartystreets/goconvey/convey" - "github.com/vulcand/oxy/ratelimit" "github.com/vulcand/oxy/v2/connlimit" + "github.com/vulcand/oxy/v2/ratelimit" "go.aporeto.io/elemental" ) diff --git a/gateway/upstreamer/push/notifier_test.go b/gateway/upstreamer/push/notifier_test.go index 2d27a54..c2afc24 100644 --- a/gateway/upstreamer/push/notifier_test.go +++ b/gateway/upstreamer/push/notifier_test.go @@ -83,13 +83,12 @@ func TestNonNotifier(t *testing.T) { So(err, ShouldBeNil) }) - var p *bahamut.Publication - select { - case <-time.After(300 * time.Millisecond): - case p = <-pubCh: - } - Convey("Then the pubsub should have received a push", func() { + var p *bahamut.Publication + select { + case <-time.After(300 * time.Millisecond): + case p = <-pubCh: + } So(p, ShouldNotBeNil) @@ -117,7 +116,7 @@ func TestNonNotifier(t *testing.T) { } So(checked, ShouldEqual, 5) - Convey("Then I wait 1.5sec and I should get another pusb", func() { + Convey("Then I wait 1.5sec and I should get another push", func() { var p *bahamut.Publication select { @@ -253,7 +252,7 @@ func TestPrefixedNotifier(t *testing.T) { So(sping.Status, ShouldEqual, entityStatusHello) So(sping.Prefix, ShouldEqual, "prefix") - Convey("Then I wait 1.5sec and I should get another pusb", func() { + Convey("Then I wait 1.5sec and I should get another push", func() { var p *bahamut.Publication select { diff --git a/go.mod b/go.mod index ea2e0fa..91d56e0 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,6 @@ require ( github.com/shirou/gopsutil/v3 v3.23.1 github.com/smartystreets/goconvey v1.7.2 github.com/valyala/tcplisten v1.0.0 - github.com/vulcand/oxy v1.4.2 github.com/vulcand/oxy/v2 v2.0.0-20221121151423-d5cb734e4467 go.uber.org/zap v1.24.0 golang.org/x/time v0.3.0 diff --git a/go.sum b/go.sum index ded3e9a..bde0baa 100644 --- a/go.sum +++ b/go.sum @@ -805,8 +805,6 @@ github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/vulcand/oxy v1.4.2 h1:KibUVdKrwy7eXR3uHS2pYoZ9dCzKVcgDNHD2jkPZmxU= -github.com/vulcand/oxy v1.4.2/go.mod h1:Yq8OBb0XWU/7nPSglwUH5LS2Pcp4yvad8SVayobZbSo= github.com/vulcand/oxy/v2 v2.0.0-20221121151423-d5cb734e4467 h1:Dbv3KJLgwtDKLpCZzTf1ISeG5ZYudPaLfTdYi4O2dSU= github.com/vulcand/oxy/v2 v2.0.0-20221121151423-d5cb734e4467/go.mod h1:0kOEB8mKzSeGHknF53gTM47UEvQnPoAPnM+58baqn2o= github.com/vulcand/predicate v1.2.0 h1:uFsW1gcnnR7R+QTID+FVcs0sSYlIGntoGOTb3rQJt50= diff --git a/publication.go b/publication.go index de81fdc..4e751a4 100644 --- a/publication.go +++ b/publication.go @@ -83,6 +83,8 @@ func (p *Publication) Encode(o any) error { // EncodeWithEncoding the given object into the publication using the given encoding. func (p *Publication) EncodeWithEncoding(o any, encoding elemental.EncodingType) error { + p.mux.Lock() + defer p.mux.Unlock() data, err := elemental.Encode(encoding, o) if err != nil { @@ -147,6 +149,8 @@ func (p *Publication) Span() opentracing.Span { // Duplicate returns a copy of the publication func (p *Publication) Duplicate() *Publication { + p.mux.Lock() + defer p.mux.Unlock() pub := NewPublication(p.Topic) pub.Data = p.Data