Skip to content
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

GRPC Apis for Corresponding HTTP APIs #369

Merged
merged 7 commits into from
Jun 23, 2024
21 changes: 21 additions & 0 deletions pkg/api/grpc/delay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package grpc

import (
"context"
"time"

pb "github.com/stefanprodan/podinfo/pkg/api/grpc/delay"
"go.uber.org/zap"
)

type DelayServer struct {
pb.UnimplementedDelayServiceServer
config *Config
logger *zap.Logger
}

func (s *DelayServer) Delay(ctx context.Context, delayInput *pb.DelayRequest) (*pb.DelayResponse, error) {

time.Sleep(time.Duration(delayInput.Seconds) * time.Second)
return &pb.DelayResponse{Message: delayInput.Seconds}, nil
}
211 changes: 211 additions & 0 deletions pkg/api/grpc/delay/delay.pb.go

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

17 changes: 17 additions & 0 deletions pkg/api/grpc/delay/delay.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";

option go_package = "./delay";

package delay;

message DelayRequest {
int64 seconds = 1;
}

message DelayResponse {
int64 message = 1;
}

service DelayService {
rpc Delay (DelayRequest) returns (DelayResponse) {}
}
105 changes: 105 additions & 0 deletions pkg/api/grpc/delay/delay_grpc.pb.go

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

Loading
Loading