Open simplesteph opened 5 years ago
In this example the server prints both messages but client only prints the first.
@fiadliel please advise if
there is a way to write the client to get both server replies using the generated stub.
Will it work using java_runtime.client.Fs2ClientCall
and the generated server?
Is there a way (with the generated client) to get incremental replies for same call? Server writes some replies, client gets them, server continues with some more replies, clients gets them too, etc. In other words the lazy evaluation stream semantics is respected (as opposed to a list).
Note: used a version of the sbt-java-gen
plugin I custom built with special versions of some dependencies but did not change anything else (0.3.0 will work just as well).
In the for-comprehension:
_ <- runProgramStream(helloStub)
} yield StreamApp.ExitCode.Success
You are running Stream#flatMap
, and yielded the exit code on first reply.
Your server implementation is also confusing, if not buggy.
_ ← sayHello(req, clientHeaders)
_ ← IO(println(s"Pausing a little ..."))
_ ← IO(println(s"Responding to lady $req again"))
_ ← timer.sleep(1 second)
r ← sayHello(req, clientHeaders)
All the first sayHello
does is to calculate a response, which you discarded. If you want multiple reply for one incoming message, use flatMap
and construct your multiple response stream instead of using evalMap
.
Would be great to get client streaming, server streaming and bi-di streaming examples if possible? Including how to properly handle cancellation!