Skip to content

Commit

Permalink
Merge d41e5f2 into fa934fe
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej-fabry committed Oct 15, 2019
2 parents fa934fe + d41e5f2 commit f5efbdf
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 25 deletions.
5 changes: 3 additions & 2 deletions datasync/syncbase/kv_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package syncbase

import (
"encoding/json"
"bytes"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/ligato/cn-infra/datasync"
)
Expand Down Expand Up @@ -97,7 +98,7 @@ func (kv *KeyValBytes) GetKey() string {

// GetValue returns the value of the pair.
func (kv *KeyValBytes) GetValue(message proto.Message) error {
return json.Unmarshal(kv.value, message)
return jsonpb.Unmarshal(bytes.NewReader(kv.value), message)
}

// GetRevision returns revision associated with the latest change in the key-value pair.
Expand Down
5 changes: 3 additions & 2 deletions datasync/syncbase/msg/change_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package msg

import (
"bytes"
"context"
"encoding/json"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/ligato/cn-infra/datasync"
"github.com/ligato/cn-infra/logging/logrus"
Expand Down Expand Up @@ -87,7 +88,7 @@ func (ev *ChangeWatchResp) GetRevision() int64 {

// GetValue - see the comments in the interface datasync.ChangeEvent.
func (ev *ChangeWatchResp) GetValue(val proto.Message) error {
return json.Unmarshal(ev.message.Content, val) //TODO use contentType...
return jsonpb.Unmarshal(bytes.NewReader(ev.message.Content), val) //TODO use contentType...
}

// GetPrevValue returns the value before change.
Expand Down
2 changes: 1 addition & 1 deletion docker/dev_cn_infra/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz && \
mv go /usr/local && \
rm -f go1.9.2.linux-amd64.tar.gz

# build & install Protobuf & gogo protobuf compiler
# build & install Protobuf & golang protobuf compiler
RUN apt-get install -y make && \
apt-get install -y autoconf automake libtool curl make g++ unzip

Expand Down
2 changes: 2 additions & 0 deletions examples/model/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package etcdexample explains how to generate Golang structures from
// protobuf-formatted data.
package etcdexample

//go:generate protoc --proto_path=. --go_out=. example.proto
147 changes: 127 additions & 20 deletions examples/model/example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5efbdf

Please sign in to comment.