From a4bccd3d8d04734048d6fda7c152bfa9d4c3dcdd Mon Sep 17 00:00:00 2001 From: pritesh-patel Date: Sun, 6 Oct 2019 16:58:18 -0700 Subject: [PATCH 1/3] remove old example --- example/hello-world/.gitignore | 1 - example/hello-world/go.mod | 13 - example/hello-world/go.sum | 54 --- example/hello-world/hello-world-idl/Makefile | 50 --- .../gen/go/health/health.pb.go | 314 ------------------ .../gen/go/helloworld/helloworld.pb.go | 129 ------- .../gen/web/health/health_pb.d.ts | 48 --- .../gen/web/helloworld/helloworld_pb.d.ts | 6 - example/hello-world/hello-world-idl/go.mod | 3 - .../hello-world-idl/proto/health/health.proto | 38 --- .../proto/helloworld/helloworld.proto | 24 -- example/hello-world/main.go | 36 -- example/hello-world/server/health/health.go | 25 -- .../server/helloworld/helloworld.go | 22 -- example/hello-world/sprout.yml | 24 -- 15 files changed, 787 deletions(-) delete mode 100644 example/hello-world/.gitignore delete mode 100644 example/hello-world/go.mod delete mode 100644 example/hello-world/go.sum delete mode 100644 example/hello-world/hello-world-idl/Makefile delete mode 100644 example/hello-world/hello-world-idl/gen/go/health/health.pb.go delete mode 100644 example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go delete mode 100644 example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts delete mode 100644 example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts delete mode 100644 example/hello-world/hello-world-idl/go.mod delete mode 100644 example/hello-world/hello-world-idl/proto/health/health.proto delete mode 100644 example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto delete mode 100644 example/hello-world/main.go delete mode 100644 example/hello-world/server/health/health.go delete mode 100644 example/hello-world/server/helloworld/helloworld.go delete mode 100644 example/hello-world/sprout.yml diff --git a/example/hello-world/.gitignore b/example/hello-world/.gitignore deleted file mode 100644 index 55283c232..000000000 --- a/example/hello-world/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/hello-world-idl diff --git a/example/hello-world/go.mod b/example/hello-world/go.mod deleted file mode 100644 index 24427fed8..000000000 --- a/example/hello-world/go.mod +++ /dev/null @@ -1,13 +0,0 @@ -module github.com/yourrepo/hello-world - -go 1.12 - -replace github.com/yourrepo/hello-world-idl => ./hello-world-idl - -require ( - 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 deleted file mode 100644 index 427acc122..000000000 --- a/example/hello-world/go.sum +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index 20e02c511..000000000 --- a/example/hello-world/hello-world-idl/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -PROTOC_VERSION := 3.9.2 -PROTOC_WEB_VERSION := 1.0.6 - -PROTO_SOURCES := -I /usr/local/include -PROTO_SOURCES += -I . -PROTO_SOURCES += -I ${GOPATH}/src -PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway - -deps-linux: deps-protoc-linux deps-grpc-web-linux deps-go - -deps-protoc-linux: - curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-linux-x86_64.zip - unzip protoc-$(PROTOC_VERSION)-linux-x86_64.zip -d protoc3 - sudo mv protoc3/bin/* /usr/local/bin/ - sudo mv protoc3/include/* /usr/local/include/ - rm -rf protoc3 protoc-$(PROTOC_VERSION)-linux-x86_64.zip - -deps-grpc-web-linux: - curl -OL https://github.com/grpc/grpc-web/releases/download/$(PROTOC_WEB_VERSION)/protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 - sudo mv protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 /usr/local/bin/protoc-gen-grpc-web - chmod +x /usr/local/bin/protoc-gen-grpc-web - -deps-go: - go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway - go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger - go get -u github.com/golang/protobuf/protoc-gen-go - -generate: generate-grpc generate-web generate-http - -generate-grpc: - mkdir -p gen/go - 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: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 - 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 deleted file mode 100644 index b203ec123..000000000 --- a/example/hello-world/hello-world-idl/gen/go/health/health.pb.go +++ /dev/null @@ -1,314 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: proto/health/health.proto - -package health - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - _ "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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type HealthCheckResponse_ServingStatus int32 - -const ( - HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0 - HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1 - HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2 - HealthCheckResponse_SERVICE_UNKNOWN HealthCheckResponse_ServingStatus = 3 -) - -var HealthCheckResponse_ServingStatus_name = map[int32]string{ - 0: "UNKNOWN", - 1: "SERVING", - 2: "NOT_SERVING", - 3: "SERVICE_UNKNOWN", -} - -var HealthCheckResponse_ServingStatus_value = map[string]int32{ - "UNKNOWN": 0, - "SERVING": 1, - "NOT_SERVING": 2, - "SERVICE_UNKNOWN": 3, -} - -func (x HealthCheckResponse_ServingStatus) String() string { - return proto.EnumName(HealthCheckResponse_ServingStatus_name, int32(x)) -} - -func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_7bb2e9a145ccb86d, []int{1, 0} -} - -type HealthCheckRequest struct { - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HealthCheckRequest) Reset() { *m = HealthCheckRequest{} } -func (m *HealthCheckRequest) String() string { return proto.CompactTextString(m) } -func (*HealthCheckRequest) ProtoMessage() {} -func (*HealthCheckRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7bb2e9a145ccb86d, []int{0} -} - -func (m *HealthCheckRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HealthCheckRequest.Unmarshal(m, b) -} -func (m *HealthCheckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HealthCheckRequest.Marshal(b, m, deterministic) -} -func (m *HealthCheckRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HealthCheckRequest.Merge(m, src) -} -func (m *HealthCheckRequest) XXX_Size() int { - return xxx_messageInfo_HealthCheckRequest.Size(m) -} -func (m *HealthCheckRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HealthCheckRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HealthCheckRequest proto.InternalMessageInfo - -func (m *HealthCheckRequest) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -type HealthCheckResponse struct { - 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:"-"` -} - -func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} } -func (m *HealthCheckResponse) String() string { return proto.CompactTextString(m) } -func (*HealthCheckResponse) ProtoMessage() {} -func (*HealthCheckResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7bb2e9a145ccb86d, []int{1} -} - -func (m *HealthCheckResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HealthCheckResponse.Unmarshal(m, b) -} -func (m *HealthCheckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HealthCheckResponse.Marshal(b, m, deterministic) -} -func (m *HealthCheckResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HealthCheckResponse.Merge(m, src) -} -func (m *HealthCheckResponse) XXX_Size() int { - return xxx_messageInfo_HealthCheckResponse.Size(m) -} -func (m *HealthCheckResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HealthCheckResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_HealthCheckResponse proto.InternalMessageInfo - -func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { - if m != nil { - return m.Status - } - return HealthCheckResponse_UNKNOWN -} - -func init() { - 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{ - // 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, 0x71, 0x0d, 0x4a, 0x42, 0x83, 0xaf, 0x1c, 0x4a, 0x49, 0x8c, 0x59, 0x24, 0x19, - 0xbf, 0xd9, 0xba, 0x09, 0xe8, 0x4a, 0xba, 0x0e, 0x3c, 0xe2, 0x3e, 0xda, 0xe4, 0x39, 0x21, 0x5c, - 0xa0, 0x26, 0x94, 0x39, 0x89, 0x97, 0xbe, 0x4b, 0x9a, 0x4a, 0x4b, 0x39, 0xdd, 0xb5, 0x73, 0xa8, - 0x7f, 0x2a, 0xd0, 0xd8, 0x10, 0xf0, 0x88, 0x85, 0x9c, 0xa0, 0x1e, 0xa8, 0x5c, 0x38, 0x22, 0xe1, - 0x52, 0xb0, 0xdf, 0x3d, 0x33, 0xb3, 0xe8, 0x5b, 0xc8, 0xe6, 0x78, 0x6d, 0x16, 0xd2, 0xb1, 0x14, - 0xd8, 0x99, 0x50, 0x1f, 0x41, 0x75, 0x63, 0x80, 0x2a, 0x50, 0xbe, 0xb3, 0x6e, 0xac, 0xd1, 0xd4, - 0xaa, 0xef, 0xac, 0xc1, 0x78, 0x68, 0xdf, 0x5f, 0x5b, 0x97, 0x75, 0x05, 0xd5, 0xa0, 0x62, 0x8d, - 0x26, 0xb3, 0xbc, 0x51, 0x40, 0x0d, 0xa8, 0x49, 0x30, 0x18, 0xce, 0x72, 0x49, 0xb1, 0xfb, 0xa1, - 0x80, 0x9a, 0x3e, 0x8f, 0x26, 0x50, 0x92, 0x11, 0x90, 0xb6, 0x35, 0x97, 0xfc, 0xb5, 0x76, 0xfc, - 0x47, 0x66, 0x1d, 0xbd, 0x7e, 0x7d, 0xbf, 0x17, 0xf6, 0x10, 0xe0, 0x65, 0x27, 0x5b, 0x0b, 0xea, - 0x43, 0x69, 0xea, 0x08, 0xd7, 0xfb, 0xb7, 0x6b, 0x5b, 0xe9, 0xdf, 0xbe, 0xf5, 0x0e, 0xd1, 0x01, - 0x54, 0xd3, 0x69, 0x4b, 0x8e, 0x79, 0xb7, 0xd8, 0x31, 0xdb, 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. -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 - -// HealthClient is the client API for Health service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type HealthClient interface { - Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) - Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) -} - -type healthClient struct { - cc *grpc.ClientConn -} - -func NewHealthClient(cc *grpc.ClientConn) HealthClient { - return &healthClient{cc} -} - -func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { - out := new(HealthCheckResponse) - err := c.cc.Invoke(ctx, "/health.Health/Check", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -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], "/health.Health/Watch", opts...) - if err != nil { - return nil, err - } - x := &healthWatchClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Health_WatchClient interface { - Recv() (*HealthCheckResponse, error) - grpc.ClientStream -} - -type healthWatchClient struct { - grpc.ClientStream -} - -func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) { - m := new(HealthCheckResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// HealthServer is the server API for Health service. -type HealthServer interface { - Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) - 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) -} - -func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HealthCheckRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(HealthServer).Check(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/health.Health/Check", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(HealthCheckRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(HealthServer).Watch(m, &healthWatchServer{stream}) -} - -type Health_WatchServer interface { - Send(*HealthCheckResponse) error - grpc.ServerStream -} - -type healthWatchServer struct { - grpc.ServerStream -} - -func (x *healthWatchServer) Send(m *HealthCheckResponse) error { - return x.ServerStream.SendMsg(m) -} - -var _Health_serviceDesc = grpc.ServiceDesc{ - ServiceName: "health.Health", - HandlerType: (*HealthServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Check", - Handler: _Health_Check_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Watch", - Handler: _Health_Watch_Handler, - ServerStreams: true, - }, - }, - Metadata: "proto/health/health.proto", -} 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 deleted file mode 100644 index 1fac18020..000000000 --- a/example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go +++ /dev/null @@ -1,129 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: proto/helloworld/helloworld.proto - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -func init() { proto.RegisterFile("proto/helloworld/helloworld.proto", fileDescriptor_d16ac54e3a89a4f6) } - -var fileDescriptor_d16ac54e3a89a4f6 = []byte{ - // 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, 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/health/health_pb.d.ts b/example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts deleted file mode 100644 index 015e32a18..000000000 --- a/example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import * as jspb from "google-protobuf" - -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'; - -export class HealthCheckRequest extends jspb.Message { - getService(): string; - setService(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): HealthCheckRequest.AsObject; - static toObject(includeInstance: boolean, msg: HealthCheckRequest): HealthCheckRequest.AsObject; - static serializeBinaryToWriter(message: HealthCheckRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): HealthCheckRequest; - static deserializeBinaryFromReader(message: HealthCheckRequest, reader: jspb.BinaryReader): HealthCheckRequest; -} - -export namespace HealthCheckRequest { - export type AsObject = { - service: string, - } -} - -export class HealthCheckResponse extends jspb.Message { - getStatus(): HealthCheckResponse.ServingStatus; - setStatus(value: HealthCheckResponse.ServingStatus): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): HealthCheckResponse.AsObject; - static toObject(includeInstance: boolean, msg: HealthCheckResponse): HealthCheckResponse.AsObject; - static serializeBinaryToWriter(message: HealthCheckResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): HealthCheckResponse; - static deserializeBinaryFromReader(message: HealthCheckResponse, reader: jspb.BinaryReader): HealthCheckResponse; -} - -export namespace HealthCheckResponse { - export type AsObject = { - status: HealthCheckResponse.ServingStatus, - } - - export enum ServingStatus { - UNKNOWN = 0, - SERVING = 1, - NOT_SERVING = 2, - SERVICE_UNKNOWN = 3, - } -} - 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 deleted file mode 100644 index 9e09300a8..000000000 --- a/example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -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/go.mod b/example/hello-world/hello-world-idl/go.mod deleted file mode 100644 index 208e33ba3..000000000 --- a/example/hello-world/hello-world-idl/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/yourrepo/hello-world-idl - -go 1.12 diff --git a/example/hello-world/hello-world-idl/proto/health/health.proto b/example/hello-world/hello-world-idl/proto/health/health.proto deleted file mode 100644 index 816499b42..000000000 --- a/example/hello-world/hello-world-idl/proto/health/health.proto +++ /dev/null @@ -1,38 +0,0 @@ -syntax = "proto3"; - -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"; - -option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { - info: { - title: "Health Checks"; - version: "1.0"; - } -}; - -message HealthCheckRequest { - string service = 1; -} - -message HealthCheckResponse { - enum ServingStatus { - UNKNOWN = 0; - SERVING = 1; - NOT_SERVING = 2; - SERVICE_UNKNOWN = 3; - } - ServingStatus status = 1; -} - -service Health { - rpc Check(HealthCheckRequest) returns (HealthCheckResponse){ - option (google.api.http) = { - get: "/v1/health" - }; - } - - rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); -} diff --git a/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto b/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto deleted file mode 100644 index ce1ce7645..000000000 --- a/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; - -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 deleted file mode 100644 index 942274b8d..000000000 --- a/example/hello-world/main.go +++ /dev/null @@ -1,36 +0,0 @@ -package main -import ( - "log" - "net" - - 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" -) - -func main() { - grpcAddr := "0.0.0.0:3000" - lis, err := net.Listen("tcp", grpcAddr) - if err != nil { - log.Fatalf("failed to listen: %v", err) - } - - s := grpc.NewServer() - - //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) - - if err := s.Serve(lis); err != nil { - log.Fatalf("failed to serve: %v", err) - } -} diff --git a/example/hello-world/server/health/health.go b/example/hello-world/server/health/health.go deleted file mode 100644 index cd276d311..000000000 --- a/example/hello-world/server/health/health.go +++ /dev/null @@ -1,25 +0,0 @@ -package health - -import ( - "context" - api "github.com/yourrepo/hello-world-idl/gen/go/health" -) - -type HealthServer struct { - -} - -func NewHealthServer() *HealthServer { - return &HealthServer{} -} - -func (s *HealthServer) Check(ctx context.Context, req *api.HealthCheckRequest) (*api.HealthCheckResponse, error) { - resp := &api.HealthCheckResponse{ - Status: api.HealthCheckResponse_SERVING, - } - return resp,nil -} - -func (s *HealthServer) Watch(req *api.HealthCheckRequest, server api.Health_WatchServer) error { - return nil -} diff --git a/example/hello-world/server/helloworld/helloworld.go b/example/hello-world/server/helloworld/helloworld.go deleted file mode 100644 index f8cded13b..000000000 --- a/example/hello-world/server/helloworld/helloworld.go +++ /dev/null @@ -1,22 +0,0 @@ -package helloworld - -import ( - "context" - health_api "github.com/yourrepo/hello-world-idl/gen/go/health" - //api "github.com/yourrepo/hello-world-idl/gen/go/helloworld" -) - -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 -} diff --git a/example/hello-world/sprout.yml b/example/hello-world/sprout.yml deleted file mode 100644 index 8192e2d54..000000000 --- a/example/hello-world/sprout.yml +++ /dev/null @@ -1,24 +0,0 @@ -organization: mycompany -name: hello-world -description: -git-repo: github.com/yourrepo -docker-repo: -maintainers: -# - name: bob -# email: bob@test.com - -network: - grpc: - host: 0.0.0.0 - port: 3000 - http: - enabled: true - port: 8080 - web: - enabled: true - port: 8090 - - -services: - - name: helloworld - description: Hello world!. From d4a5d79f6f0c6209f44b80f6ad53646b18d1d2ea Mon Sep 17 00:00:00 2001 From: pritesh-patel Date: Sun, 6 Oct 2019 17:02:23 -0700 Subject: [PATCH 2/3] updated example --- example/hello-world/.gitignore | 0 example/hello-world/go.mod | 9 + example/hello-world/hello-world-idl/Makefile | 50 +++ .../gen/go/health/health.pb.go | 301 ++++++++++++++++++ .../gen/go/helloworld/helloworld.pb.go | 119 +++++++ .../gen/http/health/health.pb.gw.go | 162 ++++++++++ .../gen/http/health/health.swagger.json | 117 +++++++ .../gen/http/helloworld/helloworld.pb.gw.go | 163 ++++++++++ .../http/helloworld/helloworld.swagger.json | 63 ++++ .../gen/web/health/healthServiceClientPb.ts | 80 +++++ .../gen/web/health/health_pb.d.ts | 48 +++ .../helloworld/helloworldServiceClientPb.ts | 58 ++++ .../gen/web/helloworld/helloworld_pb.d.ts | 6 + example/hello-world/hello-world-idl/go.mod | 3 + .../hello-world-idl/proto/health/health.proto | 38 +++ .../proto/helloworld/helloworld.proto | 24 ++ example/hello-world/main.go | 36 +++ example/hello-world/server/health/health.go | 25 ++ .../server/helloworld/helloworld.go | 22 ++ example/hello-world/sprout.yml | 24 ++ 20 files changed, 1348 insertions(+) create mode 100644 example/hello-world/.gitignore create mode 100644 example/hello-world/go.mod create mode 100644 example/hello-world/hello-world-idl/Makefile create mode 100644 example/hello-world/hello-world-idl/gen/go/health/health.pb.go create mode 100644 example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go create mode 100644 example/hello-world/hello-world-idl/gen/http/health/health.pb.gw.go create mode 100644 example/hello-world/hello-world-idl/gen/http/health/health.swagger.json create mode 100644 example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.pb.gw.go create mode 100644 example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.swagger.json create mode 100644 example/hello-world/hello-world-idl/gen/web/health/healthServiceClientPb.ts create mode 100644 example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts create mode 100644 example/hello-world/hello-world-idl/gen/web/helloworld/helloworldServiceClientPb.ts create mode 100644 example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts create mode 100644 example/hello-world/hello-world-idl/go.mod create mode 100644 example/hello-world/hello-world-idl/proto/health/health.proto create mode 100644 example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto create mode 100644 example/hello-world/main.go create mode 100644 example/hello-world/server/health/health.go create mode 100644 example/hello-world/server/helloworld/helloworld.go create mode 100644 example/hello-world/sprout.yml diff --git a/example/hello-world/.gitignore b/example/hello-world/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/example/hello-world/go.mod b/example/hello-world/go.mod new file mode 100644 index 000000000..06c12cd4f --- /dev/null +++ b/example/hello-world/go.mod @@ -0,0 +1,9 @@ +module github.com/yourrepo/hello-world + +go 1.12 + +replace github.com/yourrepo/hello-world-idl => ./hello-world-idl + +require ( + github.com/yourrepo/hello-world-idl v0.0.0 +) diff --git a/example/hello-world/hello-world-idl/Makefile b/example/hello-world/hello-world-idl/Makefile new file mode 100644 index 000000000..20e02c511 --- /dev/null +++ b/example/hello-world/hello-world-idl/Makefile @@ -0,0 +1,50 @@ +PROTOC_VERSION := 3.9.2 +PROTOC_WEB_VERSION := 1.0.6 + +PROTO_SOURCES := -I /usr/local/include +PROTO_SOURCES += -I . +PROTO_SOURCES += -I ${GOPATH}/src +PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis +PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway + +deps-linux: deps-protoc-linux deps-grpc-web-linux deps-go + +deps-protoc-linux: + curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-linux-x86_64.zip + unzip protoc-$(PROTOC_VERSION)-linux-x86_64.zip -d protoc3 + sudo mv protoc3/bin/* /usr/local/bin/ + sudo mv protoc3/include/* /usr/local/include/ + rm -rf protoc3 protoc-$(PROTOC_VERSION)-linux-x86_64.zip + +deps-grpc-web-linux: + curl -OL https://github.com/grpc/grpc-web/releases/download/$(PROTOC_WEB_VERSION)/protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 + sudo mv protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 /usr/local/bin/protoc-gen-grpc-web + chmod +x /usr/local/bin/protoc-gen-grpc-web + +deps-go: + go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway + go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger + go get -u github.com/golang/protobuf/protoc-gen-go + +generate: generate-grpc generate-web generate-http + +generate-grpc: + mkdir -p gen/go + 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: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 + 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 new file mode 100644 index 000000000..55db31974 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/go/health/health.pb.go @@ -0,0 +1,301 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: proto/health/health.proto + +package health + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type HealthCheckResponse_ServingStatus int32 + +const ( + HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0 + HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1 + HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2 + HealthCheckResponse_SERVICE_UNKNOWN HealthCheckResponse_ServingStatus = 3 +) + +var HealthCheckResponse_ServingStatus_name = map[int32]string{ + 0: "UNKNOWN", + 1: "SERVING", + 2: "NOT_SERVING", + 3: "SERVICE_UNKNOWN", +} + +var HealthCheckResponse_ServingStatus_value = map[string]int32{ + "UNKNOWN": 0, + "SERVING": 1, + "NOT_SERVING": 2, + "SERVICE_UNKNOWN": 3, +} + +func (x HealthCheckResponse_ServingStatus) String() string { + return proto.EnumName(HealthCheckResponse_ServingStatus_name, int32(x)) +} + +func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_7bb2e9a145ccb86d, []int{1, 0} +} + +type HealthCheckRequest struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HealthCheckRequest) Reset() { *m = HealthCheckRequest{} } +func (m *HealthCheckRequest) String() string { return proto.CompactTextString(m) } +func (*HealthCheckRequest) ProtoMessage() {} +func (*HealthCheckRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_7bb2e9a145ccb86d, []int{0} +} + +func (m *HealthCheckRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HealthCheckRequest.Unmarshal(m, b) +} +func (m *HealthCheckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HealthCheckRequest.Marshal(b, m, deterministic) +} +func (m *HealthCheckRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HealthCheckRequest.Merge(m, src) +} +func (m *HealthCheckRequest) XXX_Size() int { + return xxx_messageInfo_HealthCheckRequest.Size(m) +} +func (m *HealthCheckRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HealthCheckRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HealthCheckRequest proto.InternalMessageInfo + +func (m *HealthCheckRequest) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +type HealthCheckResponse struct { + 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:"-"` +} + +func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} } +func (m *HealthCheckResponse) String() string { return proto.CompactTextString(m) } +func (*HealthCheckResponse) ProtoMessage() {} +func (*HealthCheckResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7bb2e9a145ccb86d, []int{1} +} + +func (m *HealthCheckResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HealthCheckResponse.Unmarshal(m, b) +} +func (m *HealthCheckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HealthCheckResponse.Marshal(b, m, deterministic) +} +func (m *HealthCheckResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HealthCheckResponse.Merge(m, src) +} +func (m *HealthCheckResponse) XXX_Size() int { + return xxx_messageInfo_HealthCheckResponse.Size(m) +} +func (m *HealthCheckResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HealthCheckResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HealthCheckResponse proto.InternalMessageInfo + +func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { + if m != nil { + return m.Status + } + return HealthCheckResponse_UNKNOWN +} + +func init() { + 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{ + // 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, 0x71, 0x0d, 0x4a, 0x42, 0x83, 0xaf, 0x1c, 0x4a, 0x49, 0x8c, 0x59, 0x24, 0x19, + 0xbf, 0xd9, 0xba, 0x09, 0xe8, 0x4a, 0xba, 0x0e, 0x3c, 0xe2, 0x3e, 0xda, 0xe4, 0x39, 0x21, 0x5c, + 0xa0, 0x26, 0x94, 0x39, 0x89, 0x97, 0xbe, 0x4b, 0x9a, 0x4a, 0x4b, 0x39, 0xdd, 0xb5, 0x73, 0xa8, + 0x7f, 0x2a, 0xd0, 0xd8, 0x10, 0xf0, 0x88, 0x85, 0x9c, 0xa0, 0x1e, 0xa8, 0x5c, 0x38, 0x22, 0xe1, + 0x52, 0xb0, 0xdf, 0x3d, 0x33, 0xb3, 0xe8, 0x5b, 0xc8, 0xe6, 0x78, 0x6d, 0x16, 0xd2, 0xb1, 0x14, + 0xd8, 0x99, 0x50, 0x1f, 0x41, 0x75, 0x63, 0x80, 0x2a, 0x50, 0xbe, 0xb3, 0x6e, 0xac, 0xd1, 0xd4, + 0xaa, 0xef, 0xac, 0xc1, 0x78, 0x68, 0xdf, 0x5f, 0x5b, 0x97, 0x75, 0x05, 0xd5, 0xa0, 0x62, 0x8d, + 0x26, 0xb3, 0xbc, 0x51, 0x40, 0x0d, 0xa8, 0x49, 0x30, 0x18, 0xce, 0x72, 0x49, 0xb1, 0xfb, 0xa1, + 0x80, 0x9a, 0x3e, 0x8f, 0x26, 0x50, 0x92, 0x11, 0x90, 0xb6, 0x35, 0x97, 0xfc, 0xb5, 0x76, 0xfc, + 0x47, 0x66, 0x1d, 0xbd, 0x7e, 0x7d, 0xbf, 0x17, 0xf6, 0x10, 0xe0, 0x65, 0x27, 0x5b, 0x0b, 0xea, + 0x43, 0x69, 0xea, 0x08, 0xd7, 0xfb, 0xb7, 0x6b, 0x5b, 0xe9, 0xdf, 0xbe, 0xf5, 0x0e, 0xd1, 0x01, + 0x54, 0xd3, 0x69, 0x4b, 0x8e, 0x79, 0xb7, 0xd8, 0x31, 0xdb, 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. +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 + +// HealthClient is the client API for Health service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type HealthClient interface { + Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) + Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) +} + +type healthClient struct { + cc *grpc.ClientConn +} + +func NewHealthClient(cc *grpc.ClientConn) HealthClient { + return &healthClient{cc} +} + +func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { + out := new(HealthCheckResponse) + err := c.cc.Invoke(ctx, "/health.Health/Check", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +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], "/health.Health/Watch", opts...) + if err != nil { + return nil, err + } + x := &healthWatchClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Health_WatchClient interface { + Recv() (*HealthCheckResponse, error) + grpc.ClientStream +} + +type healthWatchClient struct { + grpc.ClientStream +} + +func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) { + m := new(HealthCheckResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// HealthServer is the server API for Health service. +type HealthServer interface { + Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) + Watch(*HealthCheckRequest, Health_WatchServer) error +} + +func RegisterHealthServer(s *grpc.Server, srv HealthServer) { + s.RegisterService(&_Health_serviceDesc, srv) +} + +func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HealthServer).Check(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/health.Health/Check", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(HealthCheckRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(HealthServer).Watch(m, &healthWatchServer{stream}) +} + +type Health_WatchServer interface { + Send(*HealthCheckResponse) error + grpc.ServerStream +} + +type healthWatchServer struct { + grpc.ServerStream +} + +func (x *healthWatchServer) Send(m *HealthCheckResponse) error { + return x.ServerStream.SendMsg(m) +} + +var _Health_serviceDesc = grpc.ServiceDesc{ + ServiceName: "health.Health", + HandlerType: (*HealthServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Check", + Handler: _Health_Check_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Watch", + Handler: _Health_Watch_Handler, + ServerStreams: true, + }, + }, + Metadata: "proto/health/health.proto", +} 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 new file mode 100644 index 000000000..a0a7f2497 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/go/helloworld/helloworld.pb.go @@ -0,0 +1,119 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: proto/helloworld/helloworld.proto + +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" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("proto/helloworld/helloworld.proto", fileDescriptor_d16ac54e3a89a4f6) } + +var fileDescriptor_d16ac54e3a89a4f6 = []byte{ + // 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, 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) +} + +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/http/health/health.pb.gw.go b/example/hello-world/hello-world-idl/gen/http/health/health.pb.gw.go new file mode 100644 index 000000000..16fe3bea7 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/http/health/health.pb.gw.go @@ -0,0 +1,162 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: proto/health/health.proto + +/* +Package health is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package health + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +var ( + filter_Health_Check_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Health_Check_0(ctx context.Context, marshaler runtime.Marshaler, client HealthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq HealthCheckRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Health_Check_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Check(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Health_Check_0(ctx context.Context, marshaler runtime.Marshaler, server HealthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq HealthCheckRequest + var metadata runtime.ServerMetadata + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Health_Check_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Check(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterHealthHandlerServer registers the http handlers for service Health to "mux". +// UnaryRPC :call HealthServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterHealthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HealthServer) error { + + mux.Handle("GET", pattern_Health_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Health_Check_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Health_Check_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterHealthHandlerFromEndpoint is same as RegisterHealthHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterHealthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterHealthHandler(ctx, mux, conn) +} + +// RegisterHealthHandler registers the http handlers for service Health to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterHealthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterHealthHandlerClient(ctx, mux, NewHealthClient(conn)) +} + +// RegisterHealthHandlerClient registers the http handlers for service Health +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "HealthClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "HealthClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "HealthClient" to call the correct interceptors. +func RegisterHealthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client HealthClient) error { + + mux.Handle("GET", pattern_Health_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Health_Check_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Health_Check_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Health_Check_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "health"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Health_Check_0 = runtime.ForwardResponseMessage +) diff --git a/example/hello-world/hello-world-idl/gen/http/health/health.swagger.json b/example/hello-world/hello-world-idl/gen/http/health/health.swagger.json new file mode 100644 index 000000000..5ecef0a83 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/http/health/health.swagger.json @@ -0,0 +1,117 @@ +{ + "swagger": "2.0", + "info": { + "title": "Health Checks", + "version": "1.0" + }, + "schemes": [ + "http", + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v1/health": { + "get": { + "operationId": "Check", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/healthHealthCheckResponse" + } + } + }, + "parameters": [ + { + "name": "service", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "Health" + ] + } + } + }, + "definitions": { + "HealthCheckResponseServingStatus": { + "type": "string", + "enum": [ + "UNKNOWN", + "SERVING", + "NOT_SERVING", + "SERVICE_UNKNOWN" + ], + "default": "UNKNOWN" + }, + "healthHealthCheckResponse": { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/HealthCheckResponseServingStatus" + } + } + }, + "protobufAny": { + "type": "object", + "properties": { + "type_url": { + "type": "string", + "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." + }, + "value": { + "type": "string", + "format": "byte", + "description": "Must be a valid serialized protocol buffer of the above specified type." + } + }, + "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := ptypes.MarshalAny(foo)\n ...\n foo := \u0026pb.Foo{}\n if err := ptypes.UnmarshalAny(any, foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" + }, + "runtimeStreamError": { + "type": "object", + "properties": { + "grpc_code": { + "type": "integer", + "format": "int32" + }, + "http_code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "http_status": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + }, + "x-stream-definitions": { + "healthHealthCheckResponse": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/healthHealthCheckResponse" + }, + "error": { + "$ref": "#/definitions/runtimeStreamError" + } + }, + "title": "Stream result of healthHealthCheckResponse" + } + } +} diff --git a/example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.pb.gw.go b/example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.pb.gw.go new file mode 100644 index 000000000..1e17d4153 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.pb.gw.go @@ -0,0 +1,163 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: proto/helloworld/helloworld.proto + +/* +Package helloworld is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package helloworld + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "github.com/yourrepo/hello-world-idl/gen/go/health" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +var ( + filter_Helloworld_Check_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Helloworld_Check_0(ctx context.Context, marshaler runtime.Marshaler, client HelloworldClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq health.HealthCheckRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Helloworld_Check_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Check(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Helloworld_Check_0(ctx context.Context, marshaler runtime.Marshaler, server HelloworldServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq health.HealthCheckRequest + var metadata runtime.ServerMetadata + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Helloworld_Check_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Check(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterHelloworldHandlerServer registers the http handlers for service Helloworld to "mux". +// UnaryRPC :call HelloworldServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterHelloworldHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HelloworldServer) error { + + mux.Handle("GET", pattern_Helloworld_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Helloworld_Check_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Helloworld_Check_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterHelloworldHandlerFromEndpoint is same as RegisterHelloworldHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterHelloworldHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterHelloworldHandler(ctx, mux, conn) +} + +// RegisterHelloworldHandler registers the http handlers for service Helloworld to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterHelloworldHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterHelloworldHandlerClient(ctx, mux, NewHelloworldClient(conn)) +} + +// RegisterHelloworldHandlerClient registers the http handlers for service Helloworld +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "HelloworldClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "HelloworldClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "HelloworldClient" to call the correct interceptors. +func RegisterHelloworldHandlerClient(ctx context.Context, mux *runtime.ServeMux, client HelloworldClient) error { + + mux.Handle("GET", pattern_Helloworld_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Helloworld_Check_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Helloworld_Check_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Helloworld_Check_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "helloworld", "health"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Helloworld_Check_0 = runtime.ForwardResponseMessage +) diff --git a/example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.swagger.json b/example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.swagger.json new file mode 100644 index 000000000..daf0e175e --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/http/helloworld/helloworld.swagger.json @@ -0,0 +1,63 @@ +{ + "swagger": "2.0", + "info": { + "title": "Helloworld", + "version": "1.0" + }, + "schemes": [ + "http", + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v1/helloworld/health": { + "get": { + "operationId": "Check", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/healthHealthCheckResponse" + } + } + }, + "parameters": [ + { + "name": "service", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "Helloworld" + ] + } + } + }, + "definitions": { + "HealthCheckResponseServingStatus": { + "type": "string", + "enum": [ + "UNKNOWN", + "SERVING", + "NOT_SERVING", + "SERVICE_UNKNOWN" + ], + "default": "UNKNOWN" + }, + "healthHealthCheckResponse": { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/HealthCheckResponseServingStatus" + } + } + } + } +} diff --git a/example/hello-world/hello-world-idl/gen/web/health/healthServiceClientPb.ts b/example/hello-world/hello-world-idl/gen/web/health/healthServiceClientPb.ts new file mode 100644 index 000000000..d9f55f41a --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/web/health/healthServiceClientPb.ts @@ -0,0 +1,80 @@ +/** + * @fileoverview gRPC-Web generated client stub for health + * @enhanceable + * @public + */ + +// GENERATED CODE -- DO NOT EDIT! + + +import * as grpcWeb from 'grpc-web'; + +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'; + +import { + HealthCheckRequest, + HealthCheckResponse} from './health_pb'; + +export class HealthClient { + client_: grpcWeb.AbstractClientBase; + hostname_: string; + credentials_: null | { [index: string]: string; }; + options_: null | { [index: string]: string; }; + + constructor (hostname: string, + credentials?: null | { [index: string]: string; }, + options?: null | { [index: string]: string; }) { + if (!options) options = {}; + if (!credentials) credentials = {}; + options['format'] = 'text'; + + this.client_ = new grpcWeb.GrpcWebClientBase(options); + this.hostname_ = hostname; + this.credentials_ = credentials; + this.options_ = options; + } + + methodInfoCheck = new grpcWeb.AbstractClientBase.MethodInfo( + HealthCheckResponse, + (request: HealthCheckRequest) => { + return request.serializeBinary(); + }, + HealthCheckResponse.deserializeBinary + ); + + check( + request: HealthCheckRequest, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.Error, + response: HealthCheckResponse) => void) { + return this.client_.rpcCall( + this.hostname_ + + '/health.Health/Check', + request, + metadata || {}, + this.methodInfoCheck, + callback); + } + + methodInfoWatch = new grpcWeb.AbstractClientBase.MethodInfo( + HealthCheckResponse, + (request: HealthCheckRequest) => { + return request.serializeBinary(); + }, + HealthCheckResponse.deserializeBinary + ); + + watch( + request: HealthCheckRequest, + metadata?: grpcWeb.Metadata) { + return this.client_.serverStreaming( + this.hostname_ + + '/health.Health/Watch', + request, + metadata || {}, + this.methodInfoWatch); + } + +} + diff --git a/example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts b/example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts new file mode 100644 index 000000000..015e32a18 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/web/health/health_pb.d.ts @@ -0,0 +1,48 @@ +import * as jspb from "google-protobuf" + +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'; + +export class HealthCheckRequest extends jspb.Message { + getService(): string; + setService(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HealthCheckRequest.AsObject; + static toObject(includeInstance: boolean, msg: HealthCheckRequest): HealthCheckRequest.AsObject; + static serializeBinaryToWriter(message: HealthCheckRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HealthCheckRequest; + static deserializeBinaryFromReader(message: HealthCheckRequest, reader: jspb.BinaryReader): HealthCheckRequest; +} + +export namespace HealthCheckRequest { + export type AsObject = { + service: string, + } +} + +export class HealthCheckResponse extends jspb.Message { + getStatus(): HealthCheckResponse.ServingStatus; + setStatus(value: HealthCheckResponse.ServingStatus): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HealthCheckResponse.AsObject; + static toObject(includeInstance: boolean, msg: HealthCheckResponse): HealthCheckResponse.AsObject; + static serializeBinaryToWriter(message: HealthCheckResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HealthCheckResponse; + static deserializeBinaryFromReader(message: HealthCheckResponse, reader: jspb.BinaryReader): HealthCheckResponse; +} + +export namespace HealthCheckResponse { + export type AsObject = { + status: HealthCheckResponse.ServingStatus, + } + + export enum ServingStatus { + UNKNOWN = 0, + SERVING = 1, + NOT_SERVING = 2, + SERVICE_UNKNOWN = 3, + } +} + diff --git a/example/hello-world/hello-world-idl/gen/web/helloworld/helloworldServiceClientPb.ts b/example/hello-world/hello-world-idl/gen/web/helloworld/helloworldServiceClientPb.ts new file mode 100644 index 000000000..e3cabaaa2 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/web/helloworld/helloworldServiceClientPb.ts @@ -0,0 +1,58 @@ +/** + * @fileoverview gRPC-Web generated client stub for helloworld + * @enhanceable + * @public + */ + +// GENERATED CODE -- DO NOT EDIT! + + +import * as grpcWeb from 'grpc-web'; + +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'; + +export class HelloworldClient { + client_: grpcWeb.AbstractClientBase; + hostname_: string; + credentials_: null | { [index: string]: string; }; + options_: null | { [index: string]: string; }; + + constructor (hostname: string, + credentials?: null | { [index: string]: string; }, + options?: null | { [index: string]: string; }) { + if (!options) options = {}; + if (!credentials) credentials = {}; + options['format'] = 'text'; + + this.client_ = new grpcWeb.GrpcWebClientBase(options); + this.hostname_ = hostname; + this.credentials_ = credentials; + this.options_ = options; + } + + methodInfoCheck = new grpcWeb.AbstractClientBase.MethodInfo( + proto_health_health_pb.HealthCheckResponse, + (request: proto_health_health_pb.HealthCheckRequest) => { + return request.serializeBinary(); + }, + proto_health_health_pb.HealthCheckResponse.deserializeBinary + ); + + check( + request: proto_health_health_pb.HealthCheckRequest, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.Error, + response: proto_health_health_pb.HealthCheckResponse) => void) { + return this.client_.rpcCall( + this.hostname_ + + '/helloworld.Helloworld/Check', + request, + metadata || {}, + this.methodInfoCheck, + callback); + } + +} + 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 new file mode 100644 index 000000000..9e09300a8 --- /dev/null +++ b/example/hello-world/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts @@ -0,0 +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/go.mod b/example/hello-world/hello-world-idl/go.mod new file mode 100644 index 000000000..208e33ba3 --- /dev/null +++ b/example/hello-world/hello-world-idl/go.mod @@ -0,0 +1,3 @@ +module github.com/yourrepo/hello-world-idl + +go 1.12 diff --git a/example/hello-world/hello-world-idl/proto/health/health.proto b/example/hello-world/hello-world-idl/proto/health/health.proto new file mode 100644 index 000000000..816499b42 --- /dev/null +++ b/example/hello-world/hello-world-idl/proto/health/health.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +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"; + +option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { + info: { + title: "Health Checks"; + version: "1.0"; + } +}; + +message HealthCheckRequest { + string service = 1; +} + +message HealthCheckResponse { + enum ServingStatus { + UNKNOWN = 0; + SERVING = 1; + NOT_SERVING = 2; + SERVICE_UNKNOWN = 3; + } + ServingStatus status = 1; +} + +service Health { + rpc Check(HealthCheckRequest) returns (HealthCheckResponse){ + option (google.api.http) = { + get: "/v1/health" + }; + } + + rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); +} diff --git a/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto b/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto new file mode 100644 index 000000000..ce1ce7645 --- /dev/null +++ b/example/hello-world/hello-world-idl/proto/helloworld/helloworld.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +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 new file mode 100644 index 000000000..942274b8d --- /dev/null +++ b/example/hello-world/main.go @@ -0,0 +1,36 @@ +package main +import ( + "log" + "net" + + 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" +) + +func main() { + grpcAddr := "0.0.0.0:3000" + lis, err := net.Listen("tcp", grpcAddr) + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + + s := grpc.NewServer() + + //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) + + if err := s.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } +} diff --git a/example/hello-world/server/health/health.go b/example/hello-world/server/health/health.go new file mode 100644 index 000000000..cd276d311 --- /dev/null +++ b/example/hello-world/server/health/health.go @@ -0,0 +1,25 @@ +package health + +import ( + "context" + api "github.com/yourrepo/hello-world-idl/gen/go/health" +) + +type HealthServer struct { + +} + +func NewHealthServer() *HealthServer { + return &HealthServer{} +} + +func (s *HealthServer) Check(ctx context.Context, req *api.HealthCheckRequest) (*api.HealthCheckResponse, error) { + resp := &api.HealthCheckResponse{ + Status: api.HealthCheckResponse_SERVING, + } + return resp,nil +} + +func (s *HealthServer) Watch(req *api.HealthCheckRequest, server api.Health_WatchServer) error { + return nil +} diff --git a/example/hello-world/server/helloworld/helloworld.go b/example/hello-world/server/helloworld/helloworld.go new file mode 100644 index 000000000..f8cded13b --- /dev/null +++ b/example/hello-world/server/helloworld/helloworld.go @@ -0,0 +1,22 @@ +package helloworld + +import ( + "context" + health_api "github.com/yourrepo/hello-world-idl/gen/go/health" + //api "github.com/yourrepo/hello-world-idl/gen/go/helloworld" +) + +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 +} diff --git a/example/hello-world/sprout.yml b/example/hello-world/sprout.yml new file mode 100644 index 000000000..8192e2d54 --- /dev/null +++ b/example/hello-world/sprout.yml @@ -0,0 +1,24 @@ +organization: mycompany +name: hello-world +description: +git-repo: github.com/yourrepo +docker-repo: +maintainers: +# - name: bob +# email: bob@test.com + +network: + grpc: + host: 0.0.0.0 + port: 3000 + http: + enabled: true + port: 8080 + web: + enabled: true + port: 8090 + + +services: + - name: helloworld + description: Hello world!. From 66920758a99ec4226a71345a5203c4c8e8207711 Mon Sep 17 00:00:00 2001 From: pritesh-patel Date: Sun, 6 Oct 2019 17:03:02 -0700 Subject: [PATCH 3/3] add generated git ignore --- example/hello-world/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/example/hello-world/.gitignore b/example/hello-world/.gitignore index e69de29bb..55283c232 100644 --- a/example/hello-world/.gitignore +++ b/example/hello-world/.gitignore @@ -0,0 +1 @@ +/hello-world-idl