save
This commit is contained in:
parent
b9e8e7c621
commit
9e3850805f
22
collect.go
22
collect.go
|
@ -2,12 +2,13 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
mongodb "git.nonolive.co/eson.hsm/databoard-collect/database"
|
||||
database "git.nonolive.co/eson.hsm/databoard-database-myrocks"
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
@ -20,17 +21,18 @@ func collectCopyCountLiveAnchors(cxt *WorkerContext) {
|
|||
|
||||
for !ps.IsClose() {
|
||||
|
||||
db.Do(func(T *database.TableManager) {
|
||||
db.Do(func(db *sql.DB) {
|
||||
liveanchor := &CountLiveAnchors{}
|
||||
T.CountLiveAnchors.Order("create_at desc").Limit(1).Find(liveanchor)
|
||||
if err = T.CountLiveAnchors.Error; err == nil {
|
||||
// T.CountLiveAnchors.Order("create_at desc").Limit(1).Find(liveanchor)
|
||||
selectsql := fmt.Sprintf("select uid, create_at from %s order by create_at desc limit 1", Tables.CountLiveAnchors)
|
||||
row := db.QueryRow(selectsql)
|
||||
if row.Err() == nil {
|
||||
|
||||
row.Scan(&liveanchor.UID, &liveanchor.CreateAt)
|
||||
log.Println("last: ", liveanchor.CreateAt, liveanchor.UID)
|
||||
|
||||
var cur *mongo.Cursor
|
||||
var last time.Time
|
||||
last = liveanchor.CreateAt
|
||||
|
||||
log.Println("last: ", last, liveanchor.UID)
|
||||
|
||||
cur, err = mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gt": last}})
|
||||
cur, err = mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gt": liveanchor.CreateAt}})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
ps.Wait(time.Second * 5)
|
||||
|
|
|
@ -13,3 +13,5 @@ var mdb = mongodb.NewStatisticsDB("mongodb://sg-board1.livenono.com:27018")
|
|||
|
||||
// 默认全局的数据库对象
|
||||
var db = myrocks.DB
|
||||
|
||||
var Tables = myrocks.Tables
|
||||
|
|
3
go.mod
3
go.mod
|
@ -4,9 +4,8 @@ go 1.15
|
|||
|
||||
require (
|
||||
git.nonolive.co/eson.hsm/databoard-collect v0.3.0
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.1.0
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.2
|
||||
github.com/474420502/perfectshutdown v0.1.0
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/go-xorm/xorm v0.7.9
|
||||
go.mongodb.org/mongo-driver v1.4.3
|
||||
)
|
||||
|
|
6
go.sum
6
go.sum
|
@ -6,10 +6,8 @@ git.nonolive.co/eson.hsm/databoard-collect v0.3.0 h1:fy3SJFR2QOoLRjfKSqHeQMjp90q
|
|||
git.nonolive.co/eson.hsm/databoard-collect v0.3.0/go.mod h1:KX2Se020AIewrmc9k3SotNHT3S+yGFQnPmcEvRa3Za0=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.1.0 h1:/N2ThrAvlbdGzjaogP4n9ShnnWuyxZb2yVwC7Vrg/eg=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.1.0/go.mod h1:SNP2vUXs6aCLLwSkTzfNp/6QnAfPNKSaQ+Di3ZnmaWw=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.0 h1:65TeCdNIZ/TqV9BYQSrq41qcut7KOu1s0Beww3txSh4=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.0/go.mod h1:SNP2vUXs6aCLLwSkTzfNp/6QnAfPNKSaQ+Di3ZnmaWw=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.1 h1:0zAwFTt0gb46jAHppitm2QB6jag+2qZ7U1xhKpu0Pn0=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.1/go.mod h1:SNP2vUXs6aCLLwSkTzfNp/6QnAfPNKSaQ+Di3ZnmaWw=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.2 h1:vsEZVsobeDKoMvGJxzei83gLQoRIn2KA0c63TgqoAuo=
|
||||
git.nonolive.co/eson.hsm/databoard-database-myrocks v0.2.2/go.mod h1:SNP2vUXs6aCLLwSkTzfNp/6QnAfPNKSaQ+Di3ZnmaWw=
|
||||
github.com/474420502/perfectshutdown v0.1.0 h1:xffrGHi0ZgAwy6N0y6DJ6xoo2kpTt4Hktg9rTgSN8ys=
|
||||
github.com/474420502/perfectshutdown v0.1.0/go.mod h1:qonD0eLCz1ncQq8heGQHbPdLlh30lofF2ISzV5ASW8A=
|
||||
github.com/474420502/requests v1.9.1/go.mod h1:x2T9l+e40R6kxxMvNm+YSZ9D6BHAXUDak4kQElIPJ9A=
|
||||
|
|
Loading…
Reference in New Issue
Block a user