mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-19 11:15:35 +08:00
Add etcd as a service discovery mechanism
This commit is contained in:
parent
e94598f5c1
commit
140f734728
@ -34,7 +34,7 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
messageRpc := rpcclient.NewMessage(disCov, config.Share.RpcRegisterName.Msg)
|
messageRpc := rpcclient.NewMessage(disCov, config.Share.RpcRegisterName.Msg)
|
||||||
conversationRpc := rpcclient.NewConversation(disCov, config.Share.RpcRegisterName.Conversation)
|
conversationRpc := rpcclient.NewConversation(disCov, config.Share.RpcRegisterName.Conversation)
|
||||||
authRpc := rpcclient.NewAuth(disCov, config.Share.RpcRegisterName.Auth)
|
authRpc := rpcclient.NewAuth(disCov, config.Share.RpcRegisterName.Auth)
|
||||||
thirdRpc := rpcclient.NewThird(disCov, config.Share.RpcRegisterName.Third, config.RpcConfig.Prometheus.GrafanaURL)
|
thirdRpc := rpcclient.NewThird(disCov, config.Share.RpcRegisterName.Third, config.API.Prometheus.GrafanaURL)
|
||||||
|
|
||||||
u := NewUserApi(*userRpc)
|
u := NewUserApi(*userRpc)
|
||||||
m := NewMessageApi(messageRpc, userRpc, config.Share.IMAdminUserID)
|
m := NewMessageApi(messageRpc, userRpc, config.Share.IMAdminUserID)
|
||||||
|
@ -267,7 +267,7 @@ func (ws *WsServer) registerClient(client *Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
if ws.msgGatewayConfig.Share.Env == "zookeeper" {
|
if ws.msgGatewayConfig.Discovery.Enable != "k8s" {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
@ -12,11 +12,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
KUBERNETES = "k8s"
|
|
||||||
ZOOKEEPER = "zookeeper"
|
|
||||||
)
|
|
||||||
|
|
||||||
type OnlinePusher interface {
|
type OnlinePusher interface {
|
||||||
GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
|
GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
|
||||||
pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error)
|
pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error)
|
||||||
@ -42,10 +37,12 @@ func (u emptyOnlinePUsher) GetOnlinePushFailedUserIDs(ctx context.Context, msg *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewOnlinePusher(disCov discovery.SvcDiscoveryRegistry, config *Config) OnlinePusher {
|
func NewOnlinePusher(disCov discovery.SvcDiscoveryRegistry, config *Config) OnlinePusher {
|
||||||
switch config.Share.Env {
|
switch config.Discovery.Enable {
|
||||||
case KUBERNETES:
|
case "k8s":
|
||||||
return NewK8sStaticConsistentHash(disCov, config)
|
return NewK8sStaticConsistentHash(disCov, config)
|
||||||
case ZOOKEEPER:
|
case "zookeeper":
|
||||||
|
return NewDefaultAllNode(disCov, config)
|
||||||
|
case "etcd":
|
||||||
return NewDefaultAllNode(disCov, config)
|
return NewDefaultAllNode(disCov, config)
|
||||||
default:
|
default:
|
||||||
return newEmptyOnlinePUsher()
|
return newEmptyOnlinePUsher()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user