删除:topic 消息写数据库
git-svn-id: svn://47.119.165.148/zhub@163 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
@@ -80,9 +80,9 @@ func msgAccept(v Message) {
|
||||
if len(rcmd) != 3 {
|
||||
c.send("-Error: publish para number![" + strings.Join(rcmd, " ") + "]")
|
||||
} else {
|
||||
if len(topicChan) < cap(topicChan) {
|
||||
/*if len(topicChan) < cap(topicChan) {
|
||||
topicChan <- rcmd
|
||||
}
|
||||
}*/
|
||||
zsub.Publish(rcmd[1], rcmd[2])
|
||||
}
|
||||
return
|
||||
@@ -90,9 +90,9 @@ func msgAccept(v Message) {
|
||||
if len(rcmd) != 3 {
|
||||
c.send("-Error: publish para number![" + strings.Join(rcmd, " ") + "]")
|
||||
} else {
|
||||
if len(topicChan) < cap(topicChan) {
|
||||
/*if len(topicChan) < cap(topicChan) {
|
||||
topicChan <- rcmd
|
||||
}
|
||||
}*/
|
||||
zsub.Publish(rcmd[1], rcmd[2])
|
||||
}
|
||||
return
|
||||
|
||||
@@ -8,13 +8,13 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
var (
|
||||
topicChan = make(chan []string, 1000) //接收到的 所有消息数据
|
||||
)
|
||||
topicChan = make(chan []string, 1000) //接收到的 所有消息数据, 用于写入数据库持久化
|
||||
)*/
|
||||
|
||||
// Message 数据封装
|
||||
type Message struct {
|
||||
@@ -172,6 +172,7 @@ var (
|
||||
|
||||
func init() {
|
||||
LoadConf("app.conf")
|
||||
/*
|
||||
_db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
|
||||
GetStr("ztimer.db.user", "root"),
|
||||
GetStr("ztimer.db.pwd", "123456"),
|
||||
@@ -186,6 +187,7 @@ func init() {
|
||||
db = _db
|
||||
|
||||
// 批量写入数据库,等待超时5秒,如有数据写入数据
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -225,4 +227,5 @@ func init() {
|
||||
flagcount = 0
|
||||
}
|
||||
}()
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user