wire.go 3.4 KB

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