Skip to content

Commit d3523bc

Browse files
committed
update readme
1 parent 263a744 commit d3523bc

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,35 @@ by the same author and offers similar functionality. It's fully asynchronous bu
100100
Another option would be to use one Spring's database facilities that supports R2DBC, which is also async. I've not tried this approach
101101
yet but imagine it could be wrapped with cats-effect IO similarly to what was done with [Mono] in the controller layer.
102102

103+
# Issues
104+
## IO[T] to Mono[T] Conversion
105+
Right now this conversion is done in the controller layer like this:
106+
```scala
107+
private given ioToMono[A](): Conversion[IO[A], Mono[A]] with {
108+
def apply(io: IO[A]): Mono[A] = {
109+
Mono.fromFuture(new CompletableFuture[A]().tap { cf =>
110+
io.unsafeRunAsync {
111+
case Right(value) => cf.complete(value)
112+
case Left(error) => cf.completeExceptionally(error)
113+
}
114+
})
115+
}
116+
}
117+
```
118+
There may be performance issues going between the WebFlux and Cats Effect threadpools, particularly when
119+
running in an environment with a small number of CPU cores. This has to do with how time sharing is handled with fibers / virtual threads;
120+
in Cats Effect, a fiber generally [only yields on an IO boundary](https://typelevel.org/cats-effect/docs/2.x/datatypes/io), or in other words, when one of it's composite IO blocks completes.
121+
This is fundamentally different from true threads where the OS scheduler ensures each thread gets a fair amount of CPU time regardless of
122+
where / what each thread is doing.
123+
124+
Ideally there is at least one CPU core dedicated to each thread in each pool, but I am not sure how thread affinity works here
125+
or if it is even possible to exclusively bind a CPU to each of these threads. I also plan to provide better detail on
126+
what happens under load in situations where there are fewer cores than threads, or even a single core.
127+
103128
# Future Improvements
104129
## Spring Security
105-
In particular, add JTW authentication and secured endpoints + tests
130+
* Add OAuth2 request/ refresh tokens
131+
* Add Oauth2 client to support third party authentication (Google, etc)
106132

107133
## Async Rest Controller
108134
Create an AsyncController that demonstrates adapting Spring's async programming model

0 commit comments

Comments
 (0)