Page MenuHomeSoftware Heritage

Refactor the JournalWriter class to normalize its methods
ClosedPublic

Authored by douardda on May 11 2020, 4:27 PM.

Details

Summary

make all the add_xxx methods take an Iterable as argument. Also extract
the conditional execution of the underlying journal method calls in a
dedicated methof to prevent repeating the `if self.journal` all over the
place.

Ensure all the storage code that uses this JournalWriter class are updated
accordingly.

Also in this diff:

  • Improve a bit the exception message of JournalWriter.content_update
  • Add missing return annotations on JournalWriter methods

Depends on D3137.

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D3138 (id=11151)

Could not rebase; Attempt merge onto 4edf9e1454...

Updating 4edf9e1..306aa69
Fast-forward
 swh/storage/cassandra/storage.py |  8 ++---
 swh/storage/in_memory.py         |  8 ++---
 swh/storage/storage.py           |  8 ++---
 swh/storage/tests/test_replay.py | 16 +++++----
 swh/storage/writer.py            | 76 +++++++++++++++-------------------------
 5 files changed, 49 insertions(+), 67 deletions(-)
Changes applied before test
commit 306aa69b26d02f9f3c482b10cf522b88cd0a4f8f
Author: David Douard <david.douard@sdfa3.org>
Date:   Mon May 11 15:18:05 2020 +0200

    Add missing return annotations on JournalWriter methods

commit b04cb8f92c042bd76d0c7adfc490c8c93eca8ccd
Author: David Douard <david.douard@sdfa3.org>
Date:   Mon May 11 11:20:38 2020 +0200

    Improve a bit the exception message of JournalWriter.content_update

commit 46f9a7a15113d293be512f658f690e94d2658662
Author: David Douard <david.douard@sdfa3.org>
Date:   Mon May 11 11:17:05 2020 +0200

    Refactor the JournalWriter class to normalize its methods
    
    make all the add_xxx methods take an Iterable as argument. Also extract
    the conditional execution of the underlying journal method calls in a
    dedicated methof to prevent repeating the ``if self.journal`` all over the
    place.
    
    Ensure all the storage code that uses this JournalWriter class are updated
    accordingly.

commit e64944bc53c936419dfa523424b5c171c2d1425a
Author: David Douard <david.douard@sdfa3.org>
Date:   Mon May 11 16:15:51 2020 +0200

    tests: fix test_replay; do only use aware datetime objects
    
    naive dates being now properly forbidden.

See https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/166/ for more details.

This revision is now accepted and ready to land.May 11 2020, 5:16 PM