2021-05-26 19:22:11 +08:00
/*
** description("").
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@open-im.io").
** time(2021/3/22 15:33).
*/
package logic
import (
2021-10-11 22:12:01 +08:00
"Open_IM/pkg/common/config"
2021-11-25 14:12:52 +08:00
"Open_IM/pkg/common/constant"
2021-10-11 22:12:01 +08:00
"Open_IM/pkg/common/kafka"
2022-02-25 19:49:38 +08:00
"Open_IM/pkg/statistics"
"fmt"
2021-05-26 19:22:11 +08:00
)
var (
rpcServer RPCServer
pushCh PushConsumerHandler
pushTerminal [ ] int32
producer * kafka . Producer
2022-05-09 18:23:06 +08:00
successCount uint64
2021-05-26 19:22:11 +08:00
)
func Init ( rpcPort int ) {
2022-04-05 19:31:35 +08:00
2021-05-26 19:22:11 +08:00
rpcServer . Init ( rpcPort )
pushCh . Init ( )
2021-11-25 14:12:52 +08:00
pushTerminal = [ ] int32 { constant . IOSPlatformID , constant . AndroidPlatformID }
2021-05-26 19:22:11 +08:00
}
func init ( ) {
producer = kafka . NewKafkaProducer ( config . Config . Kafka . Ws2mschat . Addr , config . Config . Kafka . Ws2mschat . Topic )
2022-05-09 18:23:06 +08:00
statistics . NewStatistics ( & successCount , config . Config . ModuleName . PushName , fmt . Sprintf ( "%d second push to msg_gateway count" , constant . StatisticsTimeInterval ) , constant . StatisticsTimeInterval )
2021-05-26 19:22:11 +08:00
}
func Run ( ) {
go rpcServer . run ( )
go pushCh . pushConsumerGroup . RegisterHandleAndConsumer ( & pushCh )
}