-
Notifications
You must be signed in to change notification settings - Fork 4
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
Smithy4s integration #58
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
import scala.jdk.CollectionConverters._ | ||
import java.io.OutputStream | ||
|
||
trait ChildProcess[F[_]] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking forward to killing this off when fs2.io
has a solution for it
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't resolve yet, are you sure it's the right version ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh, my bad. Will try in a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.7-0ec6699-SNAPSHOT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, I missed that. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, try this one 3.7-eacce62-SNAPSHOT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 !
Adds a
smithy4s
module, allowing to automatically derive endpoints and stubs from smithy definitionsTodos :