27 lines
418 B
Go
27 lines
418 B
Go
package sample
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
"time"
|
|
|
|
pb "myschools.me/suguo/consul-demo/proto"
|
|
)
|
|
|
|
//Server 微服务
|
|
type Server struct {
|
|
}
|
|
|
|
var r int
|
|
|
|
//Say 实现微服务接口
|
|
func (s *Server) Say(c context.Context, req *pb.SayRequest) (*pb.SayResponse, error) {
|
|
if r == 0 {
|
|
r = int(time.Now().Unix())
|
|
}
|
|
resp := &pb.SayResponse{
|
|
Reply: req.Name + req.Day + " " + strconv.Itoa(r),
|
|
}
|
|
return resp, nil
|
|
}
|