Smithy4s integration#58
Conversation
|
@armanbilge, good progress so far. The examples currently hang at the end, but otherwise work as expected : there are two example applications involved, a client and a server. The build is wired in such a way that the client receives through the forkEnv the path to an assembly jar of the server when running A Regarding the hanging : I presume the ChildProcess I've copied and adapted from Davenverse is not sound. I wonder whether it's a similar thing to what led you to run I mean, it's entirely possible/likely that I've messed up something else, but that subprocess stdin/stdout based communication is the only I/O code involved in the example ... |
| @@ -0,0 +1,23 @@ | |||
| $version: "2.0" | |||
|
|
|||
| namespace jsonrpclib | |||
There was a problem hiding this comment.
this smithy file contains the protocol definition. It kind of echoes a question that @ckipp01 had on my BSP PR about where would be a good "central" for protocols.
I suppose DisneyStreaming could host it in https://github.com/disneystreaming/alloy/, but I'm a bit wary about putting it there and have the BSP depend on it ($work project etc etc).
| def stdout: fs2.Stream[F, Byte] = fs2.io | ||
| .readInputStream[F](Sync[F].interruptible(p.getInputStream()), chunkSize = readBufferSize) | ||
|
|
||
| def stderr: fs2.Stream[F, Byte] = fs2.io | ||
| .readInputStream[F](Sync[F].blocking(p.getErrorStream()), chunkSize = readBufferSize) | ||
| // Avoids broken pipe - we cut off when the program ends. | ||
| // Users can decide what to do with the error logs using the exitCode value | ||
| .interruptWhen(done.void.attempt) |
There was a problem hiding this comment.
readInputStream is not using interruptible looks like.
https://github.com/typelevel/fs2/blob/56b86022d48d3caf0a9b5f00bf637cac62bb7f5e/io/shared/src/main/scala/fs2/io/io.scala#L46
So that would probably explain why it is hanging. We can try swapping that, but as you mentioned interruptibility might be broken like it is for stdin. In which case I suppose each Process would have to start its own dedicated blocking threads that it can kill 🤔
There was a problem hiding this comment.
I published 3.7-ae0fc02-SNAPSHOT which swapped in interruptible, you can give that a try and see if it helps?
There was a problem hiding this comment.
Can't resolve yet, are you sure it's the right version ?
There was a problem hiding this comment.
There was a problem hiding this comment.
Doh, my bad. Will try in a bit
There was a problem hiding this comment.
3.7-0ec6699-SNAPSHOT
There was a problem hiding this comment.
Mmm I only get the initial prints from both the client and server side, but then nothing ... It may be because chunks are not automatically flushed in your implementation. That's why I couldn't use the Davenverse lib directly :
There was a problem hiding this comment.
Ok, try this one 3.7-eacce62-SNAPSHOT.
There was a problem hiding this comment.
It works 🎉 most things that should print actually print (except for the server termination message but that's some userland problem), and the program terminates as expected !
* Add method on FS2Channel: resources * Rewrite old stream variant in terms of resource --------- Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com>
* feat: Add jsonPayload trait * Remove useless comments * Add tests for JsonPayloadValidator * Transform errors as well * Use traitValidator --------- Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com>
Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
* Create caches for document encoders * Remove unused imports * Remove redundant classes * Apply review comments * add client side error handling * Mark impl details package private * minor simplification --------- Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com> Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
|
Can't approve my own PR, but LGTM (I'm mostly interested in what you did in the core, I trust you for the smithy4s and tests-related code) |
Adds a
smithy4smodule, allowing to automatically derive endpoints and stubs from smithy definitionsRelated PRs: