Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLDelight integration #3

Merged
merged 5 commits into from
Mar 11, 2021
Merged

SQLDelight integration #3

merged 5 commits into from
Mar 11, 2021

Conversation

wzieba
Copy link
Owner

@wzieba wzieba commented Mar 10, 2021

No description provided.

@wzieba wzieba marked this pull request as draft March 10, 2021 13:08
@wzieba wzieba force-pushed the local_database branch 2 times, most recently from 77b55ed to 80cfe8a Compare March 11, 2021 09:50
}

val iosFrameworkName = "shared"
val kotlinVersion = "1.4.3-native-mt"
val kotlinVersion = "1.4.2-native-mt"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocked by Turbine cashapp/turbine#29

Comment on lines 27 to 31
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
Copy link
Owner Author

@wzieba wzieba Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be handled with Hierarchical Project Structure but when I look for Kotlin targets in packForXcode task, I still see native targets:

{android=target android (androidJvm), iosArm64=target iosArm64 (native), iosX64=target iosX64 (native), metadata=target metadata (common)}

This might be a problem with documentation or I don't understand something. I plan to create an issue for that on KMM documentation.

matching {
it.name.endsWith("Test")
}.configureEach {
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use Turbine which uses Kotlin's Duration.

Comment on lines +24 to +32
event_name = tracksEvent.name,
user = "",
user_agent = null,
timestamp = null,
retry_count = null,
user_type = null,
user_props = null,
device_info = null,
custom_props = null
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this structure is taken from current implementation of Tracks, I wasn't sure if it's all needed, probably we'll verify that later.

import kotlinx.coroutines.runBlocking
import kotlin.test.assertTrue

internal class DatabaseTests {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole idea for DatabaseTests is to test SQLDelight on each platform (Android and iOS) with its native driver.

We have to create a native driver in platform-specific source sets as it requires platform specific dependencies, like Context in Android. So we create it there and then run DatabaseTests.

The cons of this approach are less readable test results as we technically have only one @Test (that will run multiple tests) but we can see which test failed in the stacktrace which is not the worse thing ever.

The other idea would be to create a new, test-only multiplatform module like KaMPKit does, but it'd require us to remove internal from classes we want to be internal and this would cause a lot of problems for consumers I believe.

@wzieba wzieba marked this pull request as ready for review March 11, 2021 11:11
@wzieba wzieba requested a review from 0nko March 11, 2021 11:11
@wzieba
Copy link
Owner Author

wzieba commented Mar 11, 2021

I'll merge this @0nko , please feel free though to add any comments you have after merge - I'll apply improvements in next PRs

@wzieba wzieba merged commit d0e8e76 into main Mar 11, 2021
@wzieba wzieba deleted the local_database branch March 11, 2021 13:43
remoteRepository.send(event)
localRepository.observe().collect { events ->
if (events.isNotEmpty()) {
remoteRepository.send(events.first())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just the first? Shouldn't we iterate over all events?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea I was having was to pick the first (or e.g. "the most important") event, process it, send and after successful sending - remove it from DB which will trigger the observe again.

But we could e.g. order events here from "the most important" to the less and then send whole list to RemoteRepository - both works fine for me.


"most important" - TBD, maybe number of failed attempts or something like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants