gogo / grpc-example Goto Github PK
View Code? Open in Web Editor NEWAn example of using Go gRPC and tools from the greater gRPC ecosystem together with the GoGo Protobuf Project.
License: Other
An example of using Go gRPC and tools from the greater gRPC ecosystem together with the GoGo Protobuf Project.
License: Other
~/go/src/github.com/davidklassen/grpc-example/ master make generate
# Generate gogo, gRPC-Gateway, swagger, go-validators output.
#
# -I declares import folders, in order of importance
# This is how proto resolves the protofile imports.
# It will check for the protofile relative to each of these
# folders and use the first one it finds.
#
# --gogo_out generates GoGo Protobuf output with gRPC plugin enabled.
# --grpc-gateway_out generates gRPC-Gateway output.
# --swagger_out generates an OpenAPI 2.0 specification for our gRPC-Gateway endpoints.
# --govalidators_out generates Go validation files for our messages types, if specified.
#
# The lines starting with Mgoogle/... are proto import replacements,
# which cause the generated file to import the specified packages
# instead of the go_package's declared by the imported protof files.
#
# $GOPATH/src is the output directory. It is relative to the GOPATH/src directory
# since we've specified a go_package option relative to that directory.
#
# proto/example.proto is the location of the protofile we use.
protoc \
-I proto \
-I vendor/github.com/grpc-ecosystem/grpc-gateway/ \
-I vendor/github.com/gogo/googleapis/ \
-I vendor/ \
--gogo_out=plugins=grpc,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$GOPATH/src/ \
--grpc-gateway_out=\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$GOPATH/src/ \
--swagger_out=third_party/OpenAPI/ \
--govalidators_out=gogoimport=true,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$GOPATH/src \
proto/example.proto
# Workaround for https://github.com/grpc-ecosystem/grpc-gateway/issues/229.
sed -i "s/empty.Empty/types.Empty/g" proto/example.pb.gw.go
sed: 1: "proto/example.pb.gw.go": extra characters at the end of p command
make: *** [generate] Error 1
Need to find how to work around https://github.com/grpc-ecosystem/grpc-gateway/blob/58f78b988bc393694cef62b92c5cde77e4742ff5/runtime/query.go#L275 in gRPC-Gateway.
Not only will this help to maintain the example, but it will also be nice an example of how to setup a travis job with gogoprotobuf and grpc.
I made following error while running the 'make generate' instruction thank's for you helper
google/protobuf/empty.proto: File not found.
google/protobuf/timestamp.proto: File not found.
google/protobuf/duration.proto: File not found.
google/protobuf/field_mask.proto: File not found.
google/protobuf/descriptor.proto: File not found.
google/api/annotations.proto:20:1: Import "google/protobuf/descriptor.proto" was not found or had errors.
google/api/annotations.proto:28:8: "google.protobuf.MethodOptions" is not defined.
google/protobuf/any.proto: File not found.
protoc-gen-swagger/options/openapiv2.proto:7:1: Import "google/protobuf/any.proto" was not found or had errors.
protoc-gen-swagger/options/openapiv2.proto:141:3: "google.protobuf.Any" is not defined.
protoc-gen-swagger/options/annotations.proto:7:1: Import "protoc-gen-swagger/options/openapiv2.proto" was not found or had errors.
protoc-gen-swagger/options/annotations.proto:8:1: Import "google/protobuf/descriptor.proto" was not found or had errors.
protoc-gen-swagger/options/annotations.proto:10:8: "google.protobuf.FileOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:17:8: "google.protobuf.MethodOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:24:8: "google.protobuf.MessageOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:31:8: "google.protobuf.ServiceOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:38:8: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto:32:1: Import "google/protobuf/descriptor.proto" was not found or had errors.
github.com/gogo/protobuf/gogoproto/gogo.proto:38:8: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
It can use the scripts from gogo/googleapis as mentioned in #4 (comment).
This should include splitting the third_party folder generation assets into a separate Makefile job as it is generation-time dependant.
At $work we ran into an issue with using the gogoproto.stdtime
as a query parameter to grpc-gateway. The problem is this code https://github.com/grpc-ecosystem/grpc-gateway/blob/ee3ef70b7777cde4e61e4e224cb11e92beecee6a/runtime/query.go#L208 that only handles destination types that implement XXX_WellKnownType
. More investigation necessary.
In your example, try updating a user's role for example. It doesn't update it.
This is because you've set allow_patch_update=false
which means grpc-gateway
will not automatically fill the field mask for you, but you also put user
instead of *
in your service definition which means that swagger won't include the field mask so the user can't set it.
In other words, the update endpoint can't do anything currently.
Changing to *
will allow the user to set the field mask which will work but not user friendly.
We were looking for a way to make gogo-proto
and allow_patch_update=true
to work successfully together (which is how I found your example in the first place), but we didn't find anything on that topic (the field mask type is different from go-protobuf
). Any idea?
Following from the discussion in #9, it may be possible to use grpc/status instead of gogo/status when types implement MessageName() string
.
At work I ran into a problem with the following definition:
service Bla {
rpc GetBla(GetBlaRequest) returns (Bla) {
option (google.api.http) = {
post: "/api/v1/{bla_id}"
body: "bla"
};
}
message Bla {
string something = 1;
}
message GetBlaRequest {
string bla_id = 1;
Bla bla = 2;
}
It resulted in an error like:
unexpected type **bla.Bla does not implement proto.Message
The error originates from this line in the generated grpc-gateway code:
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Bla); err != nil {
I have seen errors like this before in the github.com/gogo/gateway JSONPb
marshaller, but thought they were fixed. Investigate whether this is a problem still.
when i exec make generate
in my centos , it comes:
# Generate gogo, gRPC-Gateway, swagger, go-validators output.
#
# -I declares import folders, in order of importance
# This is how proto resolves the protofile imports.
# It will check for the protofile relative to each of these
# folders and use the first one it finds.
#
# --gogo_out generates GoGo Protobuf output with gRPC plugin enabled.
# --grpc-gateway_out generates gRPC-Gateway output.
# --swagger_out generates an OpenAPI 2.0 specification for our gRPC-Gateway endpoints.
# --govalidators_out generates Go validation files for our messages types, if specified.
#
# The lines starting with Mgoogle/... are proto import replacements,
# which cause the generated file to import the specified packages
# instead of the go_package's declared by the imported protof files.
#
# $GOPATH/src is the output directory. It is relative to the GOPATH/src directory
# since we've specified a go_package option relative to that directory.
#
# proto/example.proto is the location of the protofile we use.
protoc \
-I proto \
-I vendor/github.com/grpc-ecosystem/grpc-gateway/ \
-I vendor/github.com/gogo/googleapis/ \
-I vendor/ \
--gogo_out=plugins=grpc,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$GOPATH/src/ \
--grpc-gateway_out=\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$GOPATH/src/ \
--swagger_out=third_party/OpenAPI/ \
--govalidators_out=gogoimport=true,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$GOPATH/src \
proto/example.proto
google/protobuf/empty.proto: File not found.
google/protobuf/timestamp.proto: File not found.
google/protobuf/duration.proto: File not found.
google/protobuf/field_mask.proto: File not found.
google/protobuf/descriptor.proto: File not found.
google/api/annotations.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
google/api/annotations.proto:28:8: "google.protobuf.MethodOptions" is not defined.
google/protobuf/any.proto: File not found.
protoc-gen-swagger/options/openapiv2.proto: Import "google/protobuf/any.proto" was not found or had errors.
protoc-gen-swagger/options/openapiv2.proto:131:3: "google.protobuf.Any" is not defined.
protoc-gen-swagger/options/annotations.proto: Import "protoc-gen-swagger/options/openapiv2.proto" was not found or had errors.
protoc-gen-swagger/options/annotations.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
protoc-gen-swagger/options/annotations.proto:10:8: "google.protobuf.FileOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:17:8: "google.protobuf.MethodOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:24:8: "google.protobuf.MessageOptions" is not defined.
protoc-gen-swagger/options/annotations.proto:31:8: "google.protobuf.ServiceOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
github.com/gogo/protobuf/gogoproto/gogo.proto:38:8: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.EnumOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto:46:8: "google.protobuf.EnumValueOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto:50:8: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FileOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto:89:8: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.MessageOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto:123:8: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/gogo/protobuf/gogoproto/gogo.proto: "google.protobuf.FieldOptions" is not defined.
github.com/mwitkow/go-proto-validators/validator.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
github.com/mwitkow/go-proto-validators/validator.proto:18:8: "google.protobuf.FieldOptions" is not defined.
example.proto: Import "google/protobuf/empty.proto" was not found or had errors.
example.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
example.proto: Import "google/protobuf/duration.proto" was not found or had errors.
example.proto: Import "google/protobuf/field_mask.proto" was not found or had errors.
example.proto: Import "google/api/annotations.proto" was not found or had errors.
example.proto: Import "protoc-gen-swagger/options/annotations.proto" was not found or had errors.
example.proto: Import "github.com/gogo/protobuf/gogoproto/gogo.proto" was not found or had errors.
example.proto: Import "github.com/mwitkow/go-proto-validators/validator.proto" was not found or had errors.
example.proto:82:5: "google.protobuf.Timestamp" is not defined.
example.proto:97:5: "google.protobuf.FieldMask" is not defined.
example.proto:102:5: "google.protobuf.Timestamp" is not defined.
example.proto:106:5: "google.protobuf.Duration" is not defined.
example.proto:43:32: "google.protobuf.Empty" is not defined.
make: *** [generate] Error 1
and exec make install
is ok
make install
go install \
./vendor/github.com/gogo/protobuf/protoc-gen-gogo \
./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \
./vendor/github.com/mwitkow/go-proto-validators/protoc-gen-govalidators \
./vendor/github.com/rakyll/statik
and when i exec make generate
on my two mac, one is ok, but anther is failed.
I am trying to generate code from a .proto file that is basic but good enough to get me started. I have tried for several ours following grpc-example, to no avail. I know I am missing something for sure and here is what I have done so far:
syntax="proto3";
package somepackage
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
import "protoc-gen-swagger/options/annotations.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
option go_package = "client";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
info: {
version: "1.0";
};
external_docs: {
url: "https://localhost:9090/bakalr/api";
description: "Bakalr Payment Services";
}
schemes: HTTPS;
};
// Enable custom Marshal method.
option (gogoproto.marshaler_all) = true;
// Enable custom Unmarshal method.
option (gogoproto.unmarshaler_all) = true;
// Enable custom Size method (Required by Marshal and Unmarshal).
option (gogoproto.sizer_all) = true;
// Enable registration with golang/protobuf for the grpc-gateway.
option (gogoproto.goproto_registration) = true;
// Enable generation of XXX_MessageName methods for grpc-go/status.
option (gogoproto.messagename_all) = true;
service ClientService {
rpc RegisterClient(Client) returns (Client){
option (google.api.http) = {
post: "/api/v1/clients"
body: "*"
};
}
}
enum ClientType {
unknown = 0;
mobile = 1;
web = 2;
iot = 3;
pinpad = 4;
server = 5;
}
message Client {
string id = 1[(gogoproto.customname) = "ID"];
ClientType ClientType = 2[(validator.field) = {
msg_exists : true
human_error: "Client type must not be unknown"
}];
google.protobuf.Timestamp registeredOn = 3[
(gogoproto.stdtime) = true
];
}
The thing is I cannot get this to generate, I get this error Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,: No such file or directory
every time I try to generate the code out of that .proto file.
generate: install
protoc \
-I client \
--gogoslick_out=plugins=grpc,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$$GOPATH/src/ \
--grpc-gateway_out=\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$$GOPATH/src/ \
--swagger_out=third_party/OpenAPI/ \
--govalidators_out=gogoimport=true,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$$GOPATH/src \
client/client.proto
install:
go get \
github.com/gogo/protobuf/protoc-gen-gogo \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \
github.com/mwitkow/go-proto-validators/protoc-gen-govalidators \
github.com/rakyll/statik
I can verify that:
google/protobuf/timestamp.proto
google/api/annotations.proto
google/protobuf/field_mask.proto
Are present in:
github.com/gogo/protobuf/types
github.com/gogo/googleapis/google/api
respectively.
Please let me know what I am missing here.
go version go1.11.2 darwin/amd64
go modules
Hello gogo, thanks for your amazing library.
I use a lot [(gogoproto.nullable) = true];
and i recently switched to gRPC but i can't find a way to remove pointers on generated interface methods.
e.g:
// .proto:
rpc Subscribe(dto.Subscribe) returns (google.protobuf.Empty);
// .pb.go:
Subscribe(ctx context.Context, in *dto.Subscribe, opts ...grpc.CallOption) (*types.Empty, error)
Instead i'd like to have
// .pb.go:
Subscribe(ctx context.Context, in dto.Subscribe, opts ...grpc.CallOption) (types.Empty, error)
Is there any way to do this with current extensions ?
Thanks
Hello!
Could you please consider putting this repo under an open source license?
I am asking because I working in an environment that has a regulation in place that forbids using this example as a starting point when it is not under an open source license.
Preferable would be a permissive open source license like MIT or Apache 2.0
But that is up to you.
Many regards,
Michael
For example
// The file manager service definition.
service FileManager {
rpc Hello(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http) = {
get: "/v1/hello"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
responses: {
key: "200"
}
};
}
}
the code will be generate just like below
func request_FileManager_Hello_0(ctx context.Context, marshaler runtime.Marshaler, client FileManagerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
msg, err := client.Hello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
empty.Empty
can not be found by go when it be replaced by github.com/gogo/protobuf/types
.
How can i fix it?
@yurishkuro showed that users of this repository could benefit of a good example of a client using the server. I would like the following to be shown with this client:
I see a number of static assets added in a6e1cf3, but no indication where they came from. The option --swagger_out=third_party/OpenAPI/
to protoc
only generates the JSON file. If I want to serve swagger UI from my application, how would I go about generating them? I don't want to just copy them from this repo.
I'm happy to create a PR with example/explanation if you point me in the right direction.
Hi there! I really appreciate the time spent putting this example together - it's pretty awesome!
Testing it locally, I've found that the server panics in the AddUser method when I connect the client.
I managed to fix it by returning a &types.Empty{}
instead of nil
. I'm curious to know why that didn't happen to the person writing it! These are my changes: https://gist.github.com/sevein/ddbec1c4e00ea3c3e1c14c8efb5c335b.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.