Skip to content

Commit

Permalink
Use google.golang.org/protobuf instead of github.com/gogo/protobuf
Browse files Browse the repository at this point in the history
This change replaces github.com/gogo/protobuf with
google.golang.org/protobuf, except for the code generators.

All proto-encoded structs are now generated from .proto files,
which include ttrpc.Request and ttrpc.Response.

Signed-off-by: Kazuyoshi Kato <[email protected]>
  • Loading branch information
kzys committed Feb 16, 2022
1 parent 332f4c9 commit 712ed9f
Show file tree
Hide file tree
Showing 20 changed files with 982 additions and 920 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,20 @@ jobs:
sudo chmod -R go+rX /usr/local/include
sudo chmod go+x /usr/local/bin/protoc
- name: Install gogo/protobuf
- name: Install protoc-gen-go
run: |
cd $GOPATH/src
mkdir -p github.com/gogo
cd github.com/gogo
git clone --depth 1 --branch v1.3.2 https://github.com/gogo/protobuf
go install google.golang.org/protobuf/cmd/[email protected]
- name: Build protoc-gen-gogottrpc
- name: Build protoc-gen-go-ttrpc
working-directory: src/github.com/containerd/ttrpc
run: |
go build ./cmd/protoc-gen-gogottrpc
go build ./cmd/protoc-gen-go-ttrpc
- name: Run Protobuild
working-directory: src/github.com/containerd/ttrpc
run: |
export PATH=$GOPATH/bin:$PWD:$PATH
go install github.com/containerd/protobuild@7e5ee24bc1f70e9e289fef15e2631eb3491320bf
cd example
protobuild
(cd example && protobuild)
git diff --exit-code
19 changes: 19 additions & 0 deletions Protobuild.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version = "2"
generators = ["go"]

# Control protoc include paths. Below are usually some good defaults, but feel
# free to try it without them if it works for your project.
[includes]
# Include paths that will be added before all others. Typically, you want to
# treat the root of the project as an include, but this may not be necessary.
before = ["."]

# Paths that will be added untouched to the end of the includes. We use
# `/usr/local/include` to pickup the common install location of protobuf.
# This is the default.
after = ["/usr/local/include"]

# This section maps protobuf imports to Go packages. These will become
# `-M` directives in the call to the go protobuf generator.
[packages]
"proto/status.proto" = "google.golang.org/genproto/googleapis/rpc/status"
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
"syscall"
"time"

"github.com/gogo/protobuf/proto"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)

// ErrClosed is returned by client methods when the underlying connection is
Expand Down
4 changes: 3 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"testing"
"time"

"github.com/containerd/ttrpc/internal"
)

func TestUserOnCloseWait(t *testing.T) {
Expand All @@ -46,7 +48,7 @@ func TestUserOnCloseWait(t *testing.T) {
}),
)

tp testPayload
tp internal.TestPayload
tclient = newTestingClient(client)
)

Expand Down
2 changes: 1 addition & 1 deletion codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package ttrpc
import (
"fmt"

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

type codec struct{}
Expand Down
17 changes: 2 additions & 15 deletions example/Protobuild.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version = "unstable"
generator = "gogottrpc"
plugins = ["ttrpc"]
version = "2"
generators = ["go", "go-ttrpc"]

# Control protoc include paths. Below are usually some good defaults, but feel
# free to try it without them if it works for your project.
Expand All @@ -9,11 +8,6 @@ plugins = ["ttrpc"]
# treat the root of the project as an include, but this may not be necessary.
# before = ["./protobuf"]

# Paths that should be treated as include roots in relation to the vendor
# directory. These will be calculated with the vendor directory nearest the
# target package.
packages = ["github.com/gogo/protobuf"]

# Paths that will be added untouched to the end of the includes. We use
# `/usr/local/include` to pickup the common install location of protobuf.
# This is the default.
Expand All @@ -22,11 +16,4 @@ plugins = ["ttrpc"]
# This section maps protobuf imports to Go packages. These will become
# `-M` directives in the call to the go protobuf generator.
[packages]
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto"
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types"
"google/rpc/status.proto" = "github.com/containerd/containerd/protobuf/google/rpc"
6 changes: 3 additions & 3 deletions example/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

ttrpc "github.com/containerd/ttrpc"
"github.com/containerd/ttrpc/example"
"github.com/gogo/protobuf/types"
"google.golang.org/protobuf/types/known/emptypb"
)

const socket = "example-ttrpc-server"
Expand Down Expand Up @@ -130,6 +130,6 @@ func (s *exampleServer) Method1(ctx context.Context, r *example.Method1Request)
}, nil
}

func (s *exampleServer) Method2(ctx context.Context, r *example.Method1Request) (*types.Empty, error) {
return &types.Empty{}, nil
func (s *exampleServer) Method2(ctx context.Context, r *example.Method1Request) (*emptypb.Empty, error) {
return &emptypb.Empty{}, nil
}
Loading

0 comments on commit 712ed9f

Please sign in to comment.