-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revived the example with a new structure and docs #5
Open
DennisSSDev
wants to merge
4
commits into
master
Choose a base branch
from
update-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/_bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2020 Twitch Interactive, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not | ||
# use this file except in compliance with the License. A copy of the License is | ||
# located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on | ||
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
# express or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
|
||
FROM golang:latest AS build | ||
WORKDIR /go/src/github.com/twitchtv/twirp-example | ||
COPY . . | ||
RUN make build | ||
|
||
FROM alpine | ||
RUN apk add --no-cache ca-certificates | ||
WORKDIR /app | ||
COPY --from=build /go/bin/twirp-example /app/ | ||
EXPOSE 8000 | ||
ENTRYPOINT ["./twirp-example"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2020 Twitch Interactive, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not | ||
# use this file except in compliance with the License. A copy of the License is | ||
# located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on | ||
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
# express or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
|
||
M = $(shell printf "\033[34;1m▶\033[0m") | ||
|
||
export GOBIN = $(CURDIR)/_bin | ||
export PROTOPATH = $(GOPATH)/src | ||
export BINDIR := $(GOBIN) | ||
export PATH := $(GOBIN):$(PATH) | ||
|
||
protoc_gen_go := $(GOBIN)/protoc-gen-go | ||
protoc_gen_go_src := vendor/github.com/golang/protobuf/protoc-gen-go | ||
|
||
protoc_gen_twirp := $(GOBIN)/protoc-gen-twirp | ||
protoc_gen_twirp_src := vendor/github.com/twitchtv/twirp/protoc-gen-twirp | ||
|
||
build: $(info $(M) Building project...) | ||
@ CGO_ENABLED=0 go build -o /go/bin/twirp-example ./cmd/server/*.go | ||
.PHONY: build | ||
|
||
gen-twirp: $(protoc_gen_go) $(protoc_gen_twirp) | ||
$(info $(M) Generating twirp files...) | ||
@protoc --proto_path=$(GOBIN):. --twirp_out=. --go_out=. ./rpc/haberdasher/service.proto | ||
.PHONY: gen-twirp | ||
|
||
$(protoc_gen_go): $(protoc_gen_go_src) | ||
@go install ./$^ | ||
|
||
$(protoc_gen_twirp): $(protoc_gen_twirp_src) | ||
@go install ./$^ | ||
|
||
server: | ||
$(info $(M) Starting Development server...) | ||
go run ./cmd/server/main.go | ||
|
||
client: | ||
$(info $(M) Starting Client...) | ||
go run ./cmd/client/main.go | ||
|
||
docker-image: | ||
$(info $(M) Building app image...) | ||
docker build -t example . | ||
|
||
docker-container: docker-image | ||
$(info $(M) Running docker application container...) | ||
docker run -p 8080:8080 example:latest | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved. | ||
// Copyright 2020 Twitch Interactive, Inc. All Rights Reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2021 already 🎉 |
||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may not | ||
// use this file except in compliance with the License. A copy of the License is | ||
|
@@ -26,7 +26,7 @@ import ( | |
func main() { | ||
// Create a client capable of talking to a Haberdasher server running on | ||
// localhost. This is a generated function call. | ||
client := haberdasher.NewHaberdasherJSONClient("http://localhost:8080", &http.Client{}) | ||
client := haberdasher.NewHaberdasherProtobufClient("http://localhost:8080", &http.Client{}) | ||
|
||
var ( | ||
hat *haberdasher.Hat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module github.com/twitchtv/twirp-example | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/golang/protobuf v1.4.3 | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
github.com/twitchtv/twirp v7.1.1+incompatible | ||
google.golang.org/protobuf v1.25.0 | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
$(info ...)
is neat, but I would remove any "advanced" features from this Makefile. Let's try to keep just the minimal to run the twirp example. Instead of that, we could add a comment.