Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions example/hello-world-idl/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
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

deps-linux: deps-protoc-linux deps-grpc-web-linux


deps-linux:
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

generate:
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

generate: generate-grpc generate-web

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
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

45 changes: 45 additions & 0 deletions example/hello-world-idl/gen/web/health/health_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as jspb from "google-protobuf"

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,
}
}

2 changes: 2 additions & 0 deletions example/hello-world-idl/gen/web/helloworld/helloworld_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as jspb from "google-protobuf"

2 changes: 1 addition & 1 deletion example/hello-world/sprout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ network:
grpc:
host: 0.0.0.0
port: 3000
http:
web:
enabled: true
port: 8080
graphql:
Expand Down
26 changes: 23 additions & 3 deletions templates/proto/makefile.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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
Expand All @@ -7,16 +8,23 @@ PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_p
{{- $language := .Language }}
{{- $http := .Network.Http.Enabled }}

deps-linux: deps-protoc-linux deps-grpc-web-linux


deps-linux:
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

generate:
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

generate: generate-grpc {{ if .Network.Web.Enabled }}generate-web{{- end}}

generate-grpc:
mkdir -p gen/{{ $language }}
protoc ${PROTO_SOURCES} --{{ $language }}_out=plugins=grpc:./gen/{{ $language }} ./proto/health/*.proto
{{- range .Services}}
Expand All @@ -25,3 +33,15 @@ generate:
cp -f -rv gen/go/proto/* gen/go
rm -rf gen/go/proto


{{- if .Network.Web.Enabled }}
generate-web:
mkdir -p gen/web
protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/health/*.proto
{{- range .Services}}
protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/{{ .Name }}/*.proto
{{- end }}
cp -f -rv gen/web/proto/* gen/web
rm -rf gen/web/Proto gen/web/proto
{{- end}}

5 changes: 1 addition & 4 deletions templates/sprout/sprout.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ network:
grpc:
host: 0.0.0.0
port: 3000
http:
web:
enabled: true
port: 8080
graphql:
enabled: true
port: 8082

services:
- name: helloworld
Expand Down