infoc.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package unicom
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/app/interface/main/app-wall/conf"
  6. log "go-common/library/log"
  7. binfoc "go-common/library/log/infoc"
  8. )
  9. type orderInfoc struct {
  10. usermob string
  11. orderType string
  12. ip string
  13. mobiApp string
  14. build string
  15. now string
  16. }
  17. type ipInfoc struct {
  18. usermob string
  19. isValide string
  20. ip string
  21. mobiApp string
  22. build string
  23. now string
  24. }
  25. type packInfoc struct {
  26. usermob string
  27. phone string
  28. mid string
  29. requestNo string
  30. packName string
  31. packIntegral string
  32. packType string
  33. now string
  34. }
  35. // Infoc write data for Hadoop do analytics
  36. func (s *Service) unicomInfoc(mobiApp, usermob, ip string, build, orderType int, now time.Time) {
  37. select {
  38. case s.logCh <- orderInfoc{usermob, strconv.Itoa(orderType), ip, mobiApp, strconv.Itoa(build), strconv.FormatInt(now.Unix(), 10)}:
  39. default:
  40. log.Warn("unicomInfoc log buffer is full")
  41. }
  42. }
  43. // Infoc write data for Hadoop do analytics
  44. func (s *Service) ipInfoc(mobiApp, usermob, ip string, build int, isValide bool, now time.Time) {
  45. select {
  46. case s.logCh <- ipInfoc{usermob, strconv.FormatBool(isValide), ip, mobiApp, strconv.Itoa(build), strconv.FormatInt(now.Unix(), 10)}:
  47. default:
  48. log.Warn("ipInfoc log buffer is full")
  49. }
  50. }
  51. func (s *Service) unicomInfocproc() {
  52. var (
  53. unicominf2 = binfoc.New(conf.Conf.UnicomUserInfoc2)
  54. ipinf2 = binfoc.New(conf.Conf.UnicomIpInfoc2)
  55. )
  56. for {
  57. i, ok := <-s.logCh
  58. if !ok {
  59. log.Warn("infoc proc exit")
  60. return
  61. }
  62. switch v := i.(type) {
  63. case orderInfoc:
  64. unicominf2.Info(v.now, "0", v.usermob, v.orderType, v.ip, v.mobiApp, v.build)
  65. case ipInfoc:
  66. ipinf2.Info(v.now, "0", v.isValide, v.ip, v.usermob, v.mobiApp, v.build)
  67. }
  68. }
  69. }
  70. // unicomPackInfoc unicom pack infoc
  71. func (s *Service) unicomPackInfoc(usermob, packName, orderNumber string, phone, packIntegral, packType int, mid int64, now time.Time) {
  72. select {
  73. case s.packCh <- packInfoc{usermob, strconv.Itoa(phone), strconv.FormatInt(mid, 10),
  74. orderNumber, packName, strconv.Itoa(packIntegral), strconv.Itoa(packType), strconv.FormatInt(now.Unix(), 10)}:
  75. default:
  76. log.Warn("unicomPackInfoc log buffer is full")
  77. }
  78. }
  79. func (s *Service) unicomPackInfocproc() {
  80. var (
  81. packinf = binfoc.New(conf.Conf.UnicomPackInfoc)
  82. )
  83. for {
  84. i, ok := <-s.packCh
  85. if !ok {
  86. log.Warn("infoc proc exit")
  87. return
  88. }
  89. switch v := i.(type) {
  90. case packInfoc:
  91. packinf.Info(v.now, "0", v.usermob, v.phone, v.mid, v.requestNo, v.packName, v.packIntegral, v.packType)
  92. }
  93. }
  94. }