theseus-rs / postgresql-embedded

Embed PostgreSQL database
Apache License 2.0
33 stars 5 forks source link

Can we avoid being rate-limited by github? #102

Closed jcrossley3 closed 22 hours ago

jcrossley3 commented 2 days ago

We make heavy use of this project in our unit tests, and if we run them often enough, we'll see lots of failures due to being rate-limited by github, specifically this request:

Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=2&per_page=100)))

We create a new db for each test, and they all seem to fail getting that list of releases. I know there is mention in the README of setting a github token to mitigate the chance of rate-limiting, but I'd prefer to avoid it altogether. Is there any configuration option I can use to do that? I've already tried setting a specific version (16.3.0), but it still seems to execute the above request.

Thanks!

brianheineman commented 2 days ago

There was a change starting in 0.13.0 with the way PostgreSQL versions are handled. Previously, if you were specifying "16.3.0" this would be treated as an exact match; the logic would check to see if that version is already installed and skip making requests to GitHub. Starting with version 0.13.0, you would need to specify the string "=16.3.0" to indicate an exact match to trigger the optimization that skips the GitHub requests.

If your code does something like this and is caching the ~/.theseus directory between runs, I would not expect any requests to GitHub:

    let settings = Settings {
        version: VersionReq::parse("=16.3.0")?,
        ..Default::default()
    };
    let mut postgresql = PostgreSQL::new(settings);

Alternatively, starting with 0.13.0, there is a zonky feature which pulls the PostgreSQL binaries from Maven Central which may have different rate limits (though I believe your project ran into an issue with one of the dependencies for that). The postgresql_archive crate was also updated to allow users to define their own custom repositories and archives (in preparation for supporting installing extensions); so you could also define your own custom location for the binary that is used.

jcrossley3 commented 22 hours ago

Thanks, Brian! Works as described!