wire.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. )
  52. var taskSet = wire.NewSet(
  53. task.NewTask,
  54. task.NewUserTask,
  55. task.NewGameShieldTask,
  56. task.NewWafTask,
  57. )
  58. var jobSet = wire.NewSet(
  59. job.NewJob,
  60. job.NewUserJob,
  61. job.NewWhitelistJob,
  62. )
  63. var serverSet = wire.NewSet(
  64. server.NewTaskServer,
  65. server.NewJobServer,
  66. )
  67. var serviceSet = wire.NewSet(
  68. service.NewService,
  69. service.NewAoDunService,
  70. gameShield.NewGameShieldService,
  71. service.NewCrawlerService,
  72. service.NewGameShieldPublicIpService,
  73. service.NewDuedateService,
  74. service.NewFormatterService,
  75. service.NewParserService,
  76. service.NewRequiredService,
  77. service.NewHostService,
  78. gameShield.NewGameShieldBackendService,
  79. service.NewGameShieldSdkIpService,
  80. service.NewGameShieldUserIpService,
  81. waf.NewWafFormatterService,
  82. flexCdn.NewCdnService,
  83. service.NewRequestService,
  84. waf.NewTcpforwardingService,
  85. waf.NewUdpForWardingService,
  86. waf.NewWebForwardingService,
  87. flexCdn.NewProxyService,
  88. flexCdn.NewSslCertService,
  89. flexCdn.NewWebsocketService,
  90. flexCdn.NewCcService,
  91. waf.NewGatewayipService,
  92. service.NewLogService,
  93. )
  94. // build App
  95. func newApp(
  96. task *server.TaskServer,
  97. jobServer *server.JobServer,
  98. ) *app.App {
  99. return app.NewApp(
  100. app.WithServer(task, jobServer),
  101. app.WithName("demo-task"),
  102. )
  103. }
  104. func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
  105. panic(wire.Build(
  106. repositorySet,
  107. taskSet,
  108. jobSet,
  109. serverSet,
  110. serviceSet,
  111. newApp,
  112. sid.NewSid,
  113. jwt.NewJwt,
  114. ))
  115. }