Skip to content

Commit

Permalink
Move DevelopmentService to test to allow for logging to stdout by def…
Browse files Browse the repository at this point in the history
…ault.
  • Loading branch information
mpawliszyn committed Oct 16, 2023
1 parent e74dc1f commit 8fbb47e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ object Dependencies {
val retrofitWire = "com.squareup.retrofit2:converter-wire:2.9.0"
val shadowJarPlugin = "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
val slf4jApi = "org.slf4j:slf4j-api:2.0.3"
val slf4jSimple = "org.slf4j:slf4j-simple:2.0.3"
val spotlessPlugin = "com.diffplug.spotless:spotless-plugin-gradle:6.12.0"
val tracingJaeger = "io.jaegertracing:jaeger-core:1.1.0"

Expand Down
1 change: 1 addition & 0 deletions service-self-backfill/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ dependencies {
testImplementation(Dependencies.kotlinxCoroutinesTest)
testImplementation(Dependencies.assertj)
testImplementation(Dependencies.openTracingMock)
testImplementation(Dependencies.slf4jSimple)

testImplementation(project(":backfila-embedded"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package app.cash.backfila.service.selfbackfill

import app.cash.backfila.client.BackfilaClientServiceClient
import app.cash.backfila.client.BackfilaClientServiceClientProvider
import app.cash.backfila.client.BackfilaDefaultEndpointConfigModule
import app.cash.backfila.client.ForConnectors
import app.cash.backfila.dashboard.ViewLogsUrlProvider
import app.cash.backfila.protos.clientservice.GetNextBatchRangeRequest
import app.cash.backfila.protos.clientservice.GetNextBatchRangeResponse
import app.cash.backfila.protos.clientservice.KeyRange
import app.cash.backfila.protos.clientservice.PrepareBackfillRequest
import app.cash.backfila.protos.clientservice.PrepareBackfillResponse
import app.cash.backfila.protos.clientservice.RunBatchRequest
import app.cash.backfila.protos.clientservice.RunBatchResponse
import app.cash.backfila.service.BackfilaConfig
import app.cash.backfila.service.BackfilaServiceModule
import app.cash.backfila.service.persistence.DbBackfillRun
Expand All @@ -21,6 +31,7 @@ import misk.security.authz.MiskCallerAuthenticator
import misk.web.MiskWebModule
import misk.web.WebConfig
import misk.web.dashboard.AdminDashboardModule
import okio.ByteString.Companion.encodeUtf8
import wisp.deployment.Deployment

internal fun main(args: Array<String>) {
Expand All @@ -39,6 +50,43 @@ internal fun main(args: Array<String>) {
bind<MiskCaller>().annotatedWith<DevelopmentOnly>()
.toInstance(MiskCaller(user = "testfila"))
bind<ViewLogsUrlProvider>().to<DevelopmentViewLogsUrlProvider>()

newMapBinder<String, BackfilaClientServiceClientProvider>(ForConnectors::class)
.permitDuplicates().addBinding("DEV")
.toInstance(object : BackfilaClientServiceClientProvider {
override fun validateExtraData(connectorExtraData: String?) {
}

override fun clientFor(
serviceName: String,
connectorExtraData: String?,
): BackfilaClientServiceClient {
return object : BackfilaClientServiceClient {
override fun prepareBackfill(request: PrepareBackfillRequest): PrepareBackfillResponse {
return PrepareBackfillResponse.Builder()
.partitions(
listOf(
PrepareBackfillResponse.Partition(
"-80", KeyRange("0".encodeUtf8(), "1000".encodeUtf8()), null,
),
PrepareBackfillResponse.Partition(
"80-", KeyRange("0".encodeUtf8(), "1000".encodeUtf8()), null,
),
),
).build()
}

override suspend fun getNextBatchRange(request: GetNextBatchRangeRequest): GetNextBatchRangeResponse {
TODO("Not yet implemented")
}

override suspend fun runBatch(request: RunBatchRequest): RunBatchResponse {
TODO("Not yet implemented")
}
}
}
},
)
}
},
DeploymentModule(deployment),
Expand Down
1 change: 1 addition & 0 deletions service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dependencies {
testImplementation(Dependencies.assertj)
testImplementation(Dependencies.openTracingMock)
testImplementation(Dependencies.okHttpMockWebServer)
testImplementation(Dependencies.slf4jSimple)
}

val jar by tasks.getting(Jar::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fun main(args: Array<String>) {
).run(args)
}

class DevelopmentViewLogsUrlProvider : ViewLogsUrlProvider {
internal class DevelopmentViewLogsUrlProvider : ViewLogsUrlProvider {
override fun getUrl(session: Session, backfillRun: DbBackfillRun): String {
return "/"
}
Expand Down

0 comments on commit 8fbb47e

Please sign in to comment.