rcvr.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. // package impl implement all interfaces of micro service in gd_access_log
  4. package impl
  5. import (
  6. "context"
  7. "gd_access_log/apis"
  8. "gd_access_log/impl/access_log"
  9. "gd_access_log/impl/h5_access_log"
  10. "gd_access_log/rpc_apis/gd_management"
  11. "time"
  12. "gd_access_log/common.in/task"
  13. "github.com/astaxie/beego/orm"
  14. )
  15. // 具体实现
  16. type Rcvr struct {
  17. }
  18. func (c *Rcvr) LogAddAccessLog(ctx context.Context, req *apis.LogAddAccessLogReq, reply *apis.LogAddAccessLogReply) error {
  19. t1 := func() error {
  20. return access_log.LogAddAccessLog(ctx, req, reply)
  21. }
  22. return task.Do(ctx, t1)
  23. }
  24. // 添加无效日志
  25. func (c *Rcvr) LogAddInvalidAccessLog(ctx context.Context, req *apis.LogAddInvalidAccessLogReq, reply *apis.LogAddInvalidAccessLogReply) error {
  26. t1 := func() error {
  27. return access_log.LogAddInvalidAccessLog(ctx, req, reply)
  28. }
  29. return task.Do(ctx, t1)
  30. }
  31. func (c *Rcvr) H5LogAddAccessLog(ctx context.Context, req *apis.H5LogAddAccessLogReq, reply *apis.H5LogAddAccessLogReply) error {
  32. t1 := func() error {
  33. return h5_access_log.H5LogAddAccessLog(ctx, req, reply)
  34. }
  35. return task.Do(ctx, t1)
  36. }
  37. func (c *Rcvr) TryApiAccessLogAdd(ctx context.Context, req *apis.TryApiAccessLogReq, reply *apis.TryApiAccessLogReply) error {
  38. t1 := func() error {
  39. return access_log.TryApiAccessLogAdd(ctx, req, reply)
  40. }
  41. return task.Do(ctx, t1)
  42. }
  43. func (c *Rcvr) LogUpdateApiName(ctx context.Context, req *apis.LogUpdateApiNameReq, reply *apis.LogUpdateApiNameReply) error {
  44. t1 := func() error {
  45. return access_log.LogUpdateApiName(ctx, req, reply)
  46. }
  47. return task.Do(ctx, t1)
  48. }
  49. func (c *Rcvr) LogCallbackIn(ctx context.Context, req *apis.LogCallbackInReq, reply *apis.LogCallbackInReply) error {
  50. task1 := func() error {
  51. return access_log.LogCallbackIn(ctx, req, reply)
  52. }
  53. return task.Do(ctx, task1)
  54. }
  55. func (c *Rcvr) LogCallbackOut(ctx context.Context, req *apis.LogCallbackOutReq, reply *apis.LogCallbackOutReply) error {
  56. task1 := func() error {
  57. return access_log.LogCallbackOut(ctx, req, reply)
  58. }
  59. return task.Do(ctx, task1)
  60. }
  61. func RegisterOrmModel() {
  62. //orm.RegisterModel(new(apis.AccessLog))
  63. //orm.RegisterModel(new(apis.TGdAccessLogHistory))
  64. //orm.RegisterModel(new(apis.ThirdpartLog))
  65. //orm.RegisterModel(new(apis.TGdThirdpartAccessLogHistory))
  66. orm.RegisterModel(new(apis.TGdAccessLogCountExport))
  67. orm.RegisterModel(new(apis.InvalidAccessLog))
  68. orm.RegisterModel(new(apis.H5AccessLog))
  69. orm.RegisterModel(new(apis.H5ThirdpartLog))
  70. orm.RegisterModel(new(apis.TryApiAccessLog))
  71. orm.RegisterModel(new(apis.AccessLogDay))
  72. orm.RegisterModel(new(apis.ThirdpartLogDay))
  73. orm.RegisterModel(new(apis.TGdAccessLogMonth1))
  74. orm.RegisterModel(new(apis.TGdAccessLogMonth2))
  75. orm.RegisterModel(new(apis.TGdAccessLogMonth3))
  76. orm.RegisterModel(new(apis.TGdAccessLogMonth4))
  77. orm.RegisterModel(new(apis.TGdAccessLogMonth5))
  78. orm.RegisterModel(new(apis.TGdAccessLogMonth6))
  79. orm.RegisterModel(new(apis.TGdAccessLogMonth7))
  80. orm.RegisterModel(new(apis.TGdAccessLogMonth8))
  81. orm.RegisterModel(new(apis.TGdAccessLogMonth9))
  82. orm.RegisterModel(new(apis.TGdAccessLogMonth10))
  83. orm.RegisterModel(new(apis.TGdAccessLogMonth11))
  84. orm.RegisterModel(new(apis.TGdAccessLogMonth12))
  85. orm.RegisterModel(new(apis.TGdThirdpartLogMonth1))
  86. orm.RegisterModel(new(apis.TGdThirdpartLogMonth2))
  87. orm.RegisterModel(new(apis.TGdThirdpartLogMonth3))
  88. orm.RegisterModel(new(apis.TGdThirdpartLogMonth4))
  89. orm.RegisterModel(new(apis.TGdThirdpartLogMonth5))
  90. orm.RegisterModel(new(apis.TGdThirdpartLogMonth6))
  91. orm.RegisterModel(new(apis.TGdThirdpartLogMonth7))
  92. orm.RegisterModel(new(apis.TGdThirdpartLogMonth8))
  93. orm.RegisterModel(new(apis.TGdThirdpartLogMonth9))
  94. orm.RegisterModel(new(apis.TGdThirdpartLogMonth10))
  95. orm.RegisterModel(new(apis.TGdThirdpartLogMonth11))
  96. orm.RegisterModel(new(apis.TGdThirdpartLogMonth12))
  97. }
  98. func CleanLocalCache() {
  99. t := time.NewTicker(5 * time.Minute)
  100. for {
  101. select {
  102. case <-t.C:
  103. gd_management.CleanNameMap()
  104. }
  105. }
  106. }