Skip to content

Commit 4aca29e

Browse files
committed
Add default no-op implementations for ViewLogsUrlProvider and ViewDashboardUrlProvider
PR #537 introduced ViewDashboardAction and ViewLogsAction which require ViewDashboardUrlProvider and ViewLogsUrlProvider to be bound in the Guice injector. However, these bindings were not provided in BackfilaServiceModule, causing injection failures in downstream services like cash-server. This change adds default no-op implementations that return '#' as placeholder URLs. These satisfy Guice's dependency requirements and allow the service to start successfully. Deployments can override these bindings with real implementations that link to their actual logging and monitoring infrastructure. Fixes cash-server InjectorTest failures.
1 parent 0cbe75e commit 4aca29e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

service/src/main/kotlin/app/cash/backfila/service/BackfilaServiceModule.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import app.cash.backfila.client.GrpcCallbackConnectorProvider
99
import app.cash.backfila.client.HttpCallbackConnectorProvider
1010
import app.cash.backfila.dashboard.BackfilaDashboardModule
1111
import app.cash.backfila.dashboard.BackfilaWebActionsModule
12+
import app.cash.backfila.dashboard.ViewDashboardUrlProvider
13+
import app.cash.backfila.dashboard.ViewLogsUrlProvider
1214
import app.cash.backfila.service.listener.BackfilaListenerModule
1315
import app.cash.backfila.service.persistence.BackfilaPersistenceModule
16+
import app.cash.backfila.service.persistence.DbBackfillRun
1417
import app.cash.backfila.service.runner.BackfillRunnerLoggingSetupProvider
1518
import app.cash.backfila.service.runner.BackfillRunnerNoLoggingSetupProvider
1619
import app.cash.backfila.service.scheduler.ForBackfilaScheduler
@@ -23,6 +26,7 @@ import java.util.concurrent.Executors
2326
import javax.inject.Qualifier
2427
import javax.inject.Singleton
2528
import misk.config.ConfigModule
29+
import misk.hibernate.Session
2630
import misk.inject.KAbstractModule
2731
import misk.security.authz.AccessAnnotationEntry
2832
import misk.slack.SlackModule
@@ -68,6 +72,11 @@ class BackfilaServiceModule(
6872

6973
bind<BackfillRunnerLoggingSetupProvider>().to(runnerLoggingSetupProvider)
7074

75+
// Provide default no-op implementations for URL providers
76+
// Deployments should override these with real implementations
77+
bind<ViewLogsUrlProvider>().to<NoOpViewLogsUrlProvider>()
78+
bind<ViewDashboardUrlProvider>().to<NoOpViewDashboardUrlProvider>()
79+
7180
if (config.slack != null) {
7281
install(SlackModule(config.slack))
7382
}
@@ -88,3 +97,25 @@ class BackfilaServiceModule(
8897
)
8998
}
9099
}
100+
101+
/**
102+
* Default no-op implementation for ViewLogsUrlProvider.
103+
* Deployments should override this binding with a real implementation that provides
104+
* links to their logging infrastructure.
105+
*/
106+
internal class NoOpViewLogsUrlProvider : ViewLogsUrlProvider {
107+
override fun getUrl(session: Session, backfillRun: DbBackfillRun): String {
108+
return "#" // Return a no-op URL
109+
}
110+
}
111+
112+
/**
113+
* Default no-op implementation for ViewDashboardUrlProvider.
114+
* Deployments should override this binding with a real implementation that provides
115+
* links to their dashboard/monitoring infrastructure.
116+
*/
117+
internal class NoOpViewDashboardUrlProvider : ViewDashboardUrlProvider {
118+
override fun getUrl(session: Session, backfillRun: DbBackfillRun): String {
119+
return "#" // Return a no-op URL
120+
}
121+
}

0 commit comments

Comments
 (0)