Group name: Point of Go return
- Adrian Borup (adbo@itu.dk)
- Andreas Wachs (ahja@itu.dk)
- Anne M. Bartholdy-Falk (anmb@itu.dk)
- Joachim Borup (aljb@itu.dk)
To run the server, enter the server
folder and run go run .
. The server will then be listening at localhost:8080
.
Note: the server does not contain actual business logic - i.e. the requests don't actually do anything. It's just a constant response.
To run the client, enter the client
folder and run go run main.go
.
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative service.proto
Build the docker image inside the gRPC
folder with
docker build -t gogrpc .
To spin up the container, run:
# unix
docker run -it --rm -v "$(pwd)":/app --network="host" gogrpc bash
# windows
docker run -it --rm -v ${pwd}:/app --network="host" gogrpc bash
This assumes that you are in the gRPC
folder! Note, if your path has spaces, it may very well not work.
cd /app && \
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative --experimental_allow_proto3_optional service/service.proto
cd /app/server && \
go run .
cd /app/client && \
go run .
2021/10/03 21:47:39 Server started
2021/10/03 21:47:46 GET /course/1 CourseCourseIdGet 0s
2021/10/03 21:47:46 POST /course CoursePost 0s
2021/10/03 21:47:46 PUT /course/1 CourseCourseIdPut 0s
2021/10/03 21:47:46 DELETE /course/1 CourseCourseIdDelete 0s
Requesting [GET] http://127.0.0.1:8080/course/1
{
"id": 0,
"name": "string",
"expectedWorkload": 0,
"rating": 0
}
Requesting [POST] http://127.0.0.1:8080/course
{
"id": 0,
"name": "string",
"expectedWorkload": 0,
"rating": 0
}
Requesting [PUT] http://127.0.0.1:8080/course/1
{
"id": 0,
"name": "string",
"expectedWorkload": 0,
"rating": 0
}
Requesting [DELETE] http://127.0.0.1:8080/course/1
{
"id": 0,
"name": "string",
"expectedWorkload": 0,
"rating": 0
}
2021/10/05 10:13:16 NewCourse() call recieved.
2021/10/05 10:13:16 GetCourse() call recieved.
2021/10/05 10:13:16 DeleteCourse() call recieved.
2021/10/05 10:13:16 EditCourse() call recieved.
2021/10/05 10:13:16 NewCourse: name:"name" expectedWorkload:9000 rating:5
2021/10/05 10:13:16 GetCourse: id:1 name:"name" expectedWorkload:9000 rating:5
2021/10/05 10:13:16 DeleteCourse: id:1 name:"name" expectedWorkload:9000 rating:5
2021/10/05 10:13:16 EditCourse: id:1 name:"Distributed Systems" expectedWorkload:1000000 rating:5