⬆️ Upgrade to support the latest version Hydrogen Project standard

This commit is contained in:
2024-06-22 17:29:53 +08:00
parent 52c864b11f
commit c79c8d3618
45 changed files with 538 additions and 279 deletions

View File

@@ -0,0 +1,31 @@
package grpc
import (
"github.com/spf13/viper"
"google.golang.org/grpc"
health "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/reflection"
"net"
)
type Server struct {
}
var S *grpc.Server
func NewGRPC() {
S = grpc.NewServer()
health.RegisterHealthServer(S, &Server{})
reflection.Register(S)
}
func ListenGRPC() error {
listener, err := net.Listen("tcp", viper.GetString("grpc_bind"))
if err != nil {
return err
}
return S.Serve(listener)
}