wire.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //go:build wireinject
  2. // +build wireinject
  3. package wire
  4. import (
  5. "github.com/go-nunu/nunu-layout-advanced/internal/job"
  6. "github.com/go-nunu/nunu-layout-advanced/internal/repository"
  7. "github.com/go-nunu/nunu-layout-advanced/internal/repository/admin"
  8. flexCdn2 "github.com/go-nunu/nunu-layout-advanced/internal/repository/api/flexCdn"
  9. waf2 "github.com/go-nunu/nunu-layout-advanced/internal/repository/api/waf"
  10. "github.com/go-nunu/nunu-layout-advanced/internal/server"
  11. "github.com/go-nunu/nunu-layout-advanced/internal/service"
  12. admin2 "github.com/go-nunu/nunu-layout-advanced/internal/service/admin"
  13. "github.com/go-nunu/nunu-layout-advanced/internal/service/api/flexCdn"
  14. "github.com/go-nunu/nunu-layout-advanced/internal/service/api/gameShield"
  15. "github.com/go-nunu/nunu-layout-advanced/internal/service/api/waf"
  16. "github.com/go-nunu/nunu-layout-advanced/internal/task"
  17. "github.com/go-nunu/nunu-layout-advanced/pkg/app"
  18. "github.com/go-nunu/nunu-layout-advanced/pkg/jwt"
  19. "github.com/go-nunu/nunu-layout-advanced/pkg/log"
  20. "github.com/go-nunu/nunu-layout-advanced/pkg/sid"
  21. "github.com/google/wire"
  22. "github.com/spf13/viper"
  23. )
  24. var repositorySet = wire.NewSet(
  25. repository.NewDB,
  26. repository.NewRedis,
  27. repository.NewMongoClient,
  28. repository.NewCasbinEnforcer,
  29. repository.NewMongoDB,
  30. repository.NewRabbitMQ,
  31. repository.NewRepository,
  32. repository.NewTransaction,
  33. admin.NewUserRepository,
  34. repository.NewGameShieldRepository,
  35. repository.NewGameShieldBackendRepository,
  36. repository.NewGameShieldPublicIpRepository,
  37. repository.NewHostRepository,
  38. repository.NewGameShieldUserIpRepository,
  39. repository.NewGameShieldSdkIpRepository,
  40. waf2.NewWebForwardingRepository,
  41. waf2.NewTcpforwardingRepository,
  42. waf2.NewUdpForWardingRepository,
  43. waf2.NewGlobalLimitRepository,
  44. repository.NewGatewayGroupRepository,
  45. repository.NewGateWayGroupIpRepository,
  46. flexCdn2.NewCdnRepository,
  47. repository.NewExpiredRepository,
  48. flexCdn2.NewProxyRepository,
  49. waf2.NewGatewayipRepository,
  50. repository.NewLogRepository,
  51. flexCdn2.NewCcRepository,
  52. flexCdn2.NewCcIpListRepository,
  53. admin.NewWafLogRepository,
  54. )
  55. var taskSet = wire.NewSet(
  56. task.NewTask,
  57. task.NewUserTask,
  58. task.NewGameShieldTask,
  59. task.NewWafTask,
  60. )
  61. var jobSet = wire.NewSet(
  62. job.NewJob,
  63. job.NewUserJob,
  64. job.NewWhitelistJob,
  65. job.NewWafLogJob,
  66. )
  67. var serverSet = wire.NewSet(
  68. server.NewTaskServer,
  69. server.NewJobServer,
  70. )
  71. var serviceSet = wire.NewSet(
  72. service.NewService,
  73. service.NewAoDunService,
  74. gameShield.NewGameShieldService,
  75. service.NewCrawlerService,
  76. service.NewGameShieldPublicIpService,
  77. service.NewDuedateService,
  78. service.NewFormatterService,
  79. service.NewParserService,
  80. service.NewRequiredService,
  81. service.NewHostService,
  82. gameShield.NewGameShieldBackendService,
  83. service.NewGameShieldSdkIpService,
  84. service.NewGameShieldUserIpService,
  85. waf.NewWafFormatterService,
  86. flexCdn.NewCdnService,
  87. service.NewRequestService,
  88. waf.NewTcpforwardingService,
  89. waf.NewUdpForWardingService,
  90. waf.NewWebForwardingService,
  91. flexCdn.NewProxyService,
  92. flexCdn.NewSslCertService,
  93. flexCdn.NewWebsocketService,
  94. waf.NewCcService,
  95. waf.NewGatewayipService,
  96. service.NewLogService,
  97. waf.NewCcIpListService,
  98. waf.NewBuildAudunService,
  99. waf.NewZzybgpService,
  100. admin2.NewWafLogService,
  101. )
  102. // build App
  103. func newApp(
  104. task *server.TaskServer,
  105. jobServer *server.JobServer,
  106. ) *app.App {
  107. return app.NewApp(
  108. app.WithServer(task, jobServer),
  109. app.WithName("demo-task"),
  110. )
  111. }
  112. func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
  113. panic(wire.Build(
  114. repositorySet,
  115. taskSet,
  116. jobSet,
  117. serverSet,
  118. serviceSet,
  119. newApp,
  120. sid.NewSid,
  121. jwt.NewJwt,
  122. ))
  123. }