Skip to content

Commit b0817cc

Browse files
committed
Merge branch 'master' into jhwang/fix-viewdashboard-action
* master: Revert "Add Vitess Sharded Key Range Support for SqlDelight" (#540) Increasing the number of variants per service (#539)
2 parents 4aca29e + 42e87cb commit b0817cc

File tree

25 files changed

+85
-1480
lines changed

25 files changed

+85
-1480
lines changed

client-sqldelight-gradle-plugin/src/main/kotlin/app/cash/backfila/client/sqldelight/plugin/GenerateBackfilaRecordSourceQueriesTask.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,6 @@ abstract class GenerateBackfilaRecordSourceQueriesTask : DefaultTask() {
163163
.addStatement("return database.%L.%LGetBatch(start, end)", queriesFunctionName, lowerName)
164164
.addModifiers(OVERRIDE)
165165
.build(),
166-
).addFunction(
167-
FunSpec.builder("tableName")
168-
.returns(String::class)
169-
.addStatement("return %S", backfillConfig.tableName)
170-
.addModifiers(OVERRIDE)
171-
.build(),
172-
).addFunction(
173-
FunSpec.builder("primaryKeyColumn")
174-
.returns(String::class)
175-
.addStatement("return %S", backfillConfig.keyName)
176-
.addModifiers(OVERRIDE)
177-
.build(),
178166
).build(),
179167
).build()
180168

client-sqldelight-gradle-plugin/src/test/kotlin/app/cash/backfila/client/sqldelight/plugin/BackfilaSqlDelightGradlePluginTest.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,6 @@ class BackfilaSqlDelightGradlePluginTest {
3333
.contains(result.task(taskName)!!.outcome)
3434
}
3535

36-
@Test
37-
fun `generated config includes tableName and primaryKeyColumn methods`() {
38-
val projectDir = File("src/test/projects/happyPath")
39-
40-
// Build the project
41-
val taskName = ":lib:compileKotlin"
42-
createRunner(projectDir, "clean", taskName).build()
43-
44-
// Check the generated file contains the expected methods
45-
val generatedFile = File(
46-
projectDir,
47-
"lib/build/backfilaSqlDelight/hockeyPlayerOrigin/kotlin/app/cash/backfila/client/sqldelight/hockeydata/HockeyPlayerOriginRecordSourceConfig.kt",
48-
)
49-
assertThat(generatedFile).exists()
50-
51-
val content = generatedFile.readText()
52-
53-
// Verify tableName() method is generated with correct value
54-
assertThat(content).contains("override fun tableName(): String = \"hockeyPlayer\"")
55-
56-
// Verify primaryKeyColumn() method is generated with correct value
57-
assertThat(content).contains("override fun primaryKeyColumn(): String = \"player_number\"")
58-
}
59-
6036
private fun createRunner(
6137
projectDir: File,
6238
vararg taskNames: String,

client-sqldelight-test/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,19 @@ dependencies {
5757
testImplementation(libs.assertj)
5858
testImplementation(libs.junitEngine)
5959
testImplementation(libs.kotlinTest)
60+
61+
testImplementation(project(":backfila-embedded"))
62+
testImplementation(project(":client-testing"))
63+
64+
// ****************************************
65+
// For TESTING purposes only. We only want Misk for easy testing.
66+
// DO NOT turn these into regular dependencies.
67+
// ****************************************
68+
testImplementation(libs.misk)
69+
testImplementation(libs.miskActions)
70+
testImplementation(libs.miskInject)
71+
testImplementation(libs.miskJdbc)
72+
testImplementation(testFixtures(libs.miskJdbc))
73+
testImplementation(libs.miskTesting)
74+
testImplementation(project(":client-misk"))
6075
}

client-sqldelight/src/test/kotlin/app/cash/backfila/client/sqldelight/PlayerOriginBackfillTest.kt renamed to client-sqldelight-test/src/test/kotlin/app/cash/backfila/client/sqldelight/PlayerOriginBackfillTest.kt

File renamed without changes.

client-sqldelight/src/test/kotlin/app/cash/backfila/client/sqldelight/TestBackfillsModule.kt renamed to client-sqldelight-test/src/test/kotlin/app/cash/backfila/client/sqldelight/TestBackfillsModule.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,28 @@ import javax.inject.Provider
1515
import javax.inject.Singleton
1616
import javax.sql.DataSource
1717
import misk.inject.KAbstractModule
18+
import misk.jdbc.DataSourceConfig
19+
import misk.jdbc.DataSourceType
20+
import misk.jdbc.JdbcModule
1821

1922
/**
2023
* Simulates a Backfills module where all the relevant backfills are registered.
2124
*/
22-
class TestBackfillsModule(
23-
private val useVitess: Boolean = false,
24-
private val vitessPort: Int = 27003,
25-
) : KAbstractModule() {
25+
class TestBackfillsModule : KAbstractModule() {
2626
override fun configure() {
27+
install(
28+
JdbcModule(
29+
HockeyDataDb::class,
30+
DataSourceConfig(
31+
type = DataSourceType.MYSQL,
32+
username = "root",
33+
password = "",
34+
database = "hockeydata_testing",
35+
migrations_resource = "classpath:/migrations",
36+
),
37+
),
38+
)
39+
2740
install(
2841
MiskBackfillModule(
2942
BackfilaHttpClientConfig(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package app.cash.backfila.client.sqldelight
2+
3+
import app.cash.backfila.client.sqldelight.persistence.HockeyDataDb
4+
import app.cash.backfila.embedded.EmbeddedBackfilaModule
5+
import misk.MiskTestingServiceModule
6+
import misk.environment.DeploymentModule
7+
import misk.inject.KAbstractModule
8+
import misk.jdbc.JdbcTestingModule
9+
import misk.logging.LogCollectorModule
10+
import wisp.deployment.TESTING
11+
12+
/**
13+
* Simulates a specific service implementation module
14+
*/
15+
class TestingModule : KAbstractModule() {
16+
override fun configure() {
17+
install(DeploymentModule(TESTING))
18+
install(LogCollectorModule())
19+
install(MiskTestingServiceModule())
20+
install(JdbcTestingModule(HockeyDataDb::class))
21+
22+
install(EmbeddedBackfilaModule())
23+
24+
install(TestBackfillsModule())
25+
}
26+
}

client-sqldelight/build.gradle.kts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,9 @@ dependencies {
2424
implementation(libs.retrofitWire)
2525
implementation(libs.wireMoshiAdapter)
2626

27-
// Misk dependencies for Vitess support
28-
implementation(libs.miskJdbc)
29-
implementation(libs.miskVitess)
30-
3127
api(project(":client"))
3228
// We do not want to leak client-base implementation details to customers.
3329
implementation(project(":client-base"))
34-
35-
testImplementation(libs.assertj)
36-
testImplementation(libs.junitEngine)
37-
testImplementation(libs.kotlinTest)
38-
39-
testImplementation(project(":client-sqldelight-test")) // Test fixtures
40-
testImplementation(project(":backfila-embedded"))
41-
testImplementation(project(":client-testing"))
42-
testImplementation(project(":client-misk"))
43-
44-
// Misk testing framework (for @MiskTest)
45-
testImplementation(libs.misk)
46-
testImplementation(libs.miskActions)
47-
testImplementation(libs.miskInject)
48-
testImplementation(libs.miskJdbc)
49-
testImplementation(testFixtures(libs.miskJdbc))
50-
testImplementation(libs.miskVitess)
51-
testImplementation(testFixtures(libs.miskVitess))
52-
testImplementation(libs.miskTesting)
5330
}
5431

5532
configure<MavenPublishBaseExtension> {

client-sqldelight/src/main/kotlin/app/cash/backfila/client/sqldelight/BoundingRangeStrategy.kt

Lines changed: 0 additions & 85 deletions
This file was deleted.

client-sqldelight/src/main/kotlin/app/cash/backfila/client/sqldelight/PartitionProvider.kt

Lines changed: 0 additions & 53 deletions
This file was deleted.

client-sqldelight/src/main/kotlin/app/cash/backfila/client/sqldelight/SqlDelightDatasourceBackfill.kt

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,15 @@ import app.cash.backfila.client.BackfillConfig
55
import app.cash.backfila.client.PrepareBackfillConfig
66

77
/**
8-
* Base class for SqlDelight-based backfills.
8+
* K - Key type
9+
* R - Row type
10+
* P - Parameters type
911
*
10-
* K - Key type (primary key type, must be Comparable for Vitess strategies)
11-
* R - Row type (the record returned by SqlDelight queries)
12-
* P - Parameters type (user-defined parameters for the backfill)
13-
*
14-
* For unsharded databases, simply extend this class:
15-
* ```kotlin
16-
* class MyBackfill @Inject constructor(
17-
* myDatabase: MyDatabase,
18-
* ) : SqlDelightDatasourceBackfill<Long, MyRecord, NoParameters>(
19-
* MyRecordSourceConfig(myDatabase),
20-
* )
21-
* ```
22-
*
23-
* For Vitess sharded databases, override [partitionProvider]:
24-
* ```kotlin
25-
* class MyBackfill @Inject constructor(
26-
* myDatabase: MyDatabase,
27-
* @MyDb dataSourceService: DataSourceService,
28-
* ) : SqlDelightDatasourceBackfill<Long, MyRecord, NoParameters>(
29-
* MyRecordSourceConfig(myDatabase),
30-
* ) {
31-
* override fun partitionProvider() = VitessShardedPartitionProvider(
32-
* dataSourceService,
33-
* Keyspace("my_keyspace"),
34-
* )
35-
* }
36-
* ```
37-
*
38-
* @param recordSourceConfig The SqlDelight query config for this backfill.
3912
*/
4013
abstract class SqlDelightDatasourceBackfill<K : Any, R : Any, P : Any>(
4114
val recordSourceConfig: SqlDelightRecordSourceConfig<K, R>,
4215
) : Backfill {
4316

44-
/**
45-
* Returns the partition provider for this backfill.
46-
*
47-
* Override this to use Vitess-aware partition providers like [VitessShardedPartitionProvider]
48-
* or [VitessSingleCursorPartitionProvider].
49-
*
50-
* The partition provider also determines the [BoundingRangeStrategy] via its
51-
* [PartitionProvider.boundingRangeStrategy] method.
52-
*/
53-
open fun partitionProvider(): PartitionProvider = UnshardedPartitionProvider()
54-
5517
/**
5618
* Override this and throw an exception to prevent the backfill from being created.
5719
* This is also a good place to do any prep work before batches are run.

0 commit comments

Comments
 (0)