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

Full document serialization #1355

Merged
merged 102 commits into from
May 4, 2023
Merged

Full document serialization #1355

merged 102 commits into from
May 4, 2023

Conversation

clementetb
Copy link
Contributor

@clementetb clementetb commented Apr 19, 2023

Full document serialization enables using any class as argument and return types to:

  • Custom function credentials
  • Atlas function calls
  • User profile and custom data

It uses the new experimental EJson decoder available in Kbson. The decoder is based on kserializer and there are some considerations to have into account.

  1. It is an experimental feature and it is subject to change.

  2. Custom function credentials are late evaluated when the instance is actually used. This is required because the payload encoding requires access to the EJson instance defined in the App configuration, but because Credentials are decoupled from the App we only can have access to the App instance when the Credentials are actually being used.

  3. Atlas function calls now use a Builder pattern. This is required because kserializer does not support runtime serializer lookup, which we are required to do in compile time.

  4. Values must be @Serializable or a custom serializer must be specified on call.

Examples

Credentials

Crendetials.customFunction(
   Payload(
       name = "hello",
       id = 400
   )
)

User profile and custom Data

val profile: MyCustomProfile = user.profile()

val customData: MyCustomData = user.customData()

Function call

val dog: Dog = user.functions.call("findDog") {
    add(Owner(name = "Luis"))
    add("Golden retriever")
}

Pending

  • Changelog
  • Examples
  • Update to KBson 0.3.0

closes #994

Eduardo López and others added 30 commits January 12, 2023 08:54
# Conflicts:
#	.github/workflows/issue-needs-attention.yml
# Conflicts:
#	packages/test-base/src/commonMain/kotlin/io/realm/kotlin/test/util/TypeDescriptor.kt
…`, `put`, `putAll`, `remove` and `clear` (#1219)
# Conflicts:
#	packages/jni-swig-stub/realm.i
# Conflicts:
#	packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmObjectHelper.kt
#	packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmSetInternal.kt
#	packages/test-base/src/androidAndroidTest/kotlin/io/realm/kotlin/test/shared/RealmSetTests.kt
… support for Decimal128 in `copyFromRealm` (#1255)
# Conflicts:
#	packages/external/core
#	packages/jni-swig-stub/realm.i
# Conflicts:
#	packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmInstantImpl.kt
#	packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/AppConfiguration.kt
#	packages/test-base/src/androidAndroidTest/kotlin/io/realm/kotlin/test/shared/SerializationTests.kt
#	packages/test-base/src/commonMain/kotlin/io/realm/kotlin/entities/SerializableSample.kt
@clementetb clementetb marked this pull request as ready for review April 27, 2023 08:16
@rorbech
Copy link
Contributor

rorbech commented Apr 27, 2023

I am a bit confused about the @OptIns, but maybe I am just missing some pieces. Just to clarify before going into details:

  • I would expect that you can still use the current API without opt'ing in to anything and that it is only new stuff that requires opt'ing in, right? And
  • Are the any need for an API surface that requires users to opt into KBson's ExperimentalKSerializerApi without also wanting to use our ExperimentalRealmSerializerApi?

Copy link
Contributor

@cmelchior cmelchior left a comment

Choose a reason for hiding this comment

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

Looking good. Minor comments and awaiting final approval until CI is green.

clementetb and others added 12 commits May 3, 2023 10:31
Co-authored-by: Christian Melchior <christian@ilios.dk>
…notations/ExperimentalRealmSerializerApi.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
…notations/ExperimentalRealmSerializerApi.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
…ngodb/AppConfiguration.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
…ngodb/internal/CustomEJsonCredentialsImpl.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
Copy link
Contributor

@cmelchior cmelchior left a comment

Choose a reason for hiding this comment

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

Awesome 🚀

…ngodb/ext/FunctionsExt.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
@clementetb clementetb merged commit a2ec352 into main May 4, 2023
@clementetb clementetb deleted the ct/document-serialization branch May 4, 2023 12:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document support in KBson
3 participants