Passport/pkg/internal/grpc/server.go

36 lines
740 B
Go
Raw Normal View History

2024-02-20 13:46:15 +00:00
package grpc
import (
2024-03-20 12:56:07 +00:00
"net"
2024-04-13 05:48:19 +00:00
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
2024-02-20 13:46:15 +00:00
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
type Server struct {
proto.UnimplementedAuthServer
proto.UnimplementedNotifyServer
2024-04-05 17:07:36 +00:00
proto.UnimplementedFriendshipsServer
2024-05-03 17:47:44 +00:00
proto.UnimplementedRealmsServer
2024-02-20 13:46:15 +00:00
}
func StartGrpc() error {
listen, err := net.Listen("tcp", viper.GetString("grpc_bind"))
if err != nil {
return err
}
server := grpc.NewServer()
proto.RegisterAuthServer(server, &Server{})
proto.RegisterNotifyServer(server, &Server{})
2024-04-05 17:07:36 +00:00
proto.RegisterFriendshipsServer(server, &Server{})
2024-05-03 17:47:44 +00:00
proto.RegisterRealmsServer(server, &Server{})
2024-02-20 13:46:15 +00:00
reflection.Register(server)
return server.Serve(listen)
}