Skip to content

Commit 2a1af4d

Browse files
authored
Use json-iterator instead of encoding/json (bfenetworks#610)
1 parent 0778b72 commit 2a1af4d

File tree

43 files changed

+274
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+274
-44
lines changed

bfe_balance/bal_gslb/bal_gslb_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package bal_gslb
1616

1717
import (
18-
"encoding/json"
1918
"io/ioutil"
2019
"net"
2120
"testing"
@@ -27,6 +26,7 @@ import (
2726
"github.com/bfenetworks/bfe/bfe_config/bfe_cluster_conf/cluster_table_conf"
2827
"github.com/bfenetworks/bfe/bfe_config/bfe_cluster_conf/gslb_conf"
2928
"github.com/bfenetworks/bfe/bfe_http"
29+
"github.com/bfenetworks/bfe/bfe_util/json"
3030
)
3131

3232
func loadJson(path string, v interface{}) error {

bfe_balance/bal_slb/bal_rr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package bal_slb
1616

1717
import (
18-
"encoding/json"
1918
"fmt"
2019
"math/rand"
2120
"reflect"
@@ -25,6 +24,7 @@ import (
2524
import (
2625
"github.com/bfenetworks/bfe/bfe_balance/backend"
2726
"github.com/bfenetworks/bfe/bfe_config/bfe_cluster_conf/cluster_table_conf"
27+
"github.com/bfenetworks/bfe/bfe_util/json"
2828
)
2929

3030
func populateBackend(name, addr string, port int, avail bool) *backend.BfeBackend {

bfe_basic/action/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ package action
1616

1717
import (
1818
"bytes"
19-
"encoding/json"
2019
"fmt"
2120
"strings"
2221
)
2322

2423
import (
2524
"github.com/bfenetworks/bfe/bfe_basic"
25+
"github.com/bfenetworks/bfe/bfe_util/json"
2626
)
2727

2828
const (

bfe_config/bfe_cluster_conf/cluster_conf/cluster_conf_load.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
import (
27-
jsoniter "github.com/json-iterator/go"
27+
"github.com/bfenetworks/bfe/bfe_util/json"
2828
)
2929

3030
// RetryLevels
@@ -493,7 +493,6 @@ func (conf *BfeClusterConf) LoadAndCheck(filename string) (string, error) {
493493
}
494494

495495
/* decode the file */
496-
json := jsoniter.ConfigCompatibleWithStandardLibrary
497496
decoder := json.NewDecoder(file)
498497
defer file.Close()
499498

bfe_config/bfe_cluster_conf/cluster_table_conf/cluster_table_load.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
import (
30-
jsoniter "github.com/json-iterator/go"
30+
"github.com/bfenetworks/bfe/bfe_util/json"
3131
)
3232

3333
// BackendConf is conf of backend
@@ -225,7 +225,6 @@ func ClusterTableLoad(filename string) (ClusterTableConf, error) {
225225
}
226226

227227
/* decode the file */
228-
json := jsoniter.ConfigCompatibleWithStandardLibrary
229228
decoder := json.NewDecoder(file)
230229

231230
err2 := decoder.Decode(&config)
@@ -247,7 +246,6 @@ func ClusterTableLoad(filename string) (ClusterTableConf, error) {
247246
// ClusterTableDump dumps conf to file
248247
func ClusterTableDump(conf ClusterTableConf, filename string) error {
249248
// marshal to json
250-
json := jsoniter.ConfigCompatibleWithStandardLibrary
251249
confJson, err := json.Marshal(conf)
252250
if err != nil {
253251
return err

bfe_config/bfe_cluster_conf/gslb_conf/gslb_conf_load.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
import (
27-
jsoniter "github.com/json-iterator/go"
27+
"github.com/bfenetworks/bfe/bfe_util/json"
2828
)
2929

3030
var (
@@ -163,7 +163,6 @@ func GslbConfLoad(filename string) (GslbConf, error) {
163163
}
164164

165165
/* decode the file */
166-
json := jsoniter.ConfigCompatibleWithStandardLibrary
167166
decoder := json.NewDecoder(file)
168167
err2 := decoder.Decode(&config)
169168
file.Close()

bfe_config/bfe_route_conf/host_rule_conf/host_table_load.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
package host_rule_conf
1818

1919
import (
20-
"encoding/json"
2120
"errors"
2221
"fmt"
2322
"os"
2423
)
2524

25+
import (
26+
"github.com/bfenetworks/bfe/bfe_util/json"
27+
)
28+
2629
type HostnameList []string // list of hostname
2730
type HostTagList []string // list of host-tag
2831

bfe_config/bfe_route_conf/route_rule_conf/route_table_load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
package route_rule_conf
1818

1919
import (
20-
"encoding/json"
2120
"errors"
2221
"fmt"
2322
"os"
2423
)
2524

2625
import (
2726
"github.com/bfenetworks/bfe/bfe_basic/condition"
27+
"github.com/bfenetworks/bfe/bfe_util/json"
2828
)
2929

3030
// RouteRule is composed by a condition and cluster to serve

bfe_config/bfe_route_conf/vip_rule_conf/vip_table_load.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
package vip_rule_conf
1818

1919
import (
20-
"encoding/json"
2120
"errors"
2221
"fmt"
2322
"net"
2423
"os"
2524
)
2625

26+
import (
27+
"github.com/bfenetworks/bfe/bfe_util/json"
28+
)
29+
2730
type VipList []string // list of vips
2831

2932
type Product2Vip map[string]VipList // product => vip list

bfe_config/bfe_tls_conf/server_cert_conf/server_cert_conf_load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package server_cert_conf
1616

1717
import (
1818
"crypto/x509"
19-
"encoding/json"
2019
"fmt"
2120
"io/ioutil"
2221
"os"
@@ -30,6 +29,7 @@ import (
3029
import (
3130
"github.com/bfenetworks/bfe/bfe_tls"
3231
"github.com/bfenetworks/bfe/bfe_util"
32+
"github.com/bfenetworks/bfe/bfe_util/json"
3333
)
3434

3535
const (

0 commit comments

Comments
 (0)