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

jsonpatch is really slow and we shouldn't need to merge if there is no default. #4071

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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 adapters/relevantdigital/relevantdigital.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/prebid/prebid-server/v3/macros"
"github.com/prebid/prebid-server/v3/openrtb_ext"
"github.com/prebid/prebid-server/v3/util/jsonutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)

type adapter struct {
Expand Down
2 changes: 1 addition & 1 deletion adservertargeting/respdataprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/openrtb_ext"
"github.com/prebid/prebid-server/v3/util/jsonutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)

const MaxKeyLength = 20
Expand Down
2 changes: 1 addition & 1 deletion endpoints/openrtb2/amp_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/prebid/prebid-server/v3/hooks/hookexecution"
"github.com/prebid/prebid-server/v3/ortb"
"github.com/prebid/prebid-server/v3/util/uuidutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

accountService "github.com/prebid/prebid-server/v3/account"
"github.com/prebid/prebid-server/v3/amp"
Expand Down
2 changes: 1 addition & 1 deletion endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/prebid/prebid-server/v3/privacysandbox"
"github.com/prebid/prebid-server/v3/schain"
"golang.org/x/net/publicsuffix"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

accountService "github.com/prebid/prebid-server/v3/account"
"github.com/prebid/prebid-server/v3/analytics"
Expand Down
2 changes: 1 addition & 1 deletion endpoints/openrtb2/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/prebid/prebid-server/v3/util/iputil"
"github.com/prebid/prebid-server/v3/util/jsonutil"
"github.com/prebid/prebid-server/v3/util/uuidutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)

// In this file we define:
Expand Down
2 changes: 1 addition & 1 deletion endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/prebid/prebid-server/v3/hooks/hookexecution"
"github.com/prebid/prebid-server/v3/ortb"
"github.com/prebid/prebid-server/v3/privacy"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

accountService "github.com/prebid/prebid-server/v3/account"
"github.com/prebid/prebid-server/v3/analytics"
Expand Down
2 changes: 1 addition & 1 deletion exchange/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/prebid/prebid-server/v3/exchange/entities"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

"github.com/prebid/prebid-server/v3/analytics"
"github.com/prebid/prebid-server/v3/config"
Expand Down
2 changes: 1 addition & 1 deletion exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"github.com/prebid/prebid-server/v3/util/ptrutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)

func TestNewExchange(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion firstpartydata/first_party_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/prebid/openrtb/v20/openrtb2"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

"github.com/prebid/prebid-server/v3/errortypes"
"github.com/prebid/prebid-server/v3/openrtb_ext"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
golang.org/x/net v0.23.0
golang.org/x/text v0.21.0
google.golang.org/grpc v1.56.3
gopkg.in/evanphx/json-patch.v4 v4.12.0
gopkg.in/evanphx/json-patch.v5 v5.9.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/evanphx/json-patch.v5 v5.9.0 h1:hx1VU2SGj4F8r9b8GUwJLdc8DNO8sy79ZGui0G05GLo=
gopkg.in/evanphx/json-patch.v5 v5.9.0/go.mod h1:/kvTRh1TVm5wuM6OkHxqXtE/1nUZZpihg29RtuIyfvk=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4=
Expand Down
2 changes: 1 addition & 1 deletion hooks/hookexecution/enricher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/config"
"github.com/prebid/prebid-server/v3/util/jsonutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)

const (
Expand Down
5 changes: 4 additions & 1 deletion stored_requests/backends/file_fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/prebid/prebid-server/v3/stored_requests"
"github.com/prebid/prebid-server/v3/util/jsonutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)

// NewFileFetcher _immediately_ loads stored request data from local files.
Expand Down Expand Up @@ -60,6 +60,9 @@ func (fetcher *eagerFetcher) FetchAccount(ctx context.Context, accountDefaultsJS
}}
}

if accountDefaultsJSON == nil {
return accountJSON, nil
}
completeJSON, err := jsonpatch.MergePatch(accountDefaultsJSON, accountJSON)
if err != nil {
return nil, []error{err}
Expand Down
4 changes: 4 additions & 0 deletions stored_requests/backends/file_fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func TestAccountFetcher(t *testing.T) {
assertErrorCount(t, 0, errs)
assert.JSONEq(t, `{"disabled":false, "events_enabled":true, "id":"valid" }`, string(account))

account, errs = fetcher.FetchAccount(context.Background(), nil, "valid")
assertErrorCount(t, 0, errs)
assert.JSONEq(t, `{"disabled":false, "id":"valid" }`, string(account))

_, errs = fetcher.FetchAccount(context.Background(), json.RawMessage(`{"events_enabled":true}`), "nonexistent")
assertErrorCount(t, 1, errs)
assert.Error(t, errs[0])
Expand Down
5 changes: 4 additions & 1 deletion stored_requests/backends/http_fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/prebid/prebid-server/v3/stored_requests"
"github.com/prebid/prebid-server/v3/util/jsonutil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

"github.com/golang/glog"
"golang.org/x/net/context/ctxhttp"
Expand Down Expand Up @@ -164,6 +164,9 @@ func (fetcher *HttpFetcher) FetchAccount(ctx context.Context, accountDefaultsJSO
DataType: "Account",
}}
}
if accountDefaultsJSON == nil {
return accountJSON, nil
}
completeJSON, err := jsonpatch.MergePatch(accountDefaultsJSON, accountJSON)
if err != nil {
return nil, []error{err}
Expand Down
2 changes: 1 addition & 1 deletion util/jsonutil/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
jsonpatch "gopkg.in/evanphx/json-patch.v5"

"github.com/prebid/prebid-server/v3/errortypes"
)
Expand Down
Loading