wire.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. "github.com/go-nunu/nunu-layout-advanced/internal/service/api/flexCdn"
  13. "github.com/go-nunu/nunu-layout-advanced/internal/service/api/gameShield"
  14. "github.com/go-nunu/nunu-layout-advanced/internal/service/api/waf"
  15. admin2 "github.com/go-nunu/nunu-layout-advanced/internal/service/admin"
  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. )
  66. var serverSet = wire.NewSet(
  67. server.NewTaskServer,
  68. server.NewJobServer,
  69. )
  70. var serviceSet = wire.NewSet(
  71. service.NewService,
  72. service.NewAoDunService,
  73. gameShield.NewGameShieldService,
  74. service.NewCrawlerService,
  75. service.NewGameShieldPublicIpService,
  76. service.NewDuedateService,
  77. service.NewFormatterService,
  78. service.NewParserService,
  79. service.NewRequiredService,
  80. service.NewHostService,
  81. gameShield.NewGameShieldBackendService,
  82. service.NewGameShieldSdkIpService,
  83. service.NewGameShieldUserIpService,
  84. waf.NewWafFormatterService,
  85. flexCdn.NewCdnService,
  86. service.NewRequestService,
  87. waf.NewTcpforwardingService,
  88. waf.NewUdpForWardingService,
  89. waf.NewWebForwardingService,
  90. flexCdn.NewProxyService,
  91. flexCdn.NewSslCertService,
  92. flexCdn.NewWebsocketService,
  93. waf.NewCcService,
  94. waf.NewGatewayipService,
  95. service.NewLogService,
  96. waf.NewCcIpListService,
  97. waf.NewBuildAudunService,
  98. waf.NewZzybgpService,
  99. admin2.NewWafLogService,
  100. )
  101. // build App
  102. func newApp(
  103. task *server.TaskServer,
  104. jobServer *server.JobServer,
  105. ) *app.App {
  106. return app.NewApp(
  107. app.WithServer(task, jobServer),
  108. app.WithName("demo-task"),
  109. )
  110. }
  111. func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
  112. panic(wire.Build(
  113. repositorySet,
  114. taskSet,
  115. jobSet,
  116. serverSet,
  117. serviceSet,
  118. newApp,
  119. sid.NewSid,
  120. jwt.NewJwt,
  121. ))
  122. }