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.
33 lines
691 B
33 lines
691 B
package dao |
|
|
|
import ( |
|
"context" |
|
"strconv" |
|
"time" |
|
|
|
"go-common/library/log" |
|
) |
|
|
|
type statMsg struct { |
|
ID int64 `json:"id"` |
|
Timestamp int64 `json:"timestamp"` |
|
Count int32 `json:"count"` |
|
Type string `json:"type"` |
|
} |
|
|
|
// SendStats update stat. |
|
func (d *Dao) SendStats(c context.Context, typ int32, oid int64, cnt int32) (err error) { |
|
// new databus stats |
|
if name, ok := d.statsTypes[typ]; ok { |
|
m := &statMsg{ |
|
ID: oid, |
|
Type: name, |
|
Count: cnt, |
|
Timestamp: time.Now().Unix(), |
|
} |
|
if err = d.statsBus.Send(c, strconv.FormatInt(oid, 10), m); err != nil { |
|
log.Error("d.databus.Send(%d,%d,%d) error(%v)", typ, oid, cnt, err) |
|
} |
|
} |
|
return |
|
}
|
|
|