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.
Open-IM-Server/internal/msggateway/init.go

49 lines
1.2 KiB

2 years ago
package msggateway
import (
2 years ago
"OpenIM/pkg/common/config"
"OpenIM/pkg/common/constant"
3 years ago
2 years ago
"OpenIM/pkg/statistics"
3 years ago
"fmt"
"sync"
2 years ago
2 years ago
prome "OpenIM/pkg/common/prome"
2 years ago
"github.com/go-playground/validator/v10"
)
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
)
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)
ws.onInit(wsPort)
rpcSvr.onInit(rpcPort)
initPrometheus()
}
2 years ago
func Run(prometheusPort int) {
go ws.run()
go rpcSvr.run()
2 years ago
go func() {
2 years ago
err := prome.StartPrometheusSrv(prometheusPort)
2 years ago
if err != nil {
panic(err)
}
}()
}