Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix data race and remove oxy v1 #185

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gateway/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
15 changes: 7 additions & 8 deletions gateway/upstreamer/push/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 4 additions & 0 deletions publication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Loading