From e8ff116a0cb55b474fe7f122af4b52e37c3fd6b6 Mon Sep 17 00:00:00 2001 From: Yan Zhu Date: Tue, 12 Sep 2023 02:06:12 +0800 Subject: [PATCH] add drop-in json library adapter Signed-off-by: Yan Zhu --- Makefile | 7 ++-- README.md | 67 ++++++++++++++++++++++++++++++++ cache/cache_test.go | 2 +- cache/doc.go | 2 +- client/api_test_model.go | 4 +- client/client.go | 2 +- client/client_test.go | 2 +- client/doc.go | 38 +++++++++--------- client/monitor_test.go | 2 +- cmd/modelgen/main.go | 2 +- cmd/print_schema/print_schema.go | 2 +- go.mod | 4 ++ go.sum | 5 +++ internal/json/go_json.go | 13 +++++++ internal/json/json.go | 13 +++++++ internal/json/jsoniter.go | 14 +++++++ mapper/info_test.go | 2 +- mapper/mapper.go | 10 +++-- mapper/mapper_test.go | 2 +- model/model.go | 15 +++---- model/model_test.go | 2 +- modelgen/dbmodel.go | 5 +-- modelgen/dbmodel_test.go | 6 +-- modelgen/doc.go | 1 - modelgen/table_test.go | 2 +- ovsdb/bindings_test.go | 2 +- ovsdb/condition.go | 3 +- ovsdb/condition_test.go | 3 +- ovsdb/encoding_test.go | 2 +- ovsdb/map.go | 9 +++-- ovsdb/map_test.go | 3 +- ovsdb/monitor_select.go | 2 +- ovsdb/monitor_select_test.go | 3 +- ovsdb/mutation.go | 3 +- ovsdb/mutation_test.go | 3 +- ovsdb/named_uuid_test.go | 3 +- ovsdb/notation.go | 2 +- ovsdb/notation_test.go | 3 +- ovsdb/row.go | 2 +- ovsdb/rpc_test.go | 3 +- ovsdb/schema.go | 5 ++- ovsdb/schema_test.go | 3 +- ovsdb/serverdb/model.go | 3 +- ovsdb/set.go | 6 ++- ovsdb/set_test.go | 3 +- ovsdb/update3.go | 3 +- ovsdb/uuid.go | 3 +- server/monitor.go | 2 +- server/server.go | 2 +- server/server_test.go | 2 +- test/test_data.go | 2 +- 51 files changed, 219 insertions(+), 85 deletions(-) create mode 100644 internal/json/go_json.go create mode 100644 internal/json/json.go create mode 100644 internal/json/jsoniter.go diff --git a/Makefile b/Makefile index af63e7db..8a709d73 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ OVS_VERSION ?= v2.16.0 +TAG ?= std .PHONY: all all: lint build test integration-test coverage @@ -14,14 +15,14 @@ prebuild: modelgen ovsdb/serverdb/_server.ovsschema example/vswitchd/ovs.ovssche @go generate -v ./... .PHONY: build -build: prebuild +build: prebuild @echo "+ $@" @go build -v ./... .PHONY: test test: prebuild @echo "+ $@" - @go test -race -coverprofile=unit.cov -test.short -timeout 30s -v ./... + @go test -race -coverprofile=unit.cov -tags $(TAG) -test.short -timeout 30s -v ./... .PHONY: integration-test integration-test: @@ -36,7 +37,7 @@ coverage: test integration-test .PHONY: bench bench: install-deps prebuild @echo "+ $@" - @go test -run=XXX -count=3 -bench=. ./... | tee bench.out + @go test -run=XXX -count=3 -tags $(TAG) -bench=. ./... | tee bench.out @benchstat bench.out .PHONY: install-deps diff --git a/README.md b/README.md index f43869a5..cf58a712 100644 --- a/README.md +++ b/README.md @@ -307,6 +307,73 @@ In your application, load the ClientDBModel, connect to the server and start int fmt.Printf("My Router has UUID: %s and %d Ports\n", lr.UUID, len(lr.Ports)) } +## Drop-in json library + +There are two json libraries to use as a drop-in replacement for std json library. +[go-json](https://github.com/goccy/go-json) and [json-iterator](https://github.com/json-iterator/go) + +go build your application with -tags go_json or jsoniter + + $ benchstat bench.out.std bench.out.jsoniter bench.out.go_json + goos: linux + goarch: amd64 + pkg: github.com/ovn-org/libovsdb/ovsdb + cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz + │ bench.out.std │ bench.out.jsoniter │ bench.out.go_json │ + │ sec/op │ sec/op vs base │ sec/op vs base │ + MapMarshalJSON1-4 2.234µ ± ∞ ¹ 1.621µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.289µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapMarshalJSON2-4 3.109µ ± ∞ ¹ 2.283µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.834µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapMarshalJSON3-4 4.165µ ± ∞ ¹ 2.900µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.404µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapMarshalJSON5-4 6.058µ ± ∞ ¹ 4.119µ ± ∞ ¹ ~ (p=0.100 n=3) ² 3.421µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapMarshalJSON8-4 8.978µ ± ∞ ¹ 5.685µ ± ∞ ¹ ~ (p=0.100 n=3) ² 4.912µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapUnmarshalJSON1-4 3.208µ ± ∞ ¹ 2.437µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.944µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapUnmarshalJSON2-4 4.525µ ± ∞ ¹ 3.579µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.659µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapUnmarshalJSON3-4 6.015µ ± ∞ ¹ 4.780µ ± ∞ ¹ ~ (p=0.100 n=3) ² 3.404µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapUnmarshalJSON5-4 9.121µ ± ∞ ¹ 7.061µ ± ∞ ¹ ~ (p=0.100 n=3) ² 4.914µ ± ∞ ¹ ~ (p=0.100 n=3) ² + MapUnmarshalJSON8-4 13.912µ ± ∞ ¹ 10.242µ ± ∞ ¹ ~ (p=0.100 n=3) ² 7.076µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONString1-4 668.7n ± ∞ ¹ 511.9n ± ∞ ¹ ~ (p=0.100 n=3) ² 393.8n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONString2-4 1756.0n ± ∞ ¹ 1243.0n ± ∞ ¹ ~ (p=0.100 n=3) ² 972.6n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONString3-4 1.977µ ± ∞ ¹ 1.320µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.082µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONString5-4 2.463µ ± ∞ ¹ 1.561µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.327µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONString8-4 3.310µ ± ∞ ¹ 1.929µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.647µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONInt1-4 605.4n ± ∞ ¹ 495.1n ± ∞ ¹ ~ (p=0.100 n=3) ² 405.5n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONInt2-4 1.612µ ± ∞ ¹ 1.253µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.057µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONInt3-4 1.766µ ± ∞ ¹ 1.327µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.200µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONInt5-4 2.082µ ± ∞ ¹ 1.560µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.423µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONInt8-4 2.554µ ± ∞ ¹ 1.906µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.772µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONFloat1-4 676.8n ± ∞ ¹ 562.1n ± ∞ ¹ ~ (p=0.100 n=3) ² 489.2n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONFloat2-4 1.599µ ± ∞ ¹ 1.205µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.025µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONFloat3-4 1.761µ ± ∞ ¹ 1.341µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.148µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONFloat5-4 2.090µ ± ∞ ¹ 1.576µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.379µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONFloat8-4 2.543µ ± ∞ ¹ 1.902µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.720µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONUUID1-4 1227.0n ± ∞ ¹ 570.0n ± ∞ ¹ ~ (p=0.100 n=3) ² 485.8n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONUUID2-4 2.875µ ± ∞ ¹ 1.311µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.142µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONUUID3-4 3.594µ ± ∞ ¹ 1.490µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.313µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONUUID5-4 5.184µ ± ∞ ¹ 1.832µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.674µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetMarshalJSONUUID8-4 7.555µ ± ∞ ¹ 2.333µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.252µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONString1-4 848.8n ± ∞ ¹ 769.3n ± ∞ ¹ ~ (p=0.100 n=3) ² 517.0n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONString2-4 2.722µ ± ∞ ¹ 2.270µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.684µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONString3-4 3.264µ ± ∞ ¹ 2.790µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.940µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONString5-4 4.482µ ± ∞ ¹ 3.580µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.414µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONString8-4 5.980µ ± ∞ ¹ 4.519µ ± ∞ ¹ ~ (p=0.100 n=3) ² 3.010µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONInt1-4 741.6n ± ∞ ¹ 942.9n ± ∞ ¹ ~ (p=0.100 n=3) ² 514.6n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONInt2-4 2.394µ ± ∞ ¹ 2.236µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.709µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONInt3-4 2.839µ ± ∞ ¹ 2.667µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.048µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONInt5-4 3.521µ ± ∞ ¹ 3.425µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.497µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONInt8-4 4.383µ ± ∞ ¹ 4.227µ ± ∞ ¹ ~ (p=0.100 n=3) ² 3.066µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONFloat1-4 845.2n ± ∞ ¹ 960.0n ± ∞ ¹ ~ (p=0.100 n=3) ² 541.3n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONFloat2-4 2.606µ ± ∞ ¹ 2.264µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.748µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONFloat3-4 3.141µ ± ∞ ¹ 2.667µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.040µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONFloat5-4 4.118µ ± ∞ ¹ 3.436µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.560µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONFloat8-4 5.149µ ± ∞ ¹ 4.286µ ± ∞ ¹ ~ (p=0.100 n=3) ² 3.141µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONUUID1-4 1802.0n ± ∞ ¹ 879.3n ± ∞ ¹ ~ (p=0.100 n=3) ² 613.5n ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONUUID2-4 5.697µ ± ∞ ¹ 2.503µ ± ∞ ¹ ~ (p=0.100 n=3) ² 1.899µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONUUID3-4 7.469µ ± ∞ ¹ 3.035µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.218µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONUUID5-4 11.604µ ± ∞ ¹ 3.965µ ± ∞ ¹ ~ (p=0.100 n=3) ² 2.987µ ± ∞ ¹ ~ (p=0.100 n=3) ² + SetUnmarshalJSONUUID8-4 17.097µ ± ∞ ¹ 5.168µ ± ∞ ¹ ~ (p=0.100 n=3) ² 3.731µ ± ∞ ¹ ~ (p=0.100 n=3) ² + geomean 2.982µ 2.057µ -31.03% 1.606µ -46.14% + ¹ need >= 6 samples for confidence interval at level 0.95 + ² need >= 4 samples to detect a difference at alpha level 0.05 ## Running the tests diff --git a/cache/cache_test.go b/cache/cache_test.go index abca11d5..646ecf2e 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -1,12 +1,12 @@ package cache import ( - "encoding/json" "fmt" "math/rand" "testing" "github.com/go-logr/logr" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "github.com/ovn-org/libovsdb/test" diff --git a/cache/doc.go b/cache/doc.go index 3b176f27..25f1597e 100644 --- a/cache/doc.go +++ b/cache/doc.go @@ -3,7 +3,7 @@ Package cache provides a cache of model.Model elements that can be used in an OV The cache can be accessed using a simple API: - cache.Table("Open_vSwitch").Row("") + cache.Table("Open_vSwitch").Row("") It implements the ovsdb.NotificationHandler interface such that it can be populated automatically by diff --git a/client/api_test_model.go b/client/api_test_model.go index 36ea476e..7b49e94e 100644 --- a/client/api_test_model.go +++ b/client/api_test_model.go @@ -1,10 +1,10 @@ package client import ( - "encoding/json" "testing" "github.com/ovn-org/libovsdb/cache" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" @@ -128,7 +128,7 @@ func (*testLogicalSwitch) Table() string { return "Logical_Switch" } -//LogicalSwitchPort struct defines an object in Logical_Switch_Port table +// LogicalSwitchPort struct defines an object in Logical_Switch_Port table type testLogicalSwitchPort struct { UUID string `ovsdb:"_uuid"` Up *bool `ovsdb:"up"` diff --git a/client/client.go b/client/client.go index b71da2a8..21c657aa 100644 --- a/client/client.go +++ b/client/client.go @@ -3,7 +3,6 @@ package client import ( "context" "crypto/tls" - "encoding/json" "errors" "fmt" "log" @@ -21,6 +20,7 @@ import ( "github.com/go-logr/logr" "github.com/go-logr/stdr" "github.com/ovn-org/libovsdb/cache" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/mapper" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" diff --git a/client/client_test.go b/client/client_test.go index c8a8148e..ddef14ba 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -2,7 +2,6 @@ package client import ( "context" - "encoding/json" "fmt" "math/rand" "os" @@ -17,6 +16,7 @@ import ( "github.com/google/uuid" "github.com/ovn-org/libovsdb/cache" db "github.com/ovn-org/libovsdb/database" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/mapper" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" diff --git a/client/doc.go b/client/doc.go index 90e409ee..2f1aabba 100644 --- a/client/doc.go +++ b/client/doc.go @@ -4,30 +4,29 @@ Package client connects to, monitors and interacts with OVSDB servers (RFC7047). This package uses structs, that contain the 'ovs' field tag to determine which field goes to which column in the database. We refer to pointers to this structs as Models. Example: - type MyLogicalSwitch struct { - UUID string `ovsdb:"_uuid"` // _uuid tag is mandatory - Name string `ovsdb:"name"` - Ports []string `ovsdb:"ports"` - Config map[string]string `ovsdb:"other_config"` - } + type MyLogicalSwitch struct { + UUID string `ovsdb:"_uuid"` // _uuid tag is mandatory + Name string `ovsdb:"name"` + Ports []string `ovsdb:"ports"` + Config map[string]string `ovsdb:"other_config"` + } Based on these Models a Database Model (see ClientDBModel type) is built to represent the entire OVSDB: - clientDBModel, _ := client.NewClientDBModel("OVN_Northbound", - map[string]client.Model{ - "Logical_Switch": &MyLogicalSwitch{}, - }) - + clientDBModel, _ := client.NewClientDBModel("OVN_Northbound", + map[string]client.Model{ + "Logical_Switch": &MyLogicalSwitch{}, + }) The ClientDBModel represents the entire Database (or the part of it we're interested in). Using it, the libovsdb.client package is able to properly encode and decode OVSDB messages and store them in Model instances. A client instance is created by simply specifying the connection information and the database model: - ovs, _ := client.Connect(context.Background(), clientDBModel) + ovs, _ := client.Connect(context.Background(), clientDBModel) -Main API +# Main API After creating a OvsdbClient using the Connect() function, we can use a number of CRUD-like to interact with the database: @@ -43,7 +42,7 @@ and passed to client.Transact(). Others, such as List() and Get(), interact with the client's internal cache and are able to return Model instances (or a list thereof) directly. -Conditions +# Conditions Some API functions (Create() and Get()), can be run directly. Others, require us to use a ConditionalAPI. The ConditionalAPI injects RFC7047 Conditions into ovsdb Operations as well as @@ -111,7 +110,7 @@ cache element, an operation will be created matching on the "_uuid" column. The quite large depending on the cache size and the provided function. Most likely there is a way to express the same condition using Where() or WhereAll() which will be more efficient. -Get +# Get Get() operation is a simple operation capable of retrieving one Model based on some of its schema indexes. E.g: @@ -119,7 +118,7 @@ Get() operation is a simple operation capable of retrieving one Model based on s err := ovs.Get(ls) fmt.Printf("Name of the switch is: &s", ls.Name) -List +# List List() searches the cache and populates a slice of Models. It can be used directly or using WhereCache() @@ -131,7 +130,7 @@ List() searches the cache and populates a slice of Models. It can be used direct return strings.HasPrefix(ls.Name, "ext_") }).List(lsList) -Create +# Create Create returns a list of operations to create the models provided. E.g: @@ -143,7 +142,7 @@ Update returns a list of operations to update the matching rows to match the val ls := &LogicalSwitch{ExternalIDs: map[string]string {"foo": "bar"}} ops, err := ovs.Where(...).Update(&ls, &ls.ExternalIDs} -Mutate +# Mutate Mutate returns a list of operations needed to mutate the matching rows as described by the list of Mutation objects. E.g: @@ -154,11 +153,10 @@ Mutate returns a list of operations needed to mutate the matching rows as descri Value: map[string]string{"foo":"bar"}, }) -Delete +# Delete Delete returns a list of operations needed to delete the matching rows. E.g: ops, err := ovs.Where(...).Delete() - */ package client diff --git a/client/monitor_test.go b/client/monitor_test.go index 206436a3..319b19aa 100644 --- a/client/monitor_test.go +++ b/client/monitor_test.go @@ -1,9 +1,9 @@ package client import ( - "encoding/json" "testing" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" diff --git a/cmd/modelgen/main.go b/cmd/modelgen/main.go index 59883379..8ae67c5f 100644 --- a/cmd/modelgen/main.go +++ b/cmd/modelgen/main.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "flag" "fmt" "io/ioutil" @@ -9,6 +8,7 @@ import ( "os" "path/filepath" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/modelgen" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/cmd/print_schema/print_schema.go b/cmd/print_schema/print_schema.go index e1b5fe06..4a93350c 100644 --- a/cmd/print_schema/print_schema.go +++ b/cmd/print_schema/print_schema.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "flag" "fmt" "io/ioutil" @@ -10,6 +9,7 @@ import ( "runtime" "runtime/pprof" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/go.mod b/go.mod index bb6ea1f4..7dafe7ba 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,9 @@ require ( github.com/cenkalti/rpc2 v0.0.0-20210604223624-c1acbc6ec984 github.com/go-logr/logr v1.2.2 github.com/go-logr/stdr v1.2.2 + github.com/goccy/go-json v0.10.2 github.com/google/uuid v1.2.0 + github.com/json-iterator/go v1.1.12 github.com/ory/dockertest/v3 v3.9.1 github.com/prometheus/client_golang v1.12.1 github.com/stretchr/testify v1.8.0 @@ -36,6 +38,8 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect github.com/opencontainers/runc v1.1.2 // indirect diff --git a/go.sum b/go.sum index c9427a47..8c0e4d0e 100644 --- a/go.sum +++ b/go.sum @@ -106,6 +106,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -178,6 +180,7 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -203,9 +206,11 @@ github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdx github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= diff --git a/internal/json/go_json.go b/internal/json/go_json.go new file mode 100644 index 00000000..9ede9cf4 --- /dev/null +++ b/internal/json/go_json.go @@ -0,0 +1,13 @@ +//go:build go_json + +package json + +import json "github.com/goccy/go-json" + +var ( + Marshal = json.Marshal + Unmarshal = json.Unmarshal + MarshalIndent = json.MarshalIndent +) + +type RawMessage = json.RawMessage diff --git a/internal/json/json.go b/internal/json/json.go new file mode 100644 index 00000000..5df477a5 --- /dev/null +++ b/internal/json/json.go @@ -0,0 +1,13 @@ +//go:build !jsoniter && !go_json + +package json + +import "encoding/json" + +var ( + Marshal = json.Marshal + Unmarshal = json.Unmarshal + MarshalIndent = json.MarshalIndent +) + +type RawMessage = json.RawMessage diff --git a/internal/json/jsoniter.go b/internal/json/jsoniter.go new file mode 100644 index 00000000..173e048d --- /dev/null +++ b/internal/json/jsoniter.go @@ -0,0 +1,14 @@ +//go:build jsoniter + +package json + +import jsoniter "github.com/json-iterator/go" + +var ( + json = jsoniter.ConfigCompatibleWithStandardLibrary + Marshal = json.Marshal + Unmarshal = json.Unmarshal + MarshalIndent = json.MarshalIndent +) + +type RawMessage = jsoniter.RawMessage diff --git a/mapper/info_test.go b/mapper/info_test.go index cf5ad960..ea554375 100644 --- a/mapper/info_test.go +++ b/mapper/info_test.go @@ -1,10 +1,10 @@ package mapper import ( - "encoding/json" "fmt" "testing" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" ) diff --git a/mapper/mapper.go b/mapper/mapper.go index 5ca7a412..56a0fa2b 100644 --- a/mapper/mapper.go +++ b/mapper/mapper.go @@ -12,12 +12,14 @@ import ( // to what column in the database id through field a field tag. // The tag used is "ovsdb" and has the following structure // 'ovsdb:"${COLUMN_NAME}"' +// // where COLUMN_NAME is the name of the column and must match the schema // -//Example: -// type MyObj struct { -// Name string `ovsdb:"name"` -// } +// Example: +// +// type MyObj struct { +// Name string `ovsdb:"name"` +// } type Mapper struct { Schema ovsdb.DatabaseSchema } diff --git a/mapper/mapper_test.go b/mapper/mapper_test.go index 7a4d40b1..6dccf95b 100644 --- a/mapper/mapper_test.go +++ b/mapper/mapper_test.go @@ -1,10 +1,10 @@ package mapper import ( - "encoding/json" "fmt" "testing" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" ) diff --git a/model/model.go b/model/model.go index c8575f5b..9fa0a141 100644 --- a/model/model.go +++ b/model/model.go @@ -1,10 +1,10 @@ package model import ( - "encoding/json" "fmt" "reflect" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" ) @@ -16,12 +16,13 @@ import ( // The struct may also have non-tagged fields (which will be ignored by the API calls) // The Model interface must be implemented by the pointer to such type // Example: -//type MyLogicalRouter struct { -// UUID string `ovsdb:"_uuid"` -// Name string `ovsdb:"name"` -// ExternalIDs map[string]string `ovsdb:"external_ids"` -// LoadBalancers []string `ovsdb:"load_balancer"` -//} +// +// type MyLogicalRouter struct { +// UUID string `ovsdb:"_uuid"` +// Name string `ovsdb:"name"` +// ExternalIDs map[string]string `ovsdb:"external_ids"` +// LoadBalancers []string `ovsdb:"load_balancer"` +// } type Model interface{} type CloneableModel interface { diff --git a/model/model_test.go b/model/model_test.go index e75a4d45..24e5b7f1 100644 --- a/model/model_test.go +++ b/model/model_test.go @@ -1,11 +1,11 @@ package model import ( - "encoding/json" "fmt" "reflect" "testing" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" ) diff --git a/modelgen/dbmodel.go b/modelgen/dbmodel.go index d3189abb..73a4a434 100644 --- a/modelgen/dbmodel.go +++ b/modelgen/dbmodel.go @@ -1,10 +1,10 @@ package modelgen import ( - "encoding/json" "sort" "text/template" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" ) @@ -29,8 +29,7 @@ func NewDBTemplate() *template.Template { {{- end }} {{- define "preDBDefinitions" }} import ( - "encoding/json" - + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/modelgen/dbmodel_test.go b/modelgen/dbmodel_test.go index bce11b4a..24e61342 100644 --- a/modelgen/dbmodel_test.go +++ b/modelgen/dbmodel_test.go @@ -1,10 +1,11 @@ package modelgen import ( - "encoding/json" "testing" "text/template" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -52,8 +53,7 @@ func TestDbModelTemplate(t *testing.T) { package test import ( - "encoding/json" - + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/modelgen/doc.go b/modelgen/doc.go index 26dd8686..b2a32f53 100644 --- a/modelgen/doc.go +++ b/modelgen/doc.go @@ -2,6 +2,5 @@ Package modelgen provides core functionality to implement Model code generators based on a schema. It allows to create and customize a text/template that can generate the Model types that libovsdb can work with. - */ package modelgen diff --git a/modelgen/table_test.go b/modelgen/table_test.go index 6d4e2711..a3cddddf 100644 --- a/modelgen/table_test.go +++ b/modelgen/table_test.go @@ -1,7 +1,6 @@ package modelgen import ( - "encoding/json" "fmt" "reflect" "testing" @@ -9,6 +8,7 @@ import ( "github.com/google/uuid" "github.com/ovn-org/libovsdb/example/vswitchd" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" diff --git a/ovsdb/bindings_test.go b/ovsdb/bindings_test.go index afac2d06..23d22b60 100644 --- a/ovsdb/bindings_test.go +++ b/ovsdb/bindings_test.go @@ -1,11 +1,11 @@ package ovsdb import ( - "encoding/json" "fmt" "reflect" "testing" + "github.com/ovn-org/libovsdb/internal/json" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/ovsdb/condition.go b/ovsdb/condition.go index 783ac0f5..c52d7416 100644 --- a/ovsdb/condition.go +++ b/ovsdb/condition.go @@ -1,9 +1,10 @@ package ovsdb import ( - "encoding/json" "fmt" "reflect" + + "github.com/ovn-org/libovsdb/internal/json" ) type ConditionFunction string diff --git a/ovsdb/condition_test.go b/ovsdb/condition_test.go index 4eae9cb8..45d1a811 100644 --- a/ovsdb/condition_test.go +++ b/ovsdb/condition_test.go @@ -1,10 +1,11 @@ package ovsdb import ( - "encoding/json" "reflect" "testing" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/stretchr/testify/assert" ) diff --git a/ovsdb/encoding_test.go b/ovsdb/encoding_test.go index 078bebc8..95b8ce56 100644 --- a/ovsdb/encoding_test.go +++ b/ovsdb/encoding_test.go @@ -1,10 +1,10 @@ package ovsdb import ( - "encoding/json" "fmt" "testing" + "github.com/ovn-org/libovsdb/internal/json" "github.com/stretchr/testify/assert" ) diff --git a/ovsdb/map.go b/ovsdb/map.go index 893a9774..452263f5 100644 --- a/ovsdb/map.go +++ b/ovsdb/map.go @@ -1,9 +1,10 @@ package ovsdb import ( - "encoding/json" "fmt" "reflect" + + "github.com/ovn-org/libovsdb/internal/json" ) // OvsMap is the JSON map structure used for OVSDB @@ -47,7 +48,8 @@ func (o *OvsMap) UnmarshalJSON(b []byte) (err error) { case []interface{}: vSet := f[0].([]interface{}) if len(vSet) != 2 || vSet[0] == "map" { - return &json.UnmarshalTypeError{Value: reflect.ValueOf(oMap).String(), Type: reflect.TypeOf(*o)} + return fmt.Errorf("json: cannot unmarshal %s into Go value of type %s", + reflect.ValueOf(oMap).String(), reflect.TypeOf(*o).String()) } goSlice, err := ovsSliceToGoNotation(vSet) if err != nil { @@ -61,7 +63,8 @@ func (o *OvsMap) UnmarshalJSON(b []byte) (err error) { case []interface{}: vSet := f[1].([]interface{}) if len(vSet) != 2 || vSet[0] == "map" { - return &json.UnmarshalTypeError{Value: reflect.ValueOf(oMap).String(), Type: reflect.TypeOf(*o)} + return fmt.Errorf("json: cannot unmarshal %s into Go value of type %s", + reflect.ValueOf(oMap).String(), reflect.TypeOf(*o).String()) } goSlice, err := ovsSliceToGoNotation(vSet) if err != nil { diff --git a/ovsdb/map_test.go b/ovsdb/map_test.go index 16907c64..e779a29a 100644 --- a/ovsdb/map_test.go +++ b/ovsdb/map_test.go @@ -1,8 +1,9 @@ package ovsdb import ( - "encoding/json" "testing" + + "github.com/ovn-org/libovsdb/internal/json" ) func benchmarkMap(m map[string]string, b *testing.B) { diff --git a/ovsdb/monitor_select.go b/ovsdb/monitor_select.go index b97e0628..a068529a 100644 --- a/ovsdb/monitor_select.go +++ b/ovsdb/monitor_select.go @@ -1,6 +1,6 @@ package ovsdb -import "encoding/json" +import "github.com/ovn-org/libovsdb/internal/json" // MonitorSelect represents a monitor select according to RFC7047 type MonitorSelect struct { diff --git a/ovsdb/monitor_select_test.go b/ovsdb/monitor_select_test.go index 8a31ba24..21debddd 100644 --- a/ovsdb/monitor_select_test.go +++ b/ovsdb/monitor_select_test.go @@ -1,9 +1,10 @@ package ovsdb import ( - "encoding/json" "testing" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/stretchr/testify/assert" ) diff --git a/ovsdb/mutation.go b/ovsdb/mutation.go index dc8b0f6d..6989812d 100644 --- a/ovsdb/mutation.go +++ b/ovsdb/mutation.go @@ -1,8 +1,9 @@ package ovsdb import ( - "encoding/json" "fmt" + + "github.com/ovn-org/libovsdb/internal/json" ) type Mutator string diff --git a/ovsdb/mutation_test.go b/ovsdb/mutation_test.go index a70c835b..2640c4c7 100644 --- a/ovsdb/mutation_test.go +++ b/ovsdb/mutation_test.go @@ -1,10 +1,11 @@ package ovsdb import ( - "encoding/json" "reflect" "testing" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/stretchr/testify/assert" ) diff --git a/ovsdb/named_uuid_test.go b/ovsdb/named_uuid_test.go index 78f3f9f6..488cd512 100644 --- a/ovsdb/named_uuid_test.go +++ b/ovsdb/named_uuid_test.go @@ -1,10 +1,11 @@ package ovsdb import ( - "encoding/json" "fmt" "testing" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/ovsdb/notation.go b/ovsdb/notation.go index afad87cd..8c32bc21 100644 --- a/ovsdb/notation.go +++ b/ovsdb/notation.go @@ -1,7 +1,7 @@ package ovsdb import ( - "encoding/json" + "github.com/ovn-org/libovsdb/internal/json" ) const ( diff --git a/ovsdb/notation_test.go b/ovsdb/notation_test.go index c519c69e..248866ab 100644 --- a/ovsdb/notation_test.go +++ b/ovsdb/notation_test.go @@ -1,12 +1,13 @@ package ovsdb import ( - "encoding/json" "fmt" "log" "reflect" "testing" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/ovsdb/row.go b/ovsdb/row.go index 9a253f74..167a262a 100644 --- a/ovsdb/row.go +++ b/ovsdb/row.go @@ -1,6 +1,6 @@ package ovsdb -import "encoding/json" +import "github.com/ovn-org/libovsdb/internal/json" // Row is a table Row according to RFC7047 type Row map[string]interface{} diff --git a/ovsdb/rpc_test.go b/ovsdb/rpc_test.go index c6f338a0..bad37018 100644 --- a/ovsdb/rpc_test.go +++ b/ovsdb/rpc_test.go @@ -1,8 +1,9 @@ package ovsdb import ( - "encoding/json" "testing" + + "github.com/ovn-org/libovsdb/internal/json" ) func TestNewGetSchemaArgs(t *testing.T) { diff --git a/ovsdb/schema.go b/ovsdb/schema.go index cf80aa50..8c3c8d59 100644 --- a/ovsdb/schema.go +++ b/ovsdb/schema.go @@ -1,13 +1,14 @@ package ovsdb import ( - "encoding/json" "fmt" "io" "io/ioutil" "math" "os" "strings" + + "github.com/ovn-org/libovsdb/internal/json" ) // DatabaseSchema is a database schema according to RFC7047 @@ -124,7 +125,7 @@ of this library, we define an ExtendedType that includes all possible column typ atomic fields). */ -//ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set +// ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set type ExtendedType = string // RefType is used to define the possible RefTypes diff --git a/ovsdb/schema_test.go b/ovsdb/schema_test.go index fae25493..e9e0f059 100644 --- a/ovsdb/schema_test.go +++ b/ovsdb/schema_test.go @@ -1,12 +1,13 @@ package ovsdb import ( - "encoding/json" "fmt" "math" "reflect" "testing" + "github.com/ovn-org/libovsdb/internal/json" + "github.com/stretchr/testify/assert" ) diff --git a/ovsdb/serverdb/model.go b/ovsdb/serverdb/model.go index c8e5cec8..9dfc8c80 100644 --- a/ovsdb/serverdb/model.go +++ b/ovsdb/serverdb/model.go @@ -4,8 +4,7 @@ package serverdb import ( - "encoding/json" - + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/ovsdb/set.go b/ovsdb/set.go index ae1ec59a..cb2bb26e 100644 --- a/ovsdb/set.go +++ b/ovsdb/set.go @@ -1,9 +1,10 @@ package ovsdb import ( - "encoding/json" "fmt" "reflect" + + "github.com/ovn-org/libovsdb/internal/json" ) // OvsSet is an OVSDB style set @@ -92,7 +93,8 @@ func (o *OvsSet) UnmarshalJSON(b []byte) (err error) { } if oSet[0] != "set" { // it is a slice, but is not a set - return &json.UnmarshalTypeError{Value: reflect.ValueOf(inter).String(), Type: reflect.TypeOf(*o)} + return fmt.Errorf("json: cannot unmarshal %s into Go value of type %s", + reflect.ValueOf(inter).String(), reflect.TypeOf(*o).String()) } innerSet := oSet[1].([]interface{}) for _, val := range innerSet { diff --git a/ovsdb/set_test.go b/ovsdb/set_test.go index 12857a87..b24b313e 100644 --- a/ovsdb/set_test.go +++ b/ovsdb/set_test.go @@ -1,11 +1,12 @@ package ovsdb import ( - "encoding/json" "fmt" "reflect" "strings" "testing" + + "github.com/ovn-org/libovsdb/internal/json" ) var testUUIDs = []string{ diff --git a/ovsdb/update3.go b/ovsdb/update3.go index a24ce64a..62dabe21 100644 --- a/ovsdb/update3.go +++ b/ovsdb/update3.go @@ -1,8 +1,9 @@ package ovsdb import ( - "encoding/json" "fmt" + + "github.com/ovn-org/libovsdb/internal/json" ) type MonitorCondSinceReply struct { diff --git a/ovsdb/uuid.go b/ovsdb/uuid.go index 6bc46365..84165a12 100644 --- a/ovsdb/uuid.go +++ b/ovsdb/uuid.go @@ -1,9 +1,10 @@ package ovsdb import ( - "encoding/json" "fmt" "regexp" + + "github.com/ovn-org/libovsdb/internal/json" ) var validUUID = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`) diff --git a/server/monitor.go b/server/monitor.go index 2dedf992..d076d87e 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -1,13 +1,13 @@ package server import ( - "encoding/json" "log" "sync" "github.com/cenkalti/rpc2" "github.com/google/uuid" "github.com/ovn-org/libovsdb/database" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/server/server.go b/server/server.go index 0100d766..124f2bee 100644 --- a/server/server.go +++ b/server/server.go @@ -1,7 +1,6 @@ package server import ( - "encoding/json" "errors" "fmt" "log" @@ -15,6 +14,7 @@ import ( "github.com/go-logr/stdr" "github.com/google/uuid" "github.com/ovn-org/libovsdb/database" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" ) diff --git a/server/server_test.go b/server/server_test.go index 36cf4d87..d834195e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -1,11 +1,11 @@ package server import ( - "encoding/json" "testing" "github.com/google/uuid" "github.com/ovn-org/libovsdb/database" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "github.com/stretchr/testify/assert" diff --git a/test/test_data.go b/test/test_data.go index 6be6b8b2..e09e9e39 100644 --- a/test/test_data.go +++ b/test/test_data.go @@ -1,9 +1,9 @@ package test import ( - "encoding/json" "fmt" + "github.com/ovn-org/libovsdb/internal/json" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" )