wangchuxiao e1a27e6aea Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
 Conflicts:
	cmd/api/main.go
	go.mod
	internal/push/fcm/push.go
	internal/push/getui/push.go
	internal/push/logic/init.go
	internal/push/logic/push_to_client.go
	internal/push/push_rpc_server.go
	internal/rpc/conversation/conversaion.go
	pkg/common/db/controller/group.go
	pkg/proto/push/push.pb.go
2023-02-22 19:52:53 +08:00

49 lines
1.2 KiB
Go

package msggateway
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/statistics"
"fmt"
"sync"
prome "Open_IM/pkg/common/prome"
"github.com/go-playground/validator/v10"
)
var (
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
sendMsgAllCount uint64
sendMsgFailedCount uint64
sendMsgSuccessCount uint64
userCount uint64
sendMsgAllCountLock sync.RWMutex
)
func Init(rpcPort, wsPort int) {
rwLock = new(sync.RWMutex)
validate = validator.New()
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()
}
func Run(prometheusPort int) {
go ws.run()
go rpcSvr.run()
go func() {
err := prome.StartPromeSrv(prometheusPort)
if err != nil {
panic(err)
}
}()
}