diff --git a/example/hello-world/go.mod b/example/hello-world/go.mod index 8d5234aaa..24427fed8 100644 --- a/example/hello-world/go.mod +++ b/example/hello-world/go.mod @@ -2,8 +2,12 @@ module github.com/yourrepo/hello-world go 1.12 -replace github.com/yourrepo/hello-world-idl => hello-world-idl +replace github.com/yourrepo/hello-world-idl => ./hello-world-idl require ( - github.com/yourrepo/hello-world-idl v0.0.0 + github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect + github.com/yourrepo/hello-world-idl v0.0.0 + google.golang.org/appengine v1.4.0 // indirect + google.golang.org/genproto v0.0.0-20191002211648-c459b9ce5143 // indirect + google.golang.org/grpc v1.24.0 // indirect ) diff --git a/example/hello-world/go.sum b/example/hello-world/go.sum new file mode 100644 index 000000000..427acc122 --- /dev/null +++ b/example/hello-world/go.sum @@ -0,0 +1,54 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/grpc-ecosystem/grpc-gateway v1.11.3 h1:h8+NsYENhxNTuq+dobk3+ODoJtwY4Fu0WQXsxJfL8aM= +github.com/grpc-ecosystem/grpc-gateway v1.11.3/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20191002211648-c459b9ce5143 h1:tikhlQEJeezbnu0Zcblj7g5vm/L7xt6g1vnfq8mRCS4= +google.golang.org/genproto v0.0.0-20191002211648-c459b9ce5143/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= +google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/example/hello-world/hello-world-idl/Makefile b/example/hello-world/hello-world-idl/Makefile index e97a9724e..20e02c511 100644 --- a/example/hello-world/hello-world-idl/Makefile +++ b/example/hello-world/hello-world-idl/Makefile @@ -30,21 +30,21 @@ generate: generate-grpc generate-web generate-http generate-grpc: mkdir -p gen/go - protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/health/*.proto - protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/helloworld/*.proto - cp -f -rv gen/go/proto/* gen/go - rm -rf gen/go/proto + protoc ${PROTO_SOURCES} --go_out=plugins=grpc,paths=source_relative:proto ./proto/health/*.proto + protoc ${PROTO_SOURCES} --go_out=plugins=grpc,paths=source_relative:proto ./proto/helloworld/*.proto + cp -f -rv proto/proto/* gen/go + rm -rf proto/proto generate-web: mkdir -p gen/web - protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/health/*.proto - protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/helloworld/*.proto - cp -f -rv gen/web/proto/* gen/web - rm -rf gen/web/Proto gen/web/proto + protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:proto ./proto/health/*.proto + protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:proto ./proto/helloworld/*.proto + cp -f -rv proto/proto/* gen/web + cp -f -rv proto/Proto/* gen/web + rm -rf proto/proto proto/Proto generate-http: - mkdir -p gen/http gen/swagger - protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/health/*.proto - protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/helloworld/*.proto - cp -f -rv gen/http/proto/* gen/http - cp -f -rv gen/swagger/proto/* gen/swagger - rm -rf gen/swagger/proto + mkdir -p gen/http + protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true,paths=source_relative:proto --swagger_out=logtostderr=true:proto ./proto/health/*.proto + protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true,paths=source_relative:proto --swagger_out=logtostderr=true:proto ./proto/helloworld/*.proto + cp -f -rv proto/proto/* gen/http + rm -rf proto/proto diff --git a/example/hello-world/hello-world-idl/gen/go/health/health.pb.go b/example/hello-world/hello-world-idl/gen/go/health/health.pb.go index 3a477870f..b203ec123 100644 --- a/example/hello-world/hello-world-idl/gen/go/health/health.pb.go +++ b/example/hello-world/hello-world-idl/gen/go/health/health.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: proto/health/health.proto -package mycompany_health +package health import ( context "context" @@ -10,6 +10,8 @@ import ( _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" math "math" ) @@ -95,7 +97,7 @@ func (m *HealthCheckRequest) GetService() string { } type HealthCheckResponse struct { - Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=mycompany.health.HealthCheckResponse_ServingStatus" json:"status,omitempty"` + Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=health.HealthCheckResponse_ServingStatus" json:"status,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -134,36 +136,37 @@ func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { } func init() { - proto.RegisterEnum("mycompany.health.HealthCheckResponse_ServingStatus", HealthCheckResponse_ServingStatus_name, HealthCheckResponse_ServingStatus_value) - proto.RegisterType((*HealthCheckRequest)(nil), "mycompany.health.HealthCheckRequest") - proto.RegisterType((*HealthCheckResponse)(nil), "mycompany.health.HealthCheckResponse") + proto.RegisterEnum("health.HealthCheckResponse_ServingStatus", HealthCheckResponse_ServingStatus_name, HealthCheckResponse_ServingStatus_value) + proto.RegisterType((*HealthCheckRequest)(nil), "health.HealthCheckRequest") + proto.RegisterType((*HealthCheckResponse)(nil), "health.HealthCheckResponse") } func init() { proto.RegisterFile("proto/health/health.proto", fileDescriptor_7bb2e9a145ccb86d) } var fileDescriptor_7bb2e9a145ccb86d = []byte{ - // 324 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x51, 0xcd, 0x4e, 0x02, 0x31, - 0x10, 0xb6, 0x10, 0x20, 0x0e, 0x22, 0x64, 0x30, 0x06, 0x88, 0x07, 0xb2, 0xd1, 0xc4, 0x83, 0x74, - 0xf9, 0x79, 0x02, 0x25, 0x44, 0x0d, 0xc9, 0x92, 0x2c, 0x0a, 0x47, 0x52, 0x37, 0x4d, 0x97, 0x08, - 0xed, 0x4a, 0x0b, 0x86, 0xab, 0x8f, 0xa0, 0x8f, 0xe2, 0x5b, 0x78, 0xf5, 0x15, 0x7c, 0x10, 0x43, - 0x17, 0x0e, 0xa8, 0x89, 0x1e, 0x3c, 0x4d, 0x66, 0xbe, 0x9f, 0xf9, 0xda, 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b, 0x42, 0xfb, 0x13, 0x95, 0x93, 0x3f, 0xbd, 0xc3, 0xc1, 0xa7, 0xf7, 0x8f, 0x97, 0xc4, - 0x1e, 0x82, 0xbb, 0x68, 0xac, 0xcf, 0x87, 0x03, 0x48, 0x0d, 0x99, 0x09, 0xc2, 0x7f, 0xdd, 0x54, - 0x27, 0x17, 0xe5, 0xe7, 0xf3, 0x43, 0x3c, 0x80, 0x5c, 0x8c, 0x56, 0x2d, 0xac, 0x9b, 0xc9, 0x06, - 0xad, 0xdf, 0xa5, 0xed, 0x51, 0x5b, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x27, 0xce, 0xfd, 0xfa, - 0x4f, 0x02, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0x41, 0x4e, 0xc2, 0x40, + 0x14, 0xb5, 0x10, 0x4a, 0xfc, 0x88, 0x90, 0xc1, 0x18, 0xac, 0x2e, 0x48, 0x57, 0x9a, 0xd8, 0x0e, + 0xe0, 0x09, 0x80, 0x10, 0x35, 0x9a, 0x92, 0x14, 0x94, 0xc4, 0x0d, 0x29, 0x65, 0x32, 0x6d, 0xac, + 0x9d, 0xda, 0x99, 0x42, 0xdc, 0x7a, 0x04, 0xbd, 0x81, 0x3b, 0xcf, 0xe3, 0x15, 0x3c, 0x88, 0x61, + 0xda, 0x2e, 0x88, 0xc4, 0x85, 0xab, 0x9f, 0xf7, 0xff, 0x7b, 0x6f, 0xde, 0xe4, 0x7f, 0x38, 0x8a, + 0x62, 0x26, 0x18, 0xf6, 0x88, 0x13, 0x08, 0x2f, 0x2b, 0xa6, 0xec, 0x21, 0x35, 0x45, 0xda, 0x09, + 0x65, 0x8c, 0x06, 0x04, 0x3b, 0x91, 0x8f, 0x9d, 0x30, 0x64, 0xc2, 0x11, 0x3e, 0x0b, 0x79, 0xca, + 0xd2, 0xce, 0x65, 0x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b, 0x0f, 0x1d, 0xea, 0x0b, 0x2f, 0x99, + 0x9b, 0x2e, 0x7b, 0xc2, 0x2f, 0x2c, 0x89, 0x63, 0x12, 0xad, 0x0f, 0x23, 0x08, 0x98, 0xb1, 0x62, + 0x71, 0xb0, 0x30, 0xfc, 0x45, 0x80, 0x29, 0x09, 0x31, 0xcd, 0xef, 0x65, 0xae, 0xca, 0xad, 0x5e, + 0xfc, 0x04, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xfa, 0x76, 0x68, 0x46, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -192,7 +195,7 @@ func NewHealthClient(cc *grpc.ClientConn) HealthClient { func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { out := new(HealthCheckResponse) - err := c.cc.Invoke(ctx, "/mycompany.health.Health/Check", in, out, opts...) + err := c.cc.Invoke(ctx, "/health.Health/Check", in, out, opts...) if err != nil { return nil, err } @@ -200,7 +203,7 @@ func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts . } func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) { - stream, err := c.cc.NewStream(ctx, &_Health_serviceDesc.Streams[0], "/mycompany.health.Health/Watch", opts...) + stream, err := c.cc.NewStream(ctx, &_Health_serviceDesc.Streams[0], "/health.Health/Watch", opts...) if err != nil { return nil, err } @@ -237,6 +240,17 @@ type HealthServer interface { Watch(*HealthCheckRequest, Health_WatchServer) error } +// UnimplementedHealthServer can be embedded to have forward compatible implementations. +type UnimplementedHealthServer struct { +} + +func (*UnimplementedHealthServer) Check(ctx context.Context, req *HealthCheckRequest) (*HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") +} +func (*UnimplementedHealthServer) Watch(req *HealthCheckRequest, srv Health_WatchServer) error { + return status.Errorf(codes.Unimplemented, "method Watch not implemented") +} + func RegisterHealthServer(s *grpc.Server, srv HealthServer) { s.RegisterService(&_Health_serviceDesc, srv) } @@ -251,7 +265,7 @@ func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/mycompany.health.Health/Check", + FullMethod: "/health.Health/Check", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) @@ -281,7 +295,7 @@ func (x *healthWatchServer) Send(m *HealthCheckResponse) error { } var _Health_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mycompany.health.Health", + ServiceName: "health.Health", HandlerType: (*HealthServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go b/example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go index 11d64767b..1fac18020 100644 --- a/example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go +++ b/example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go @@ -1,11 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: proto/helloworld/helloworld.proto -package mycompany_helloworld +package helloworld import ( + context "context" fmt "fmt" proto "github.com/golang/protobuf/proto" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" + health "github.com/yourrepo/hello-world-idl/gen/go/health" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" math "math" ) @@ -23,10 +30,100 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package func init() { proto.RegisterFile("proto/helloworld/helloworld.proto", fileDescriptor_d16ac54e3a89a4f6) } var fileDescriptor_d16ac54e3a89a4f6 = []byte{ - // 66 bytes of a gzipped FileDescriptorProto + // 229 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0xcf, 0x48, 0xcd, 0xc9, 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0x41, 0x62, 0xea, 0x81, - 0xe5, 0x84, 0x44, 0x72, 0x2b, 0x93, 0xf3, 0x73, 0x0b, 0x12, 0xf3, 0x2a, 0xf5, 0x10, 0x72, 0x49, - 0x6c, 0x60, 0x49, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x9e, 0x58, 0x93, 0x41, 0x00, - 0x00, 0x00, + 0xe5, 0x84, 0xb8, 0x10, 0x22, 0x52, 0x92, 0x30, 0xe5, 0x89, 0x39, 0x25, 0x19, 0x50, 0x0a, 0xa2, + 0x4c, 0x4a, 0x26, 0x3d, 0x3f, 0x3f, 0x3d, 0x27, 0x55, 0x3f, 0xb1, 0x20, 0x53, 0x3f, 0x31, 0x2f, + 0x2f, 0xbf, 0x24, 0xb1, 0x24, 0x33, 0x3f, 0xaf, 0x18, 0x2a, 0xab, 0x03, 0xa6, 0x92, 0x75, 0xd3, + 0x53, 0xf3, 0x74, 0x8b, 0xcb, 0x13, 0xd3, 0xd3, 0x53, 0x8b, 0xf4, 0xf3, 0x0b, 0xc0, 0x2a, 0x30, + 0x55, 0x1b, 0xe5, 0x72, 0x71, 0x79, 0xc0, 0x2d, 0x15, 0x8a, 0xe7, 0x62, 0x75, 0xce, 0x48, 0x4d, + 0xce, 0x16, 0x92, 0xd2, 0x83, 0xda, 0xe8, 0x01, 0xa6, 0xc0, 0x82, 0x41, 0xa9, 0x85, 0xa5, 0xa9, + 0xc5, 0x25, 0x52, 0xd2, 0x58, 0xe5, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x95, 0x64, 0x9b, 0x2e, + 0x3f, 0x99, 0xcc, 0x24, 0x2e, 0x24, 0xaa, 0x5f, 0x66, 0x88, 0xea, 0x57, 0x90, 0x5a, 0x27, 0xdf, + 0x49, 0x8e, 0xc2, 0x42, 0x82, 0xc8, 0x76, 0x1a, 0x31, 0x1b, 0xea, 0x19, 0x44, 0x99, 0xa6, 0x67, + 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x57, 0xe6, 0x97, 0x16, 0x15, 0xa5, 0x16, + 0x40, 0x83, 0x4a, 0x17, 0xac, 0x4a, 0x37, 0x33, 0x25, 0x47, 0x3f, 0x3d, 0x35, 0x4f, 0x3f, 0x1d, + 0x39, 0x04, 0x93, 0xd8, 0xc0, 0x9e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x7a, 0x4e, + 0x9a, 0x5c, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// HelloworldClient is the client API for Helloworld service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type HelloworldClient interface { + Check(ctx context.Context, in *health.HealthCheckRequest, opts ...grpc.CallOption) (*health.HealthCheckResponse, error) +} + +type helloworldClient struct { + cc *grpc.ClientConn +} + +func NewHelloworldClient(cc *grpc.ClientConn) HelloworldClient { + return &helloworldClient{cc} +} + +func (c *helloworldClient) Check(ctx context.Context, in *health.HealthCheckRequest, opts ...grpc.CallOption) (*health.HealthCheckResponse, error) { + out := new(health.HealthCheckResponse) + err := c.cc.Invoke(ctx, "/helloworld.Helloworld/Check", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// HelloworldServer is the server API for Helloworld service. +type HelloworldServer interface { + Check(context.Context, *health.HealthCheckRequest) (*health.HealthCheckResponse, error) +} + +// UnimplementedHelloworldServer can be embedded to have forward compatible implementations. +type UnimplementedHelloworldServer struct { +} + +func (*UnimplementedHelloworldServer) Check(ctx context.Context, req *health.HealthCheckRequest) (*health.HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") +} + +func RegisterHelloworldServer(s *grpc.Server, srv HelloworldServer) { + s.RegisterService(&_Helloworld_serviceDesc, srv) +} + +func _Helloworld_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(health.HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HelloworldServer).Check(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/helloworld.Helloworld/Check", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HelloworldServer).Check(ctx, req.(*health.HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Helloworld_serviceDesc = grpc.ServiceDesc{ + ServiceName: "helloworld.Helloworld", + HandlerType: (*HelloworldServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Check", + Handler: _Helloworld_Check_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/helloworld/helloworld.proto", } diff --git a/example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts b/example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts index 9444b292f..9e09300a8 100644 --- a/example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts +++ b/example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts @@ -1,2 +1,6 @@ import * as jspb from "google-protobuf" +import * as proto_health_health_pb from '../../proto/health/health_pb'; +import * as google_api_annotations_pb from '../../google/api/annotations_pb'; +import * as protoc$gen$swagger_options_annotations_pb from '../../protoc-gen-swagger/options/annotations_pb'; + diff --git a/example/hello-world/hello-world-idl/proto/health/health.proto b/example/hello-world/hello-world-idl/proto/health/health.proto index 1068fcfa2..816499b42 100644 --- a/example/hello-world/hello-world-idl/proto/health/health.proto +++ b/example/hello-world/hello-world-idl/proto/health/health.proto @@ -1,6 +1,8 @@ syntax = "proto3"; -package mycompany.health; +option go_package = "github.com/yourrepo/hello-world-idl/gen/go/health"; + +package health; import "google/api/annotations.proto"; import "protoc-gen-swagger/options/annotations.proto"; diff --git a/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto b/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto index cb45dce35..ce1ce7645 100644 --- a/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto +++ b/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto @@ -1,3 +1,24 @@ syntax = "proto3"; -package mycompany.helloworld; +option go_package = "github.com/yourrepo/hello-world-idl/gen/go/helloworld"; + +package helloworld; + +import "proto/health/health.proto"; +import "google/api/annotations.proto"; +import "protoc-gen-swagger/options/annotations.proto"; + +option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { + info: { + title: "Helloworld"; + version: "1.0"; + } +}; + +service Helloworld { + rpc Check(health.HealthCheckRequest) returns (health.HealthCheckResponse){ + option (google.api.http) = { + get: "/v1/helloworld/health" + }; + } +} diff --git a/example/hello-world/main.go b/example/hello-world/main.go index 7002bd2d3..942274b8d 100644 --- a/example/hello-world/main.go +++ b/example/hello-world/main.go @@ -3,9 +3,11 @@ import ( "log" "net" - health "github.com/yourrepo/hello-world/server/health" healthpb "github.com/yourrepo/hello-world-idl/gen/go/health" - + helloworldpb "github.com/yourrepo/hello-world-idl/gen/go/helloworld" + + health "github.com/yourrepo/hello-world/server/health" + helloworld "github.com/yourrepo/hello-world/server/helloworld" "google.golang.org/grpc" ) @@ -16,11 +18,15 @@ func main() { if err != nil { log.Fatalf("failed to listen: %v", err) } + s := grpc.NewServer() - //TODO: Register your servers here + //Server initialization & registration healthServer := health.NewHealthServer() healthpb.RegisterHealthServer(s, healthServer) + helloworldServer := helloworld.NewHelloworldServer() + helloworldpb.RegisterHelloworldServer(s, helloworldServer) + log.Printf("Starting grpc server on %v...", grpcAddr) diff --git a/example/hello-world/server/helloworld/helloworld.go b/example/hello-world/server/helloworld/helloworld.go index 8423d3208..f8cded13b 100644 --- a/example/hello-world/server/helloworld/helloworld.go +++ b/example/hello-world/server/helloworld/helloworld.go @@ -2,7 +2,8 @@ package helloworld import ( "context" - api "github.com/yourrepo/hello-world-idl/gen/go/helloworld" + health_api "github.com/yourrepo/hello-world-idl/gen/go/health" + //api "github.com/yourrepo/hello-world-idl/gen/go/helloworld" ) type HelloworldServer struct { @@ -12,3 +13,10 @@ type HelloworldServer struct { func NewHelloworldServer() *HelloworldServer { return &HelloworldServer{} } + +func (s *HelloworldServer) Check(ctx context.Context, req *health_api.HealthCheckRequest) (*health_api.HealthCheckResponse, error) { + resp := &health_api.HealthCheckResponse{ + Status: health_api.HealthCheckResponse_SERVING, + } + return resp,nil +}