Page MenuHomeSoftware Heritage

Allow to use several backends with a RPCServerApp
ClosedPublic

Authored by vsellier on Tue, Apr 6, 4:09 PM.

Details

Summary

This is needed for the swh-counters module, one backend uses Redis to
manage the counters by themselves, and another one manages the history
files using prometheus.
Each one can possibly evolve separately or can use a different backend
implementation one day or another.

Related to T3165

Diff Detail

Repository
rDCORE Foundations and core functionalities
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 D5428 (id=19401)

Rebasing onto 246abfb9b3...

Current branch diff-target is up to date.
Changes applied before test
commit cbc9b86b2336ae70e9198fa03f588100418f5c6a
Author: Vincent SELLIER <vincent.sellier@softwareheritage.org>
Date:   Tue Apr 6 15:46:57 2021 +0200

    Allow to use several backends with a RPCServerApp
    
    This is needed for the swh-counters module, one backend uses Redis to
    manage the counters by themselves, and another one manages the history
    files using prometheus.
    Each one can possibly evolve separately or can use a different backend
    implementation one day or another.
    
    Related to T3165

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

Why not a single backend class for both?

Why not a single backend class for both?

because it's not the same backend implementation
so not the same concern/perimeter as mentioned in the diff description.

This revision is now accepted and ready to land.Tue, Apr 6, 4:49 PM

Why not a single backend class for both?

because it's not the same backend implementation
so not the same concern/perimeter as mentioned in the diff description.

Exactly, it will be specially useful if we decide to poc a second implementation for one perimeter, without impacting the other one.

Then what is the expected return type of swh.counters.get_counters, if backends have disjoint interfaces?

ah, found the diff def get_history(cls: str, **kwargs: Dict[str, Any]) -> HistoryInterface:

Hmm...

I don't like it, but ok