Skip to content

Commit

Permalink
Start migration to github.com/ugorji/go/
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Feb 10, 2016
1 parent 1e45d49 commit c9f1a2b
Show file tree
Hide file tree
Showing 3 changed files with 5,051 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/PuerkitoBio/ghost/handlers"
"github.com/gorilla/mux"
"github.com/pquerna/ffjson/ffjson"
"github.com/ugorji/go/codec"

"github.com/weaveworks/scope/common/hostname"
"github.com/weaveworks/scope/common/xfer"
Expand All @@ -22,6 +22,7 @@ var (

// UniqueID - set at runtime.
UniqueID = "0"
h codec.JsonHandle
)

// URLMatcher uses request.RequestURI (the raw, unparsed request) to attempt
Expand Down Expand Up @@ -134,7 +135,7 @@ func RegisterReportPostHandler(a Adder, router *mux.Router) {
decoder := gob.NewDecoder(reader).Decode
if strings.HasPrefix(r.Header.Get("Content-Type"), "application/json") {
decoder = func(i interface{}) error {
return ffjson.NewDecoder().DecodeReader(reader, i)
return codec.NewDecoder(reader, &h).Decode(i)
}
}
if err := decoder(&rpt); err != nil {
Expand Down
6 changes: 4 additions & 2 deletions probe/appclient/report_publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package appclient
import (
"bytes"
"compress/gzip"
"github.com/pquerna/ffjson/ffjson"
"github.com/ugorji/go/codec"

"github.com/weaveworks/scope/report"
)

var h codec.JsonHandle

// A ReportPublisher uses a buffer pool to serialise reports, which it
// then passes to a publisher
type ReportPublisher struct {
Expand All @@ -25,7 +27,7 @@ func NewReportPublisher(publisher Publisher) *ReportPublisher {
func (p *ReportPublisher) Publish(r report.Report) error {
buf := &bytes.Buffer{}
gzwriter := gzip.NewWriter(buf)
if err := ffjson.NewEncoder(gzwriter).Encode(r); err != nil {
if err := codec.NewEncoder(gzwriter, &h).Encode(r); err != nil {
return err
}
gzwriter.Close() // otherwise the content won't get flushed to the output stream
Expand Down
Loading

0 comments on commit c9f1a2b

Please sign in to comment.