class Manager: MAPPING = {"git": GitBackend, "redis": RedisBackend, "ephemeral": EphemeralBackend} def __init__(self): self.backend = EphemeralBackend() def get_collection(self, name): col_dict = self.backend.get(name) return Collection( Storage(self.MAPPING[col_dict["storage"][0]](*col_dict["storage"][1:])), Logger(self.MAPPING[col_dict["logs"][0]](*col_dict["logs"][1:])), Snapshot(self.MAPPING[col_dict["snapshot"][0]](*col_dict["snapshot"][1:])), ) def create_collection(self, name, settings): self.backend.set(name, settings)
def __init__(self): self.backend = EphemeralBackend()