mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 21:02:11 +08:00
fix: pkg update.
This commit is contained in:
parent
ceac3a4110
commit
25e71d6b3c
@ -20,6 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||||
"github.com/openimsdk/tools/discovery"
|
"github.com/openimsdk/tools/discovery"
|
||||||
|
"github.com/openimsdk/tools/system/program"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -41,7 +42,6 @@ import (
|
|||||||
ginprom "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus"
|
ginprom "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
||||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/tools/apiresp"
|
"github.com/openimsdk/tools/apiresp"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
@ -122,7 +122,7 @@ func Start(ctx context.Context, config *config.GlobalConfig, port int, proPort i
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
select {
|
select {
|
||||||
case <-sigs:
|
case <-sigs:
|
||||||
util.SIGTERMExit()
|
program.SIGTERMExit()
|
||||||
err := server.Shutdown(ctx)
|
err := server.Shutdown(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.WrapMsg(err, "shutdown err")
|
return errs.WrapMsg(err, "shutdown err")
|
||||||
|
|||||||
@ -62,13 +62,13 @@ func (u *UserMap) Set(key string, v *Client) {
|
|||||||
oldClients := allClients.([]*Client)
|
oldClients := allClients.([]*Client)
|
||||||
oldClients = append(oldClients, v)
|
oldClients = append(oldClients, v)
|
||||||
u.m.Store(key, oldClients)
|
u.m.Store(key, oldClients)
|
||||||
}
|
} else {
|
||||||
|
|
||||||
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client_user_id", v.UserID)
|
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client_user_id", v.UserID)
|
||||||
|
|
||||||
var clients []*Client
|
var clients []*Client
|
||||||
clients = append(clients, v)
|
clients = append(clients, v)
|
||||||
u.m.Store(key, clients)
|
u.m.Store(key, clients)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) {
|
func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) {
|
||||||
@ -114,7 +114,7 @@ func (u *UserMap) deleteClients(key string, clients []*Client) (isDeleteUser boo
|
|||||||
oldClients := allClients.([]*Client)
|
oldClients := allClients.([]*Client)
|
||||||
var remainingClients []*Client
|
var remainingClients []*Client
|
||||||
for _, client := range oldClients {
|
for _, client := range oldClients {
|
||||||
if _, shouldBeDeleted := deleteMap[client.ctx.GetRemoteAddr()]; !shouldBeDeleted {
|
if _, shouldBeDeleted := m[client.ctx.GetRemoteAddr()]; !shouldBeDeleted {
|
||||||
remainingClients = append(remainingClients, client)
|
remainingClients = append(remainingClients, client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/openimsdk/tools/discoveryregistry"
|
"github.com/openimsdk/tools/discovery"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/stathat/consistent"
|
"github.com/stathat/consistent"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -36,7 +36,7 @@ type K8sDR struct {
|
|||||||
gatewayName string
|
gatewayName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewK8sDiscoveryRegister(gatewayName string) (discoveryregistry.SvcDiscoveryRegistry, error) {
|
func NewK8sDiscoveryRegister(gatewayName string) (discovery.SvcDiscoveryRegistry, error) {
|
||||||
gatewayConsistent := consistent.New()
|
gatewayConsistent := consistent.New()
|
||||||
gatewayHosts := getMsgGatewayHost(context.Background(), gatewayName)
|
gatewayHosts := getMsgGatewayHost(context.Background(), gatewayName)
|
||||||
for _, v := range gatewayHosts {
|
for _, v := range gatewayHosts {
|
||||||
|
|||||||
@ -15,30 +15,29 @@
|
|||||||
package zookeeper
|
package zookeeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/openimsdk/tools/discovery"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/tools/discoveryregistry"
|
"github.com/openimsdk/tools/discovery/zookeeper"
|
||||||
openkeeper "github.com/openimsdk/tools/discoveryregistry/zookeeper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewZookeeperDiscoveryRegister creates a new instance of ZookeeperDR for Zookeeper service discovery and registration.
|
// NewZookeeperDiscoveryRegister creates a new instance of ZookeeperDR for Zookeeper service discovery and registration.
|
||||||
func NewZookeeperDiscoveryRegister(zkConf *config.Zookeeper) (discoveryregistry.SvcDiscoveryRegistry, error) {
|
func NewZookeeperDiscoveryRegister(zkConf *config.Zookeeper) (discovery.SvcDiscoveryRegistry, error) {
|
||||||
schema := getEnv("ZOOKEEPER_SCHEMA", zkConf.Schema)
|
schema := getEnv("ZOOKEEPER_SCHEMA", zkConf.Schema)
|
||||||
zkAddr := getZkAddrFromEnv(zkConf.ZkAddr)
|
zkAddr := getZkAddrFromEnv(zkConf.ZkAddr)
|
||||||
username := getEnv("ZOOKEEPER_USERNAME", zkConf.Username)
|
username := getEnv("ZOOKEEPER_USERNAME", zkConf.Username)
|
||||||
password := getEnv("ZOOKEEPER_PASSWORD", zkConf.Password)
|
password := getEnv("ZOOKEEPER_PASSWORD", zkConf.Password)
|
||||||
|
|
||||||
zk, err := openkeeper.NewClient(
|
zk, err := zookeeper.NewZkClient(
|
||||||
zkAddr,
|
zkAddr,
|
||||||
schema,
|
schema,
|
||||||
openkeeper.WithFreq(time.Hour),
|
zookeeper.WithFreq(time.Hour),
|
||||||
openkeeper.WithUserNameAndPassword(username, password),
|
zookeeper.WithUserNameAndPassword(username, password),
|
||||||
openkeeper.WithRoundRobin(),
|
zookeeper.WithRoundRobin(),
|
||||||
openkeeper.WithTimeout(10),
|
zookeeper.WithTimeout(10),
|
||||||
// openkeeper.WithLogger(log.NewZkLogger()),
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -17,11 +17,11 @@ package rpcclient
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/openimsdk/tools/system/program"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
|
||||||
pbconversation "github.com/openimsdk/protocol/conversation"
|
pbconversation "github.com/openimsdk/protocol/conversation"
|
||||||
"github.com/openimsdk/tools/discoveryregistry"
|
"github.com/openimsdk/tools/discovery"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
@ -29,14 +29,14 @@ import (
|
|||||||
type Conversation struct {
|
type Conversation struct {
|
||||||
Client pbconversation.ConversationClient
|
Client pbconversation.ConversationClient
|
||||||
conn grpc.ClientConnInterface
|
conn grpc.ClientConnInterface
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
discov discovery.SvcDiscoveryRegistry
|
||||||
Config *config.GlobalConfig
|
Config *config.GlobalConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry, rpcRegisterName string) *Conversation {
|
func NewConversation(discov discovery.SvcDiscoveryRegistry, rpcRegisterName string) *Conversation {
|
||||||
conn, err := discov.GetConn(context.Background(), rpcRegisterName)
|
conn, err := discov.GetConn(context.Background(), rpcRegisterName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.ExitWithError(err)
|
program.ExitWithError(err)
|
||||||
}
|
}
|
||||||
client := pbconversation.NewConversationClient(conn)
|
client := pbconversation.NewConversationClient(conn)
|
||||||
return &Conversation{discov: discov, conn: conn, Client: client}
|
return &Conversation{discov: discov, conn: conn, Client: client}
|
||||||
@ -44,7 +44,7 @@ func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry, rpcRegisterN
|
|||||||
|
|
||||||
type ConversationRpcClient Conversation
|
type ConversationRpcClient Conversation
|
||||||
|
|
||||||
func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry, rpcRegisterName string) ConversationRpcClient {
|
func NewConversationRpcClient(discov discovery.SvcDiscoveryRegistry, rpcRegisterName string) ConversationRpcClient {
|
||||||
return ConversationRpcClient(*NewConversation(discov, rpcRegisterName))
|
return ConversationRpcClient(*NewConversation(discov, rpcRegisterName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user