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

Explicit save() of cassettes? #110

Open
andersthomson opened this issue Sep 11, 2023 · 2 comments
Open

Explicit save() of cassettes? #110

andersthomson opened this issue Sep 11, 2023 · 2 comments
Labels
needs info More information is needed to proceed further.

Comments

@andersthomson
Copy link

Hi,

Thanks for a great tool! I use it extensively for running test. one thing I've noticed is that whenever in captuing mode, saving http traffic, it appears to save the cassette to disk for each new track. It appears to entail both json marshaling and a disk write. Some of my tests are long, with thousands of requests, and this amount of writing cause the capturing phase to grind to a crawl when the cassette gets larger in size.

Would it be possible to defer the (json rendering and) writing to disk until an explicit .Save() call is made?

Thanks!

@seborama
Copy link
Owner

seborama commented Apr 10, 2024

Hi

So sorry about the silence: I wasn't aware you had raised an issue. Somehow I didn't get an email. I need to check my settings...

The reason for saving cassettes early was to ensure they exist. I also suspect there were causality reasons but I don't remember exactly what off the top of my head.

I'll try and have a look into this in the near future.

Regards!

@seborama
Copy link
Owner

seborama commented Apr 13, 2024

Hi @andersthomson ,
Could you give more context about the need to keep cassettes in memory?

govcr works by recording a request the first time it is made and replaying it after that.
In practice, this means that govcr executes requests a lot faster than plain http because it acts as a cache. You only incur a save the first time a track is recorded.

Are you only making new live requests? In such case, you might be misusing govcr and not matching your requests properly (the doc, the cookbook and examples show how to deal with request matching).

If by nature you need your requests to be executed live all the time, govcr is just not needed. Perhaps you're using gvcr to record requests (and not replay)? I'd recommend you just implement your own custom http.Transport, as you will get better performance: govcr implements a rule parser which would be needless if what you want is a plain recorder (in fact, Go already has that in the test packages).

@seborama seborama added the needs info More information is needed to proceed further. label Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info More information is needed to proceed further.
Projects
None yet
Development

No branches or pull requests

2 participants