Skip to content

Commit 4b2e677

Browse files
committed
init
1 parent edb5253 commit 4b2e677

34 files changed

+11652
-0
lines changed

.github/workflows/test.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Tests
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
14+
http-server:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./http-server
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v3
24+
with:
25+
go-version: 1.18
26+
27+
- name: Build
28+
run: go build -v ./...
29+
30+
- name: Test
31+
run: go test -race -cover -coverprofile=coverage.out $(go list ./... | grep -Ev "_gen") -coverpkg $(go list ./... | grep -Ev "_gen" | tr "\n" "," | sed 's/.$//')
32+
33+
- name: Show coverage
34+
run: go tool cover -func=coverage.out | awk 'END {print $NF}'
35+
36+
rpc-server:
37+
runs-on: ubuntu-latest
38+
defaults:
39+
run:
40+
working-directory: ./rpc-server
41+
steps:
42+
- uses: actions/checkout@v3
43+
44+
- name: Set up Go
45+
uses: actions/setup-go@v3
46+
with:
47+
go-version: 1.18
48+
49+
- name: Build
50+
run: go build -v ./...
51+
52+
- name: Test
53+
run: go test -race -cover -coverprofile=coverage.out $(go list ./... | grep -Ev "_gen") -coverpkg $(go list ./... | grep -Ev "_gen" | tr "\n" "," | sed 's/.$//')
54+
55+
- name: Show coverage
56+
run: go tool cover -func=coverage.out | awk 'END {print $NF}'
57+
58+
docker-compose:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v3
62+
63+
- name: Run Docker Compose
64+
run: docker-compose up -d
65+
66+
- name: Check service status
67+
run: |
68+
if docker-compose ps | grep -q 'Exit'; then
69+
echo "Some services exited unexpectedly"
70+
exit 1
71+
else
72+
echo "All services are running"
73+
fi

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pre:
2+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
3+
go install github.com/cloudwego/kitex/tool/cmd/kitex@latest
4+
go install github.com/cloudwego/thriftgo@latest
5+
6+
generate:
7+
mkdir -p ./http-server/proto_gen
8+
protoc -I=. --go_out=./http-server/proto_gen ./idl_http.proto
9+
cd http-server && kitex -module github.com/TikTokTechImmersion/assignment_demo_2023/http-server ../idl_rpc.thrift
10+
cd rpc-server && kitex -module github.com/TikTokTechImmersion/assignment_demo_2023/rpc-server ../idl_rpc.thrift

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# assignment_demo_2023
2+
3+
![Tests](https://github.com/TikTokTechImmersion/assignment_demo_2023/actions/workflows/test.yml/badge.svg)
4+
25
This is a demo and template for backend assignment of 2023 TikTok Tech Immersion.

docker-compose.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.9'
2+
services:
3+
rpc-server:
4+
build: rpc-server
5+
ports:
6+
- "8888:8888"
7+
environment:
8+
- SERVICE_NAME=rpc-server
9+
- SERVICE_TAGS=rpc
10+
depends_on:
11+
- etcd
12+
http-server:
13+
build: http-server
14+
ports:
15+
- "8080:8080"
16+
environment:
17+
- SERVICE_NAME=http-server
18+
- SERVICE_TAGS=http
19+
depends_on:
20+
- etcd
21+
- rpc-server
22+
etcd:
23+
image: quay.io/coreos/etcd:v3.5.0
24+
command: ["etcd", "--advertise-client-urls", "http://etcd:2379", "--listen-client-urls", "http://0.0.0.0:2379"]
25+
ports:
26+
- "2379:2379"

http-server/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM golang:1.18
2+
WORKDIR /app
3+
COPY . .
4+
RUN go build -o main
5+
EXPOSE 8080
6+
CMD ["./main"]

http-server/go.mod

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module github.com/TikTokTechImmersion/assignment_demo_2023/http-server
2+
3+
go 1.18
4+
5+
require (
6+
github.com/apache/thrift v0.13.0
7+
github.com/cloudwego/hertz v0.6.1
8+
github.com/cloudwego/kitex v0.5.2
9+
github.com/kitex-contrib/registry-etcd v0.1.0
10+
google.golang.org/protobuf v1.28.1
11+
)
12+
13+
require (
14+
github.com/bytedance/go-tagexpr/v2 v2.9.2 // indirect
15+
github.com/bytedance/gopkg v0.0.0-20220817015305-b879a72dc90f // indirect
16+
github.com/bytedance/sonic v1.8.1 // indirect
17+
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
18+
github.com/chenzhuoyu/iasm v0.0.0-20230222070914-0b1b64b0e762 // indirect
19+
github.com/choleraehyq/pid v0.0.16 // indirect
20+
github.com/cloudwego/fastpb v0.0.4 // indirect
21+
github.com/cloudwego/frugal v0.1.6 // indirect
22+
github.com/cloudwego/netpoll v0.3.2 // indirect
23+
github.com/cloudwego/thriftgo v0.2.9 // indirect
24+
github.com/coreos/go-semver v0.3.0 // indirect
25+
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
26+
github.com/fsnotify/fsnotify v1.5.4 // indirect
27+
github.com/gogo/protobuf v1.3.2 // indirect
28+
github.com/golang/protobuf v1.5.2 // indirect
29+
github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 // indirect
30+
github.com/henrylee2cn/ameda v1.4.10 // indirect
31+
github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect
32+
github.com/jhump/protoreflect v1.8.2 // indirect
33+
github.com/json-iterator/go v1.1.12 // indirect
34+
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
35+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
36+
github.com/modern-go/reflect2 v1.0.2 // indirect
37+
github.com/nyaruka/phonenumbers v1.0.55 // indirect
38+
github.com/oleiade/lane v1.0.1 // indirect
39+
github.com/sirupsen/logrus v1.8.1 // indirect
40+
github.com/smartystreets/goconvey v1.7.2 // indirect
41+
github.com/tidwall/gjson v1.13.0 // indirect
42+
github.com/tidwall/match v1.1.1 // indirect
43+
github.com/tidwall/pretty v1.2.0 // indirect
44+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
45+
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
46+
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
47+
go.etcd.io/etcd/client/v3 v3.5.5 // indirect
48+
go.uber.org/atomic v1.8.0 // indirect
49+
go.uber.org/multierr v1.6.0 // indirect
50+
go.uber.org/zap v1.17.0 // indirect
51+
golang.org/x/arch v0.2.0 // indirect
52+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
53+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
54+
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
55+
golang.org/x/text v0.6.0 // indirect
56+
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
57+
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
58+
google.golang.org/grpc v1.41.0 // indirect
59+
gopkg.in/yaml.v3 v3.0.1 // indirect
60+
)
61+
62+
replace github.com/apache/thrift => github.com/apache/thrift v0.13.0

0 commit comments

Comments
 (0)