Skip to content
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

Stream VCR entries to the output file #30

Open
reibitto opened this issue Apr 14, 2021 · 0 comments
Open

Stream VCR entries to the output file #30

reibitto opened this issue Apr 14, 2021 · 0 comments

Comments

@reibitto
Copy link
Owner

Right now the recorded VCR entries only get written to disk on close(). This was intentional as I didn't want partial results getting written to disk in cases like if the tests blew up with an exception and so on.

I feel this "all or nothing" approach is the right default. Having said that, the user may want to write requests/responses immediately for various reasons. Maybe writing a proper shutdown/cleanup phase isn't straightforward in their app (some DI frameworks make this difficult). Adding an option to change the default write strategy might be helpful. The only tricky part is that if you write immediately with certain formats like JSON, then that final } needs to be properly handled. You can't just stream JSON to disk in a straightforward way. I guess either backtrack or use RandomAccessFile? I'm not sure, but that part would need to be investigated.

Besides that though, one downside with the current approach is that the requests/responses are held in memory until close() is called. Maybe it's not too big of a concern, but memory consumption could be decreased by streaming to a temporarily file first. And then on close() move that temporarily file to the "real" path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant