backend/app/zeus/service/lark/internal/server/rpc.go

33 lines
641 B
Go
Raw Normal View History

2022-01-12 00:40:37 +08:00
package server
2022-01-11 04:00:39 +08:00
import (
"fmt"
"google.golang.org/grpc/keepalive"
"log"
"net"
"time"
"git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
func RpcServer() {
lis, err := net.Listen("tcp", ":3000")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer(grpc.KeepaliveParams(keepalive.ServerParameters{
MaxConnectionIdle: 5 * time.Minute,
}))
2022-01-12 00:40:37 +08:00
lark.RegisterUserServer(s, &UserServer{})
2022-01-11 04:00:39 +08:00
reflection.Register(s)
fmt.Println("lark server run in :3000")
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}