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

Implementation of a gRPC transport #538

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ cov:
INTEG_TESTS=yes gocov test github.com/hashicorp/raft | gocov-html > /tmp/coverage.html
open /tmp/coverage.html

.PHONY: proto
proto: proto-tools proto-no-tools

.PHONY: proto-no-tools
proto-no-tools:
buf generate
mog -source './proto/transport/v1/*.pb.go'

.PHONY: proto-tools
proto-tools:
go install github.com/bufbuild/buf/cmd/buf@v1.11.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@$(shell grep google.golang.org/protobuf go.mod | awk '{print $$2}')
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
go install github.com/hashicorp/mog@v0.3.0

.PHONY: test cov integ deps dep-linter lint
14 changes: 14 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/hashicorp/raft
plugins:
- name: go
out: .
opt: paths=source_relative
- name: go-grpc
out: .
opt:
- paths=source_relative
- require_unimplemented_servers=false
17 changes: 17 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v1
lint:
use:
- DEFAULT
except:
# we want to enable our Go packages to have a pb prefix to make goimports more
# intelligently handle fixing up imports and hopefully getting it right.
- PACKAGE_DIRECTORY_MATCH

# if we ever need a v2 we can have a second version with the .v2 version in the package name
- PACKAGE_VERSION_SUFFIX

service_suffix: Service
allow_comment_ignores: true
breaking:
use:
- FILE
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ require (
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878
github.com/hashicorp/go-hclog v0.9.1
github.com/hashicorp/go-msgpack v0.5.5
github.com/stretchr/testify v1.3.0
github.com/stretchr/testify v1.7.0
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
)
145 changes: 144 additions & 1 deletion go.sum

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions proto/transport/v1/common.gen.go

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

15 changes: 15 additions & 0 deletions proto/transport/v1/conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package transportv1

import (
"time"

timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)

func TimeFromProto(t *timestamppb.Timestamp) time.Time {
return t.AsTime()
}

func TimeToProto(t time.Time) *timestamppb.Timestamp {
return timestamppb.New(t)
}
216 changes: 216 additions & 0 deletions proto/transport/v1/service.gen.go

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