aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2021-06-13Update TODOTeddy Wing
2021-06-13run(): Remove limit to two repositories used for testingTeddy Wing
I artificially limited the number of repositories processed to two for testing so that I wouldn't download an mirror all of my repositories while testing the program. Now that things seem to be working, remove this artificial limit.
2021-06-13main: Add context to GitHub fetch errorTeddy Wing
2021-06-13run(): Don't clone `base_cgitrc` into each threadTeddy Wing
Rejigger some types and signatures to allow us to get references to the `base_cgitrc` path instead of copying it for each repository.
2021-06-13MultiError: Remove impl `Iterator` testsTeddy Wing
Remove the `Iterator` test implementations that didn't work out.
2021-06-13main(): Print "error: " in front of each error lineTeddy Wing
Prefix each error line with the text "error: " to make it clear that's what it is, and that it's separate from errors printed on other lines. Worked out how to set up an `Iterator` for `MultiError` based on a comment by 'chris-morgan' (https://old.reddit.com/user/chris-morgan) on Reddit /r/rust: > 1. Implement your own iterator type which wraps existing iterator > types (std::slice::Iter, and std::vec::IntoIter if you want a > consuming iterator). > Advantages: most flexible, ensures API stability if you > need to change internal details. > Disadvantages: a lot more effort, if you want to do it properly > (which involves implementing about ten traits on your iterator > wrapper type); and if slices or their iterators add something new, > you don’t get it unless you implement a wrapper yourself. > > 2. Have your iter() functions and IntoIterator implementations use the > standard iterator types directly. > Advantages: easier, gets you all the other trait implementations on > std::slice::Iter for free—AsRef, Clone, FusedIterator, > ExactSizeIterator, Debug, Send, DoubleEndedIterator, TrustedLen, > Sync). > Disadvantages: if you need to restructure things so that this is no > longer an option (e.g. store things in a different type of vector > and thus need to map it before presenting it to the user) it’s a > breaking change. > > 3. Implement Deref<Target = [(K, V)]> and just treat your Bucket<K, V> > as a &[(K, V)]. (Read-only; implement DerefMut if you want to allow > mutations of values.) > Advantages: easy, and lets you simply treat the whole thing as a > slice (this is what Vec<T> does). > Disadvantages: there really aren’t any, if it matches your purpose. > (If not, it’s useless.) (https://old.reddit.com/r/rust/comments/7a0slp/questionimplementing_iterator_for_a_struct_with_a/)
2021-06-13main: Remove unused `std::sync` importsTeddy Wing
2021-06-13MultiError: Add struct documentationTeddy Wing
2021-06-13Move `MultiError` to its own fileTeddy Wing
2021-06-13MultiError: Remove old `errors` fieldTeddy Wing
Decided to use 'anyhow' errors instead of a generic boxed error.
2021-06-13run(): Prefix repository errors with the name of the repositoryTeddy Wing
So you know what the error referred to.
2021-06-13run(): Add a note to include the repo name in repo errorsTeddy Wing
2021-06-13run(): Adjust whitespaceTeddy Wing
Make all chained methods indented.
2021-06-13run(): Return multiple errorsTeddy Wing
Return all errors from repo processing. This allows us to provide information on all errors that happened while processing, but continue processing all the repos even if there's an error in one of them. A new `MultiError` type wraps a list of errors to do this.
2021-06-13main: Remove unused `r2d2_sqlite::SqliteConnectionManager` importTeddy Wing
Not sure when or why I added this.
2021-06-12main: Remove commented multithreading test codeTeddy Wing
Remove my old tests now that we have a multi-threading setup that actually works.
2021-06-12Process repositories on multiple threadsTeddy Wing
Use 'rayon' to parallelise the repository processing. Each repository is processed in a thread in the default 'rayon' pool. In order to get thread-safe access to the database, I followed some advice from a Stack Overflow answer by VasiliNovikov (https://stackoverflow.com/users/1091436/vasilinovikov): https://stackoverflow.com/questions/62560396/how-to-use-sqlite-via-rusqlite-from-multiple-threads/62560397#62560397 VasiliNovikov recommended creating a database connection pool using 'r2d2_sqlite'. This way we don't have to share a database connection between threads, but each thread can have its own connection. This also means we can remove mutable requirements in a bunch of places involving our `database::Db` type since we're no longer managing the database connections directly.
2021-06-12Switch from 'reqwest' to 'ureq'; Remove asyncTeddy Wing
Remove all async from the project by switching from 'reqwest' to 'ureq'. This should make the code simpler, and hopefully enable us to try out multithreading.
2021-06-12Db::connect(): Fix database open callTeddy Wing
Turns out I need to specify all the flag I want in the open call, including the one to open the database for reading and writing. This fixes the "Error code 21: Library used incorrectly" error I was getting earlier.
2021-06-12run(): Add context to database errorsTeddy Wing
To allow us to work out where the error is coming from.
2021-06-12main: try! error from `process_repo`Teddy Wing
2021-06-12main: Remove async database callsTeddy Wing
Remove all the async database calls and Tokio spawning. Still haven't worked out the error code 21 database error from earlier, but this will hopefully allow us to use normal threads directly.
2021-06-11Replace 'sqlx' with 'rusqlite'Teddy Wing
Trying to get rid of async. This compiles, but fails with the following runtime error: Error code 21: Library used incorrectly Need to investigate further.
2021-06-11Try moving things around for multi-threadingTeddy Wing
Still isn't multi-threaded. Not sure what I'm doing wrong.
2021-06-07Add usage example in READMETeddy Wing
2021-06-07Update TODOTeddy Wing
2021-06-07Add license (GNU GPLv3+)Teddy Wing
2021-06-07Delete src/repo.rsTeddy Wing
Looks like I didn't delete the file in 67d7632b900f7221c1a3fb1927cd97b7cb60c71e.
2021-06-07main: Limit to 5 repos for thread debuggingTeddy Wing
2021-06-07main: Not multi-threadedTeddy Wing
Looks like the work doesn't happen on multiple threads. All of the tasks printed the same thread ID. Need to do some more work to get this working properly, it seems.
2021-06-07main: Collect errors from spawned tasksTeddy Wing
Collect all errors into a list. I think I'm going to return them as a list from this function. The runtime appears a lot slower with this change. Need to figure out what that's about.
2021-06-07Switch `futures::executor` to Tokio runtimeTeddy Wing
Use the Tokio runtime we created to run the blocking async tasks. Trying to set this up so I can get results back from the spawned tasks, but I'm currently having trouble working out how to extract them from the async task and return them from `run()`. I suppose I could just print out the errors directly in that `while let` loop, but ideally I'd like to return all errors from `run()` rather than printing in `run()`.
2021-06-06Split database mutex lock and create calls onto multiple linesTeddy Wing
To separate the actions more.
2021-06-06main: Add a comment about the repo size flag parse error handlingTeddy Wing
2021-06-06main::run(): Get repositories from GitHub API callTeddy Wing
Remove the hard-coded test repositories I was using and replace them with real ones retrieved from the GitHub API. Enable I/O and timers on the Tokio runtime in order to enable the async GitHub API request.
2021-06-06main: Remove `unwrap` when parsing `--skip-larger-than`Teddy Wing
Don't panic here so we can use our own error message template.
2021-06-06main(): Remove `unwrap`Teddy Wing
Print the error instead of unwrapping.
2021-06-06main: Add function documentationTeddy Wing
2021-06-06github::Repo: Remove TODOTeddy Wing
Don't see any reason to do this now.
2021-06-06database: Add documentation headersTeddy Wing
2021-06-06Update TODOTeddy Wing
2021-06-06Provide an option to skip repos larger than a given sizeTeddy Wing
Allows a maximum repo size to be given as a command line argument. Repos larger than this will not be mirrored. This gives us a way to save server space by avoiding gigantic repositories.
2021-06-06Remove old in-progress threading codeTeddy Wing
Remove this now that we have something that I think works.
2021-06-06Explicitly use tokio's multi-threaded runtimeTeddy Wing
Rather that relying on the Cargo features we've enabled to define this, create a multi-threaded runtime in code.
2021-06-06Make repo mirroring multi-threadedTeddy Wing
I think, at least. Took a lot of research and trial and error to get this to compile, working out how to set up the multi-threading for async code. The idea here is to be able to process each repo in potentially multiple threads and do that processing work in parallel.
2021-06-06Update TODOTeddy Wing
2021-06-06Update TODOTeddy Wing
2021-06-05run(): Move commentTeddy Wing
2021-06-05run(): Remove `unwrap`sTeddy Wing
2021-06-05main(): Remove commented test codeTeddy Wing
This is no longer relevant.