Skip to content

Conversation

@rozza
Copy link
Member

@rozza rozza commented Feb 17, 2023

Wraps the driver-sync to provide a kotlin sync API

In general a faithful wrapping of the sync java driver. Uses reified overloads to provide syntactic sugar instead of passing resultClass.

MongoIterable deviates from the sync API so to not implement Iterable in order to protect the user from leaving open cursors. In Kotlin there are two Iterable style implementations: Iterable and Sequence neither are auto closable. Sequence is more appropriate here as it lazily consumes the iterator, but it does not auto close. See: https://youtrack.jetbrains.com/issue/KT-34719 So MongoIterable provides a loan method that treats the cursor as a Sequence and automatically closes after use.

JAVA-4869

Todo

  • Confirm the build / test
  • Publishing
  • Add extensions to any Option classes that to default timeunit maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS)
  • Is MongoIterable the correct name?
  • Confirm package namespace - currently com.mongodb.kotlin.client

@rozza rozza requested a review from jyemin February 17, 2023 18:12
@rozza rozza force-pushed the JAVA-4869 branch 2 times, most recently from f73dbb6 to c7b32d2 Compare February 20, 2023 16:31
Wraps the driver-sync to provide a kotlin sync API

In general a faithful wrapping of the sync java driver. Uses reified
overloads to provide synaptic sugar instead of passing resultClass.

MongoIterable deviates from the sync API so to not implement Iterable in
order to protect the user from leaving open cursors. In Kotlin there are two Iterable
style implementations: Iterable and Sequence neither are auto closable.
Sequence is more appropriate here as it lazily consumes the iterator,
but it does not auto close. See: https://youtrack.jetbrains.com/issue/KT-34719
So MongoIterable provides a loan method that treats the cursor as a
Sequence and automatically closes after use.

JAVA-4869
@rozza rozza marked this pull request as ready for review February 20, 2023 17:01
Also updates noticed when working with the coroutine api
Copy link
Collaborator

@jyemin jyemin left a comment

Choose a reason for hiding this comment

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

Gave it a good first look.

@rozza rozza requested a review from jyemin February 28, 2023 14:11
@rozza rozza requested a review from jyemin March 1, 2023 14:53
@rozza rozza requested a review from katcharov March 3, 2023 09:01
Copy link
Collaborator

@katcharov katcharov left a comment

Choose a reason for hiding this comment

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

I looked over the wrappers, looked good, and nice straightforward handling of the default parameters. A few minor comments related to the tests.

@rozza rozza requested a review from katcharov March 6, 2023 10:29
@rozza rozza added the kotlin label Mar 6, 2023
Copy link
Collaborator

@katcharov katcharov left a comment

Choose a reason for hiding this comment

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

LGTM

@zigzago
Copy link

zigzago commented Mar 8, 2023

For some reason I can not resolve my own comments, but the PR is ok for me

…unctions that return the same result when the object state remains the same
@rozza rozza requested a review from jyemin March 17, 2023 12:45
@rozza rozza requested review from cmelchior and jyemin March 21, 2023 13:40
Copy link
Collaborator

@jyemin jyemin left a comment

Choose a reason for hiding this comment

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

LGTM!

@rozza rozza closed this Mar 21, 2023
@rozza
Copy link
Member Author

rozza commented Mar 21, 2023

Will manually rebase and squash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants