generated from pkg/go-template
32 lines
696 B
Go
32 lines
696 B
Go
|
package servesr
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murder"
|
||
|
"google.golang.org/grpc"
|
||
|
"log"
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
type helloRequet struct {
|
||
|
murder.UnimplementedHelloWorldServer
|
||
|
}
|
||
|
|
||
|
func (helloRequet) Login(ctx context.Context, name *murder.HelloRequest) (*murder.HelloResponse, error) {
|
||
|
return &murder.HelloResponse{Token: name.Code}, nil
|
||
|
}
|
||
|
|
||
|
func RpcServer() {
|
||
|
lis, err := net.Listen("tcp", ":3000")
|
||
|
if err != nil {
|
||
|
log.Fatalf("failed to listen: %v", err)
|
||
|
}
|
||
|
s := grpc.NewServer()
|
||
|
murder.RegisterHelloWorldServer(s, &helloRequet{})
|
||
|
fmt.Println("lark server run in :3000")
|
||
|
if err := s.Serve(lis); err != nil {
|
||
|
log.Fatalf("failed to serve: %v", err)
|
||
|
}
|
||
|
}
|