mirror of
https://github.com/smallnest/rpcx.git
synced 2025-09-26 20:21:14 +08:00
remove json-iterator to simpify deps
This commit is contained in:
@@ -6,12 +6,12 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
pb "google.golang.org/protobuf/proto"
|
||||
"reflect"
|
||||
|
||||
pb "google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/tinylib/msgp/msgp"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
)
|
||||
@@ -142,20 +142,3 @@ func (c ThriftCodec) Decode(data []byte, i interface{}) error {
|
||||
d.Transport.Close()
|
||||
return d.Read(context.Background(), i.(thrift.TStruct), data)
|
||||
}
|
||||
|
||||
type JSONIterCodec struct{}
|
||||
|
||||
func (c JSONIterCodec) Encode(i interface{}) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
enc := jsoniter.NewEncoder(&buf)
|
||||
enc.SetEscapeHTML(false)
|
||||
err := enc.Encode(i)
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
// Decode decodes an object from slice of bytes.
|
||||
func (c JSONIterCodec) Decode(data []byte, i interface{}) error {
|
||||
d := jsoniter.NewDecoder(bytes.NewBuffer(data))
|
||||
d.UseNumber()
|
||||
return d.Decode(i)
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@@ -23,7 +23,6 @@ require (
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/jamiealquiza/tachymeter v2.0.0+incompatible
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/juju/ratelimit v1.0.2
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/kavu/go_reuseport v1.5.0
|
||||
@@ -66,8 +65,6 @@ require (
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/miekg/dns v1.1.51 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
||||
github.com/peterbourgon/g2s v0.0.0-20140925154142-ec76db4c1ac1 // indirect
|
||||
github.com/philhofer/fwd v1.1.2 // indirect
|
||||
|
5
go.sum
5
go.sum
@@ -149,8 +149,6 @@ github.com/jamiealquiza/tachymeter v2.0.0+incompatible h1:mGiF1DGo8l6vnGT8FXNNcI
|
||||
github.com/jamiealquiza/tachymeter v2.0.0+incompatible/go.mod h1:Ayf6zPZKEnLsc3winWEXJRkTBhdHo58HODAu1oFJkYU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/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/juju/ratelimit v1.0.2 h1:sRxmtRiajbvrcLQT7S+JbqU0ntsb9W2yhSdNN8tWfaI=
|
||||
github.com/juju/ratelimit v1.0.2/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
@@ -201,12 +199,9 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
|
@@ -92,8 +92,6 @@ const (
|
||||
// Thrift
|
||||
// Thrift for payload
|
||||
Thrift
|
||||
// JSONIterCodec for payload
|
||||
JSONIterCodec
|
||||
)
|
||||
|
||||
// Message is the generic type of Request and Response.
|
||||
|
@@ -3,6 +3,7 @@ package reflection
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -12,7 +13,6 @@ import (
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/ChimeraCoder/gojson"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/smallnest/rpcx/log"
|
||||
)
|
||||
|
||||
@@ -21,10 +21,6 @@ var (
|
||||
typeOfContext = reflect.TypeOf((*context.Context)(nil)).Elem()
|
||||
)
|
||||
|
||||
var json = jsoniter.Config{
|
||||
TagKey: "-",
|
||||
}.Froze()
|
||||
|
||||
// ServiceInfo service info.
|
||||
type ServiceInfo struct {
|
||||
Name string
|
||||
|
@@ -42,7 +42,6 @@ var Codecs = map[protocol.SerializeType]codec.Codec{
|
||||
protocol.ProtoBuffer: &codec.PBCodec{},
|
||||
protocol.MsgPack: &codec.MsgpackCodec{},
|
||||
protocol.Thrift: &codec.ThriftCodec{},
|
||||
protocol.JSONIterCodec: &codec.JSONIterCodec{},
|
||||
}
|
||||
|
||||
// RegisterCodec register customized codec.
|
||||
|
Reference in New Issue
Block a user