| 73 | } |
| 74 | |
| 75 | func (m *Monitorable) Enable(variantName coreModels.VariantName) { |
| 76 | conf := m.config[variantName] |
| 77 | |
| 78 | // Custom UpstreamCacheExpiration only for count because github has no-cache for this query and the rate limit is 30req/Hour |
| 79 | countCacheExpiration := time.Millisecond * time.Duration(conf.CountCacheExpiration) |
| 80 | |
| 81 | repository := githubRepository.NewGithubRepository(conf) |
| 82 | usecase := githubUsecase.NewGithubUsecase(repository) |
| 83 | delivery := githubDelivery.NewGithubDelivery(usecase) |
| 84 | |
| 85 | // EnableTile route to echo |
| 86 | routeGroup := m.store.MonitorableRouter.Group("/github", variantName) |
| 87 | routeCount := routeGroup.GET("/count", delivery.GetCount, options.WithCustomCacheExpiration(countCacheExpiration)) |
| 88 | routeChecks := routeGroup.GET("/checks", delivery.GetChecks) |
| 89 | routePullRequest := routeGroup.GET("/pullrequest", delivery.GetPullRequest) |
| 90 | |
| 91 | // EnableTile data for config hydration |
| 92 | m.countTileEnabler.Enable(variantName, &githubModels.CountParams{}, routeCount.Path) |
| 93 | m.checksTileEnabler.Enable(variantName, &githubModels.ChecksParams{}, routeChecks.Path) |
| 94 | m.pullRequestTileEnabler.Enable(variantName, &githubModels.PullRequestParams{}, routePullRequest.Path) |
| 95 | m.pullRequestGeneratorEnabler.Enable(variantName, &githubModels.PullRequestGeneratorParams{}, usecase.PullRequestsGenerator) |
| 96 | } |