28 lines
630 B
Go
28 lines
630 B
Go
|
package echo
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"google.golang.org/grpc/codes"
|
||
|
"google.golang.org/grpc/status"
|
||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||
|
|
||
|
pb "github.com/esinio/geco/gen/proto/echo/v1"
|
||
|
)
|
||
|
|
||
|
type Service struct {
|
||
|
*pb.UnimplementedEchoServiceServer
|
||
|
}
|
||
|
|
||
|
func (s *Service) Echo(ctx context.Context, req *pb.StringMessage) (*pb.StringMessage, error) {
|
||
|
if req.Value == "" {
|
||
|
return nil, status.Errorf(codes.Unimplemented, "value is empty")
|
||
|
}
|
||
|
return &pb.StringMessage{
|
||
|
Value: req.Value,
|
||
|
Timestamp: timestamppb.Now(),
|
||
|
}, nil
|
||
|
|
||
|
// return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented")
|
||
|
}
|