You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/kotlin-coroutines.adoc
+9
Original file line number
Diff line number
Diff line change
@@ -80,4 +80,13 @@ Coroutines repositories are built on reactive repositories to expose the non-blo
80
80
Methods on a Coroutines repository can be backed either by a query method or a custom implementation.
81
81
Invoking a custom implementation method propagates the Coroutines invocation to the actual implementation method if the custom method is `suspend`-able without requiring the implementation method to return a reactive type such as `Mono` or `Flux`.
82
82
83
+
Note that depending on the method declaration the coroutine context may or may not be available.
84
+
To retain access to the context, either declare your method using `suspend` or return a type that enables context propagation such as `Flow`.
85
+
86
+
* `suspend fun findOne(id: String): User`: Retrieve the data once and synchronously by suspending.
87
+
* `fun findByFirstname(firstname: String): Flow<User>`: Retrieve a stream of data.
88
+
The `Flow` is created eagerly while data is fetched upon `Flow` interaction (`Flow.collect(…)`).
89
+
* `fun getUser(): User`: Retrieve data once *blocking the thread* and without context propagation.
90
+
This should be avoided.
91
+
83
92
NOTE: Coroutines repositories are only discovered when the repository extends the `CoroutineCrudRepository` interface.
0 commit comments