Files
open-im-server/internal/msg_gateway/gate/init.go
T

41 lines
1.0 KiB
Go
Raw Normal View History

2021-05-26 19:24:25 +08:00
package gate
import (
"Open_IM/pkg/common/config"
2022-05-09 18:23:06 +08:00
"Open_IM/pkg/common/constant"
2022-04-05 19:31:35 +08:00
2022-02-25 19:49:38 +08:00
"Open_IM/pkg/statistics"
"fmt"
2021-05-26 19:24:25 +08:00
"github.com/go-playground/validator/v10"
"sync"
)
var (
2022-05-09 18:23:06 +08:00
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
sendMsgAllCount uint64
sendMsgFailedCount uint64
sendMsgSuccessCount uint64
userCount uint64
2022-05-18 11:52:15 +08:00
sendMsgAllCountLock sync.RWMutex
2021-05-26 19:24:25 +08:00
)
func Init(rpcPort, wsPort int) {
//log initialization
2022-04-05 19:31:35 +08:00
2021-05-26 19:24:25 +08:00
rwLock = new(sync.RWMutex)
validate = validator.New()
2022-05-09 18:23:06 +08:00
statistics.NewStatistics(&sendMsgAllCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
2021-05-26 19:24:25 +08:00
ws.onInit(wsPort)
rpcSvr.onInit(rpcPort)
}
func Run() {
go ws.run()
go rpcSvr.run()
}