databus.go 693 B

123456789101112131415161718192021222324252627
  1. package bplus
  2. import (
  3. "context"
  4. "strconv"
  5. "go-common/app/interface/main/app-interface/model/space"
  6. "go-common/library/net/metadata"
  7. xtime "go-common/library/time"
  8. "github.com/pkg/errors"
  9. )
  10. // NotifyContribute .
  11. func (d *Dao) NotifyContribute(c context.Context, vmid int64, attrs *space.Attrs, ctime xtime.Time) (err error) {
  12. ip := metadata.String(c, metadata.RemoteIP)
  13. value := struct {
  14. Vmid int64 `json:"vmid"`
  15. Attrs *space.Attrs `json:"attrs"`
  16. CTime xtime.Time `json:"ctime"`
  17. IP string `json:"ip"`
  18. }{vmid, attrs, ctime, ip}
  19. if err = d.pub.Send(c, strconv.FormatInt(vmid, 10), value); err != nil {
  20. err = errors.Wrapf(err, "%v", value)
  21. }
  22. return
  23. }