mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
rpc restore
This commit is contained in:
parent
42726cf2b6
commit
d6614decd1
@ -12,12 +12,10 @@ import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@ -36,7 +34,8 @@ func (r *RPCServer) onInit(rpcPort int) {
|
||||
r.etcdAddr = config.Config.Etcd.EtcdAddr
|
||||
}
|
||||
func (r *RPCServer) run() {
|
||||
registerAddress := ":" + utils.IntToString(r.rpcPort)
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + utils.IntToString(r.rpcPort)
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.ErrorByArgs(fmt.Sprintf("fail to listening consumer, err:%v\n", err))
|
||||
@ -46,8 +45,7 @@ func (r *RPCServer) run() {
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
pbRelay.RegisterOnlineMessageRelayServiceServer(srv, r)
|
||||
host := viper.GetString("endpoints.msg_gateway")
|
||||
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), host, r.rpcPort, r.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.ErrorByKv("register push message rpc to etcd err", "", "err", err.Error())
|
||||
}
|
||||
|
@ -4,15 +4,13 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type RPCServer struct {
|
||||
@ -29,7 +27,8 @@ func (r *RPCServer) Init(rpcPort int) {
|
||||
r.etcdAddr = config.Config.Etcd.EtcdAddr
|
||||
}
|
||||
func (r *RPCServer) run() {
|
||||
registerAddress := ":" + utils.IntToString(r.rpcPort)
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + utils.IntToString(r.rpcPort)
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.ErrorByKv("push module rpc listening port err", "", "err", err.Error())
|
||||
@ -39,8 +38,7 @@ func (r *RPCServer) run() {
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
pbPush.RegisterPushMsgServiceServer(srv, r)
|
||||
host := viper.GetString("endpoints.push")
|
||||
err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), host, r.rpcPort, r.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.ErrorByKv("register push module rpc to etcd err", "", "err", err.Error())
|
||||
}
|
||||
|
@ -5,12 +5,11 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"Open_IM/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type rpcAuth struct {
|
||||
@ -33,7 +32,7 @@ func NewRpcAuthServer(port int) *rpcAuth {
|
||||
func (rpc *rpcAuth) Run() {
|
||||
log.Info("", "", "rpc get_token init...")
|
||||
|
||||
address := ":" + strconv.Itoa(rpc.rpcPort)
|
||||
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
||||
@ -48,8 +47,7 @@ func (rpc *rpcAuth) Run() {
|
||||
//service registers with etcd
|
||||
|
||||
pbAuth.RegisterAuthServer(srv, rpc)
|
||||
host := viper.GetString("endpoints.rpc_auth")
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), host, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
||||
return
|
||||
|
@ -6,12 +6,11 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type rpcChat struct {
|
||||
@ -37,7 +36,7 @@ func NewRpcChatServer(port int) *rpcChat {
|
||||
func (rpc *rpcChat) Run() {
|
||||
log.Info("", "", "rpc get_token init...")
|
||||
|
||||
address := ":" + strconv.Itoa(rpc.rpcPort)
|
||||
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
||||
@ -52,8 +51,7 @@ func (rpc *rpcChat) Run() {
|
||||
//service registers with etcd
|
||||
|
||||
pbChat.RegisterChatServer(srv, rpc)
|
||||
host := viper.GetString("endpoints.rpc_msg")
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), host, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
||||
return
|
||||
|
@ -8,14 +8,13 @@ import (
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type friendServer struct {
|
||||
@ -38,7 +37,8 @@ func NewFriendServer(port int) *friendServer {
|
||||
func (s *friendServer) Run() {
|
||||
log.Info("", "", fmt.Sprintf("rpc friend init...."))
|
||||
|
||||
registerAddress := ":" + strconv.Itoa(s.rpcPort)
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
@ -52,8 +52,7 @@ func (s *friendServer) Run() {
|
||||
defer srv.GracefulStop()
|
||||
//User friend related services register to etcd
|
||||
pbFriend.RegisterFriendServer(srv, s)
|
||||
host := viper.GetString("endpoints.rpc_friend")
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), host, s.rpcPort, s.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.ErrorByArgs("register rpc fiend service to etcd failed,err=%s", err.Error())
|
||||
return
|
||||
|
@ -14,13 +14,11 @@ import (
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type groupServer struct {
|
||||
@ -42,7 +40,8 @@ func NewGroupServer(port int) *groupServer {
|
||||
func (s *groupServer) Run() {
|
||||
log.Info("", "", "rpc group init....")
|
||||
|
||||
registerAddress := ":" + strconv.Itoa(s.rpcPort)
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
@ -56,8 +55,7 @@ func (s *groupServer) Run() {
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
pbGroup.RegisterGroupServer(srv, s)
|
||||
host := viper.GetString("endpoints.rpc_group")
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), host, s.rpcPort, s.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.ErrorByArgs("get etcd failed,err=%s", err.Error())
|
||||
return
|
||||
|
@ -6,13 +6,12 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type userServer struct {
|
||||
@ -35,7 +34,8 @@ func NewUserServer(port int) *userServer {
|
||||
func (s *userServer) Run() {
|
||||
log.Info("", "", "rpc user init....")
|
||||
|
||||
registerAddress := ":" + strconv.Itoa(s.rpcPort)
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
@ -49,8 +49,7 @@ func (s *userServer) Run() {
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
pbUser.RegisterUserServer(srv, s)
|
||||
host := viper.GetString("endpoints.rpc_user")
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), host, s.rpcPort, s.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.ErrorByArgs("register rpc token to etcd failed,err=%s", err.Error())
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user