replaced encoding/json with jsoniter high performance pkg

This commit is contained in:
Philipp Mieden 2019-05-21 10:59:54 +02:00
parent e64b07f6c6
commit 5e44495adc
6 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,6 @@
package client package client
import ( import (
"encoding/json"
"net" "net"
"strconv" "strconv"
"sync" "sync"

View File

@ -2,7 +2,6 @@ package client
import ( import (
"bytes" "bytes"
"encoding/json"
"errors" "errors"
"io/ioutil" "io/ioutil"
"net/http" "net/http"

View File

@ -1,7 +1,6 @@
package client package client
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -11,8 +10,11 @@ import (
"github.com/foomo/contentserver/responses" "github.com/foomo/contentserver/responses"
"github.com/foomo/contentserver/server" "github.com/foomo/contentserver/server"
jsoniter "github.com/json-iterator/go"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary
type serverResponse struct { type serverResponse struct {
Reply interface{} Reply interface{}
} }

View File

@ -1,7 +1,6 @@
package repo package repo
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -10,8 +9,11 @@ import (
"github.com/foomo/contentserver/content" "github.com/foomo/contentserver/content"
"github.com/foomo/contentserver/log" "github.com/foomo/contentserver/log"
jsoniter "github.com/json-iterator/go"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary
func (repo *Repo) updateRoutine() { func (repo *Repo) updateRoutine() {
go func() { go func() {
for newDimension := range repo.updateChannel { for newDimension := range repo.updateChannel {

View File

@ -1,7 +1,6 @@
package server package server
import ( import (
"encoding/json"
"fmt" "fmt"
"time" "time"
@ -10,9 +9,12 @@ import (
"github.com/foomo/contentserver/requests" "github.com/foomo/contentserver/requests"
"github.com/foomo/contentserver/responses" "github.com/foomo/contentserver/responses"
"github.com/foomo/contentserver/status" "github.com/foomo/contentserver/status"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary
func handleRequest(r *repo.Repo, handler Handler, jsonBytes []byte, metrics *status.Metrics) (replyBytes []byte, err error) { func handleRequest(r *repo.Repo, handler Handler, jsonBytes []byte, metrics *status.Metrics) (replyBytes []byte, err error) {
var ( var (

View File

@ -1,13 +1,15 @@
package status package status
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"github.com/foomo/contentserver/log" "github.com/foomo/contentserver/log"
jsoniter "github.com/json-iterator/go"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary
func RunHealthzHandlerListener(address string, serviceName string) { func RunHealthzHandlerListener(address string, serviceName string) {
log.Notice(fmt.Sprintf("starting healthz handler on '%s'" + address)) log.Notice(fmt.Sprintf("starting healthz handler on '%s'" + address))
log.Error(http.ListenAndServe(address, HealthzHandler(serviceName))) log.Error(http.ListenAndServe(address, HealthzHandler(serviceName)))