moonfire-nvr/db
Scott Lamb 1ce52e334c fix #64 (extraneous flushes)
Now each syncer has a binary heap of the times it plans to do a flush.
When one of those times arrives, it rechecks if there's something to do.
Seems more straightforward than rechecking each stream's first
uncommitted recording, especially with the logic to retry failed flushes
every minute.

Also improved the info! log for each flush to see the actual recordings
being flushed for better debuggability.

No new tests right now. :-( They're tricky to write. One problem is that
it's hard to get the timing right: a different flush has to happen
after Syncer::save's database operations and before Syncer::run calls
SimulatedClocks::recv_timeout with an empty channel[*], advancing the
time. I've thought of a few ways of doing this:

   * adding a new SyncerCommand to run something, but it's messy (have
     to add it from the mock of one of the actions done by the save),
     and Box<dyn FnOnce() + 'static> not working (see
     rust-lang/rust#28796) makes it especially annoying.

   * replacing SimulatedClocks with something more like MockClocks.
     Lots of boilerplate. Maybe I need to find a good general-purpose
     Rust mock library. (mockers sounds good but I want something that
     works on stable Rust.)

   * bypassing the Syncer::run loop, instead manually running iterations
     from the test.

Maybe the last way is the best for now. I'm likely to try it soon.

[*] actually, it's calling Receiver::recv_timeout directly;
Clocks::recv_timeout is dead code now? oops.
2019-01-04 13:47:44 -08:00
..
testdata initial split of database to a separate crate 2018-02-20 23:15:39 -08:00
upgrade lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
auth.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
Cargo.toml fix #64 (extraneous flushes) 2019-01-04 13:47:44 -08:00
check.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
coding.rs initial split of database to a separate crate 2018-02-20 23:15:39 -08:00
db.rs fix #64 (extraneous flushes) 2019-01-04 13:47:44 -08:00
dir.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
lib.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
raw.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
recording.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
schema.proto update design docs for new-schema branch changes 2018-03-24 20:51:30 -07:00
schema.rs upgrade a few deps 2018-08-24 22:06:14 -07:00
schema.sql preliminary web support for auth (#26) 2018-11-27 11:08:33 -08:00
testutil.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
writer.rs fix #64 (extraneous flushes) 2019-01-04 13:47:44 -08:00