Comments (23)
@cindyzqtnew which version of Go are you using?
Maybe this will work better?
go install storj.io/drpc/cmd/protoc-gen-go-drpc@latest
from drpc.
Ah, to clarify the gogoproto thing, I missed that it also needs a few additional arguments:
protoc --gogo_out=paths=source_relative:. --go-drpc_out=paths=source_relative,protolib=github.com/gogo/protobuf:. service.proto
@egonelbre I see. So whether using official proto or gogo proto is specified by the option in protoc?
from drpc.
This should do the trick:
go get storj.io/drpc/cmd/protoc-gen-go-drpc
The quick-start guide https://storj.github.io/drpc/docs.html does contain the same command below the text you quoted.
from drpc.
This should do the trick:
go get storj.io/drpc/cmd/protoc-gen-go-drpc
The quick-start guide https://storj.github.io/drpc/docs.html does contain the same command below the text you quoted.
@egonelbre I've tried it but it always return the not found error.
go get storj.io/drpc/cmd/protoc-gen-go-drpc
# cd .; git clone -- https://github.com/storj/drpc/cmd/protoc-gen-go-drpc /go_path/src/storj.io/drpc/cmd/protoc-gen-go-drpc
Cloning into '/go_path/src/storj.io/drpc/cmd/protoc-gen-go-drpc'...
remote: Not Found
fatal: repository 'https://github.com/storj/drpc/cmd/protoc-gen-go-drpc/' not found
package storj.io/drpc/cmd/protoc-gen-go-drpc: exit status 128
from drpc.
go install storj.io/drpc/cmd/protoc-gen-go-drpc@latest
@egonelbre I'm using go1.15. It seems "@Version" is not supported in this version.
from drpc.
So, I debugged a little. It seems the redirection isn't working quite right for go1.15 for some reason. It'll take time to make and deploy the fix.
If you can then update your Go to latest version... Using go install
does seem to work correctly.
If updating Go is a problem then you can use this workaround to use a newer Go version:
go get golang.org/dl/go1.17.6
go1.17.6 download
go1.17.6 install storj.io/drpc/cmd/protoc-gen-go-drpc@latest
from drpc.
So, I debugged a little. It seems the redirection isn't working quite right for go1.15 for some reason. It'll take time to make and deploy the fix.
If you can then update your Go to latest version... Using
go install
does seem to work correctly.If updating Go is a problem then you can use this workaround to use a newer Go version:
go get golang.org/dl/go1.17.6 go1.17.6 download go1.17.6 install storj.io/drpc/cmd/protoc-gen-go-drpc@latest
@egonelbre thanks for your help! I'm able to download and install the protoc-gen-go-drpc by the workaround. My project can not be easily upgraded to 1.17.
Then I tried to generate the code as follows but it seems not using the drpc protoc?
> /go_path/native/x86_64-pc-linux-gnu/protobuf/protoc --go_out=. --go_opt=paths=source_relative --go-drpc_out=. --go-drpc_opt=paths=source_relative dheartbeat.proto
protoc-gen-go: program not found or is not executable
--go_out: protoc-gen-go: Plugin failed with status code 1
BTW, gogoproto like "goproto_stringer" or "gogoproto.nullable" is widely used in my project. Are they adapted in dRPC too?
from drpc.
The --go_out
options imply that you also want to use go protobuf generator:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
If you want to use gogoproto, then you'll need the gogo generators and specify those arguments as usual. See https://github.com/gogo/protobuf#installation for details.
But, yes, dRPC should work fine with gogoproto.
from drpc.
The
--go_out
options imply that you also want to use go protobuf generator:go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
If you want to use gogoproto, then you'll need the gogo generators and specify those arguments as usual. See https://github.com/gogo/protobuf#installation for details.
But, yes, dRPC should work fine with gogoproto.
@egonelbre e I'm able to generate the drpc code by the proto file. Hooray~
I still have some questions.
- In generated code, it uses "google.golang.org/protobuf/proto". Is it ok to use "github.com/gogo/protobuf/proto"?
- If I don't use JSON, I guess I can delete the JSON Marshal/UnMarshal methods, right?
- Currently in my project with grpc, I use Marshal/Unmarshal only. What's the difference between Marshal and MarshalAppend?
from drpc.
- The generated code depends on whether you use the official proto or gogo proto. It should pick the right one and you shouldn't need to modify the generated code.
- Yes, however, usually it's easier to ignore those.
- That's a question for protobuf team -- however, the MarshalAppend allows to reuse an existing byte buffer and hence reduce allocations.
from drpc.
@egonelbre One more question. In the doc example, service is registered by the drpcmutex and before drpcserver is created. Is it ok to register more services by the drpcmutex after drpcserver creation. After all, services should be registered before the drpcserver serve.
from drpc.
Ah, to clarify the gogoproto thing, I missed that it also needs a few additional arguments:
protoc --gogo_out=paths=source_relative:. --go-drpc_out=paths=source_relative,protolib=github.com/gogo/protobuf:. service.proto
from drpc.
At the moment it wouldn't be correct to register after Serve, otherwise it should be fine. If you run your program with -race
it should point out the problems.
from drpc.
At the moment it wouldn't be correct to register after Serve, otherwise it should be fine. If you run your program with
-race
it should point out the problems.
@egonelbre got you. I'll try to generate all code from grpc to drpc in my project (only change 1 proto file for testing at the moment) and then test for the performance difference.
Again thanks a lot for your help.
from drpc.
@egonelbre It seems adding argument "--go-drpc_out=paths=source_relative,protolib=github.com/gogo/protobuf/proto" makes the generated code not working correctly.
mport (
context "context"
errors "errors"
proto "github.com/gogo/protobuf/proto"
drpc "storj.io/drpc"
drpcerr "storj.io/drpc/drpcerr"
)
type drpcEncoding_File_dheartbeat_proto struct{}
func (drpcEncoding_File_dheartbeat_proto) Marshal(msg drpc.Message) ([]byte, error) {
return proto.Marshal(msg)
}
It shows the error that "msg missing method". I need to manually change it to "msg.(proto.Message)".
What's more, is there any argument to control not generating the JSON related code? The reason is "github.com/gogo/protobuf/proto" does not have "JSONMarshal" / "JSONUnmarshal" and in the end I will need to update the Makefile to automatically generate the drpc code.
from drpc.
@cindyzqtnew did you also use gogo for rest of the generation and rest of the codebase? Are you also using a protobuf version that is compatible with gogo?
from drpc.
@cindyzqtnew did you also use gogo for rest of the generation and rest of the codebase? Are you also using a protobuf version that is compatible with gogo?
@egonelbre here is the generate cmd I use.
> /go_path/native/x86_64-pc-linux-gnu/protobuf/protoc --go-drpc_out=. --go-drpc_opt=paths=source_relative,protolib=github.com/gogo/protobuf/proto dheartbeat.proto
from drpc.
@cindyzqtnew that part does not contain the code to generate the protobuf messages, it contains only the service parts. The problem is in the --gogo_out
argument.
from drpc.
@cindyzqtnew that part does not contain the code to generate the protobuf messages, it contains only the service parts. The problem is in the
--gogo_out
argument.
@egonelbre it seems not working and wired..
> /go_path/native/x86_64-pc-linux-gnu/protobuf/protoc --gogo_out=paths=source_relative --go-drpc_out=. --go-drpc_opt=paths=source_relative,protolib=github.com/gogo/protobuf/proto dheartbeat.proto
paths=source_relative/: No such file or directory
from drpc.
@cindyzqtnew the command you pasted does not match #23 (comment)
from drpc.
Now I'm able to generate the code manually by go1.17.6 install storj.io/drpc/cmd/protoc-gen-go-drpc@latest
. Since my project is big, I already automate the generate work in the Makefile. In the Makefile, I need to install the protoc-gen-go-drpc plugin first. I usually place the file under pkg/cmd/ and install it by go install
. Which files should I download for installation? The whole repo of "https://github.com/storj/drpc"? But I don't see there is any main there.
from drpc.
Now I'm able to generate the code manually by
go1.17.6 install storj.io/drpc/cmd/protoc-gen-go-drpc@latest
. Since my project is big, I already automate the generate work in the Makefile. In the Makefile, I need to install the protoc-gen-go-drpc plugin first. I usually place the file under pkg/cmd/ and install it bygo install
. Which files should I download for installation? The whole repo of "https://github.com/storj/drpc"? But I don't see there is any main there.
BTW, here is how I generate the gRPC in the Makefile.
bins:
...
bin/protoc-gen-gogo
...
bin/grpc_proto_src: $(PROTOC) $(GO_PROTOS) $(GOGOPROTO_PROTO) bin/.bootstrap bin/protoc-gen-gogo
...
for dir in $(sort $(dir $(GO_PROTOS))); do \
$(PROTOC) -Ipkg:./vendor/github.com:$(GOGO_PROTOBUF_PATH):$(PROTOBUF_PATH) --gogo_out=$(PROTO_MAPPINGS),plugins=grpc,import_prefix=test/pkg/:./pkg $$dir/*.proto; \
done
...
I try to install drpc and generate the code as follows.
bin/protoc-gen-go-drpc: bin/.submodules-initialized
cd pkg/cmd/protoc-gen-go-drpc && GO111MODULE=on $(GO_INSTALL) -v ./ && cd -
bin/drpc_proto_src: $(PROTOC) $(GO_PROTOS) $(GOGOPROTO_PROTO) bin/.bootstrap bin/protoc-gen-go-drpc
...
for dir in $(sort $(dir $(GO_PROTOS))); do \
$(PROTOC) -Ipkg:./vendor/github.com:$(GOGO_PROTOBUF_PATH):$(PROTOBUF_PATH) --go-drpc_out=paths=source_relative,import_prefix=test/pkg/:./pkg $$dir/*.proto; \
done
...
It seems not working...
Appreciate for any help!
from drpc.
It's unclear what wasn't working about your Makefile. I hope you figured it out!
from drpc.
Related Issues (20)
- Kubernetes deployment advice HOT 2
- Incorrect JSON deser in HTTP example
- Allow maximum payload size to be configurable HOT 8
- Question: how to do the load balancing? HOT 6
- buffered Writer causes data races with net.Pipe HOT 2
- Support for custom codec? HOT 4
- drpcserver: Find alternative to net.Error.IsTemporary because it's depcrated HOT 1
- Reconnect client to server HOT 3
- Context cancellation closes the connection HOT 16
- migration steps HOT 3
- What is the max message size handling approach? HOT 6
- Tag stable releases HOT 1
- Better example docs
- maximum number of connections HOT 3
- logging addresses HOT 2
- debug logging HOT 2
- Data race during Stream.MsgRecv vs drpcmanager.NewWithOptions HOT 4
- Client load balancing HOT 1
- What does the "D" stand for? HOT 2
- picobuf compatibility with regards to Marshal and Unmarshal.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drpc.