Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrate fully to protov2 #436

Merged
merged 12 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ test-examples:
generate: generate-proto

get-proto-generators:
go install github.com/golang/protobuf/protoc-gen-go
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0

generate-proto: get-proto-generators ## Generate proto
@echo "# generating proto"
Expand Down
3 changes: 1 addition & 2 deletions datasync/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
package datasync

import (
"github.com/golang/protobuf/proto"

"go.ligato.io/cn-infra/v2/logging"
"go.ligato.io/cn-infra/v2/utils/safeclose"
"google.golang.org/protobuf/proto"
)

// KVProtoWatchers is an adapter that allows multiple
Expand Down
2 changes: 1 addition & 1 deletion datasync/datasync_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"io"
"time"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

// DefaultNotifTimeout defines the default timeout for datasync notification delivery.
Expand Down
2 changes: 1 addition & 1 deletion datasync/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package datasync
import (
"context"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

// Op represents datasync operations.
Expand Down
2 changes: 1 addition & 1 deletion datasync/grpcsync/grpc_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewAdapter(grpcServer *grpc.Server) *Adapter {
base: syncbase.NewRegistry(),
server: grpcServer,
}
msg.RegisterDataMsgServiceServer(grpcServer, &DataMsgServiceServer{adapter})
msg.RegisterDataMsgServiceServer(grpcServer, &DataMsgServiceServer{adapter: adapter})

return adapter
}
Expand Down
1 change: 1 addition & 0 deletions datasync/grpcsync/msgservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewDataMsgServiceServer(adapter *Adapter) *DataMsgServiceServer {
// DataMsgServiceServer is //TODO
type DataMsgServiceServer struct {
adapter *Adapter
msg.UnimplementedDataMsgServiceServer
}

// DataChanges propagates the events in the stream to go channels of registered plugins.
Expand Down
2 changes: 1 addition & 1 deletion datasync/kvdbsync/change_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package kvdbsync
import (
"context"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
"go.ligato.io/cn-infra/v2/datasync/syncbase"
Expand Down
2 changes: 1 addition & 1 deletion datasync/kvdbsync/local/local_proto_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"sync"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
"go.ligato.io/cn-infra/v2/datasync/syncbase"
Expand Down
2 changes: 1 addition & 1 deletion datasync/kvdbsync/plugin_impl_dbsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package kvdbsync
import (
"errors"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
"go.ligato.io/cn-infra/v2/datasync/resync"
Expand Down
2 changes: 1 addition & 1 deletion datasync/msgsync/plugin_impl_msgsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package msgsync
import (
"errors"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
"go.ligato.io/cn-infra/v2/infra"
Expand Down
2 changes: 1 addition & 1 deletion datasync/syncbase/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package syncbase

import (
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
)
Expand Down
2 changes: 1 addition & 1 deletion datasync/syncbase/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package syncbase
import (
"context"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
"go.ligato.io/cn-infra/v2/logging/logrus"
Expand Down
8 changes: 3 additions & 5 deletions datasync/syncbase/kv_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
package syncbase

import (
"bytes"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
)
Expand Down Expand Up @@ -99,7 +97,7 @@ func (kv *KeyValBytes) GetKey() string {

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

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

import (
"bytes"
"context"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"

"go.ligato.io/cn-infra/v2/datasync"
"go.ligato.io/cn-infra/v2/logging/logrus"
)

//go:generate protoc --proto_path=. --go_out=plugins=grpc:. datamsg.proto
//go:generate protoc --proto_path=. --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. datamsg.proto

// NewChangeWatchResp is a constructor.
func NewChangeWatchResp(ctx context.Context, message *DataChangeRequest, callback func(error)) *ChangeEvent {
Expand Down Expand Up @@ -89,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 jsonpb.Unmarshal(bytes.NewReader(ev.message.Content), val) //TODO use contentType...
return protojson.Unmarshal(ev.message.Content, val) //TODO use contentType...
}

// GetPrevValue returns the value before change.
Expand Down
Loading