Skip to content

Commit

Permalink
Update gRPC endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
federicotdn committed Nov 27, 2024
1 parent 680e50f commit 59d44ef
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 69 deletions.
9 changes: 6 additions & 3 deletions pkg/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ func (s *serverImplementation) Status(_ context.Context, in *pb.StatusRequest) (
return &pb.StatusResponse{Ready: true}, nil
}

func (s *serverImplementation) EvaluatePizza(_ context.Context, in *pb.PizzaEvaluationRequest) (*pb.PizzaEvaluationResponse, error) {
func (s *serverImplementation) RatePizza(_ context.Context, in *pb.PizzaRatingRequest) (*pb.PizzaRatingResponse, error) {
var rating int32
if len(in.Ingredients) > 0 && in.Dough != "" {
if len(in.Ingredients) > 0 {
rating = rand.Int31n(6)
}
return &pb.PizzaEvaluationResponse{
if in.Dough != "" && rating < 5 {
rating += rand.Int31n(2)
}
return &pb.PizzaRatingResponse{
StarsRating: rating,
}, nil
}
Expand Down
92 changes: 45 additions & 47 deletions pkg/grpc/quickpizza/quickpizza.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions pkg/grpc/quickpizza/quickpizza_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions proto/quickpizza.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package quickpizza;

service GRPC {
rpc Status(StatusRequest) returns (StatusResponse) {}
rpc EvaluatePizza(PizzaEvaluationRequest) returns (PizzaEvaluationResponse) {}
rpc RatePizza(PizzaRatingRequest) returns (PizzaRatingResponse) {}
}

message StatusRequest {
Expand All @@ -14,11 +14,11 @@ message StatusResponse {
bool ready = 1;
}

message PizzaEvaluationRequest {
message PizzaRatingRequest {
repeated string ingredients = 1;
string dough = 2;
}

message PizzaEvaluationResponse {
message PizzaRatingResponse {
int32 stars_rating = 1;
}

0 comments on commit 59d44ef

Please sign in to comment.