rpc_recv.go 582 B

123456789101112131415161718192021222324252627
  1. package receiver
  2. import (
  3. "time"
  4. "github.com/710leo/urlooker/dataobj"
  5. "github.com/710leo/urlooker/modules/alarm/judge"
  6. )
  7. type Alarm int
  8. func (this *Alarm) Ping(req interface{}, reply *string) error {
  9. *reply = "ok"
  10. return nil
  11. }
  12. func (this *Alarm) Send(args []*dataobj.ItemStatus, reply *string) error {
  13. // 把当前时间的计算放在最外层,是为了减少获取时间时的系统调用开销
  14. now := time.Now().Unix()
  15. for _, arg := range args {
  16. pk := arg.PK()
  17. judge.HistoryBigMap[pk[0:2]].PushFrontAndMaintain(pk, arg, 10, now)
  18. }
  19. *reply = ""
  20. return nil
  21. }