-
Notifications
You must be signed in to change notification settings - Fork 31
fix(recordings): TargetRecordingGetHandler uses Vert.x asynchronous I/O #877
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
Conversation
The implementation is working well; integration tests are passing and I'm able to download a 1-hour long active recording with no issues. Unfortunately, I'm having issues with getting the unit tests to work. I've only worked on the tests for the v1 version of the handler so far but it should be the same for the v2 handler. The I think the issue may be that the implementation needs a working Vert.x Do you think it's worth adding the |
I think that's a good idea. There are downstream builds of it available too, though that's not strictly required but it is nice to have. It may also help your tests to make a new constructor for the EDIT: ex: https://stackoverflow.com/questions/11941617/executorservice-which-runs-tasks-in-calling-thread |
I've actually already tried passing in an |
Ah, I think I know what the problem is. In their test, the author creates a fleshed-out implementation of |
…to the HttpServerResponse
…sferTo with a buffered write to ensure the target connection remains open
Actually, I should do some |
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.
Patch seems to make sense and appears to work well from some limited testing, so I'll consider this soft-approved for now. I think I'd like to hold off on merging this until after the 2.1.0 branchpoint since that's coming up very soon and this change affects some pretty key API endpoints that we can't really risk introducing a fresh bug into.
Fixes #568
I decided to go with the vertx-java.io library to bridge the gap between the Java blocking I/O and Vert.x async I/O used in the
TargetRecordingGetHandler
. Specifically, theOutputToReadStream#pipeFromInput
function is used to write the contents of the recording stream to theHttpServerResponse
.OutputToReadStream
extends the abstractjava.io.OutputStream
class and implements theio.vertx.core.streams.ReadStream<Buffer>
interface. This is allows it to act as a sort of bridge:InputStream source
->OutputToReadStream otrs
->WriteStream<Buffer> sink
Where the source, in this case, is the active recording and the sink is the
HttpServerResponse
. The first "->" above represents the Java blocking I/O portion of the data flow(InputStream#transferTo(OutputStream)
), which happens asynchronously inside the commonForkJoinPool
. At the same time, Vert.xReadStream#pipeTo(WriteStream)
is used to pipe the data received from this transfer to theHttpServerResponse
.I've added
targetConnectionManager#markConnectionInUse(connectionDescriptor)
checks to theOutputToReadStream
implementation to ensure the target connection remains open.