You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
4 years ago
|
package gate
|
||
|
|
||
|
import (
|
||
3 years ago
|
"Open_IM/pkg/common/config"
|
||
3 years ago
|
"Open_IM/pkg/common/constant"
|
||
3 years ago
|
|
||
3 years ago
|
"Open_IM/pkg/statistics"
|
||
|
"fmt"
|
||
4 years ago
|
"sync"
|
||
2 years ago
|
|
||
|
promePkg "Open_IM/pkg/common/prometheus"
|
||
|
|
||
|
"github.com/go-playground/validator/v10"
|
||
4 years ago
|
)
|
||
|
|
||
|
var (
|
||
3 years ago
|
rwLock *sync.RWMutex
|
||
|
validate *validator.Validate
|
||
|
ws WServer
|
||
|
rpcSvr RPCServer
|
||
|
sendMsgAllCount uint64
|
||
|
sendMsgFailedCount uint64
|
||
|
sendMsgSuccessCount uint64
|
||
|
userCount uint64
|
||
3 years ago
|
|
||
|
sendMsgAllCountLock sync.RWMutex
|
||
4 years ago
|
)
|
||
|
|
||
|
func Init(rpcPort, wsPort int) {
|
||
|
rwLock = new(sync.RWMutex)
|
||
|
validate = validator.New()
|
||
3 years ago
|
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)
|
||
4 years ago
|
ws.onInit(wsPort)
|
||
|
rpcSvr.onInit(rpcPort)
|
||
2 years ago
|
initPrometheus()
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
func Run(promethuesPort int) {
|
||
4 years ago
|
go ws.run()
|
||
|
go rpcSvr.run()
|
||
2 years ago
|
go func() {
|
||
|
err := promePkg.StartPromeSrv(promethuesPort)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}()
|
||
4 years ago
|
}
|