Skip to content

GO-5411 rpc encoding with snappy #453

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
17 changes: 17 additions & 0 deletions .nix/mockgen.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ buildGoModule, fetchFromGitHub }:

buildGoModule rec {
pname = "mockgen";
version = "latest";

src = fetchFromGitHub {
owner = "uber-go";
repo = "mock";
rev = "bb4128ea0af2555e8c70f35a6b6375133dce0582";
sha256 = "sha256-I/gy0rXL0DWcfXrkAx21a2xIDaj6w3wrrO7+z8HHMo0=";
};

subPackages = [ "mockgen" ];

vendorHash = "sha256-0OnK5/e0juEYrNJuVkr+tK66btRW/oaHpJSDakB32Bc=";
}
17 changes: 17 additions & 0 deletions .nix/protoc-gen-go-vtproto.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ buildGoModule, fetchFromGitHub }:

buildGoModule rec {
pname = "protoc-gen-go-vtproto";
version = "latest";

src = fetchFromGitHub {
owner = "planetscale";
repo = "vtprotobuf";
rev = "ba97887b0a2597d20399eb70221c99c95520e8c1";
sha256 = "sha256-r4DhjNCZyoxzdJzzh3uNE5LET7xNkUIa2KXYYeuy8PY=";
};

subPackages = [ "cmd/protoc-gen-go-vtproto" ];

vendorHash = "sha256-UMOEePOtOtmm9ShQy5LXcEUTv8/SIG9dU7/9vLhrBxQ=";
}
74 changes: 44 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
.PHONY: proto test deps mocks
export GOPRIVATE=github.com/anyproto
export PATH:=deps:$(PATH)

all:
@set -e;
@git config core.hooksPath .githooks;

proto: proto-execute replace-gogo-strings
PROTOC=protoc
PROTOC_GEN_GO=$(shell which protoc-gen-go)
PROTOC_GEN_DRPC=$(shell which protoc-gen-go-drpc)
PROTOC_GEN_VTPROTO=$(shell which protoc-gen-go-vtproto)

proto-execute:
@echo 'Generating protobuf packages (Go)...'
define generate_proto
@echo "Generating Protobuf for directory: $(1)"
$(PROTOC) \
--go_out=. --plugin protoc-gen-go="$(PROTOC_GEN_GO)" \
--go-vtproto_out=. --plugin protoc-gen-go-vtproto="$(PROTOC_GEN_VTPROTO)" \
--go-vtproto_opt=features=marshal+unmarshal+size \
--proto_path=$(1) $(wildcard $(1)/*.proto)
endef

define generate_drpc
@echo "Generating Protobuf for directory: $(1) $(which protoc-gen-go)"
$(PROTOC) \
--go_out=. --plugin protoc-gen-go=$$(which protoc-gen-go) \
--plugin protoc-gen-go-drpc=$(PROTOC_GEN_DRPC) \
--go_opt=$(1) \
--go-vtproto_out=:. --plugin protoc-gen-go-vtproto=$(PROTOC_GEN_VTPROTO) \
--go-vtproto_opt=features=marshal+unmarshal+size \
--go-drpc_out=protolib=github.com/planetscale/vtprotobuf/codec/drpc:. $(wildcard $(2)/*.proto)
endef

proto:
@echo 'Generating protobuf packages (Go)...'
@$(eval P_ACL_RECORDS_PATH_PB := commonspace/object/acl/aclrecordproto)
@$(eval P_ACL_RECORDS_PATH_PB := commonspace/object/acl/aclrecordproto)
@$(eval P_TREE_CHANGES_PATH_PB := commonspace/object/tree/treechangeproto)
@$(eval P_CRYPTO_PATH_PB := util/crypto/cryptoproto)
@$(eval P_ACL_RECORDS := M$(P_ACL_RECORDS_PATH_PB)/protos/aclrecord.proto=github.com/anyproto/any-sync/$(P_ACL_RECORDS_PATH_PB))
@$(eval P_TREE_CHANGES := M$(P_TREE_CHANGES_PATH_PB)/protos/treechange.proto=github.com/anyproto/any-sync/$(P_TREE_CHANGES_PATH_PB))

protoc --gogofaster_out=:. $(P_ACL_RECORDS_PATH_PB)/protos/*.proto
protoc --gogofaster_out=:. $(P_TREE_CHANGES_PATH_PB)/protos/*.proto
protoc --gogofaster_out=:. $(P_CRYPTO_PATH_PB)/protos/*.proto
$(eval PKGMAP := $$(P_TREE_CHANGES),$$(P_ACL_RECORDS))
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonspace/spacesyncproto/protos/*.proto
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonfile/fileproto/protos/*.proto
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. net/streampool/testservice/protos/*.proto
protoc --gogofaster_out=:. net/secureservice/handshake/handshakeproto/protos/*.proto
protoc --gogofaster_out=:. net/rpc/limiter/limiterproto/protos/*.proto
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. coordinator/coordinatorproto/protos/*.proto
protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. consensus/consensusproto/protos/*.proto
protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. identityrepo/identityrepoproto/protos/*.proto
protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. nameservice/nameserviceproto/protos/*.proto
protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. paymentservice/paymentserviceproto/protos/*.proto
$(call generate_proto,$(P_ACL_RECORDS_PATH_PB)/protos)
$(call generate_proto,$(P_TREE_CHANGES_PATH_PB)/protos)
$(call generate_proto,$(P_CRYPTO_PATH_PB)/protos)
$(eval PKGMAP := $$(P_TREE_CHANGES)$(comma)$$(P_ACL_RECORDS))
$(call generate_drpc,$(PKGMAP),commonspace/spacesyncproto/protos)
$(call generate_drpc,$(PKGMAP),commonfile/fileproto/protos)
$(call generate_drpc,$(PKGMAP),net/streampool/testservice/protos)

$(call generate_drpc,,net/secureservice/handshake/handshakeproto/protos)
$(call generate_drpc,,net/rpc/limiter/limiterproto/protos)
$(call generate_drpc,$(PKGMAP),coordinator/coordinatorproto/protos)
$(call generate_drpc,,consensus/consensusproto/protos)
$(call generate_drpc,,identityrepo/identityrepoproto/protos)
$(call generate_drpc,,nameservice/nameserviceproto/protos)
$(call generate_drpc,,paymentservice/paymentserviceproto/protos)


mocks:
echo 'Generating mocks...'
go build -o deps go.uber.org/mock/mockgen
PATH=$(CURDIR)/deps:$(PATH) go generate ./...

deps:
go mod download
go build -o deps storj.io/drpc/cmd/protoc-gen-go-drpc
go build -o deps github.com/anyproto/protobuf/protoc-gen-gogofaster
go generate ./...

test:
go test ./... --cover

replace-gogo-strings:
@echo "Replacing 'github.com/gogo/protobuf' with 'github.com/anyproto/protobuf' in all files recursively..."
LC_CTYPE=C LANG=C find . -type f -name "*.go" | xargs sed -i '' "s|github.com/gogo/protobuf|github.com/anyproto/protobuf|g"
go test ./... --cover
10 changes: 6 additions & 4 deletions accountservice/mock_accountservice/mock_accountservice.go

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

74 changes: 38 additions & 36 deletions acl/mock_acl/mock_acl.go

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

Loading
Loading