mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-24 00:24:19 +01:00
Demote autopilot, backup, donations, drain, helpme, historian, paytest, probe, prometheus, rebalance, and summary to the archive
drain: fix drain msats drain: failing CI because of msats historian: add inotify to historian deps historian: update lockfile
This commit is contained in:
committed by
mergify[bot]
parent
009a0fbad8
commit
3754a9e0f8
@@ -1,33 +0,0 @@
|
||||
'''Create a backend instance based on URI scheme dispatch.'''
|
||||
from typing import Type
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from backend import Backend
|
||||
from socketbackend import SocketBackend
|
||||
from filebackend import FileBackend
|
||||
|
||||
|
||||
def resolve_backend_class(backend_url):
|
||||
|
||||
backend_map: Mapping[str, Type[Backend]] = {
|
||||
'file': FileBackend,
|
||||
'socket': SocketBackend,
|
||||
}
|
||||
p = urlparse(backend_url)
|
||||
backend_cl = backend_map.get(p.scheme, None)
|
||||
return backend_cl
|
||||
|
||||
|
||||
def get_backend(destination, create=False, require_init=False):
|
||||
backend_cl = resolve_backend_class(destination)
|
||||
if backend_cl is None:
|
||||
raise ValueError("No backend implementation found for {destination}".format(
|
||||
destination=destination,
|
||||
))
|
||||
backend = backend_cl(destination, create=create)
|
||||
initialized = backend.initialize()
|
||||
if require_init and not initialized:
|
||||
kill("Could not initialize the backup {}, please use 'backup-cli' to initialize the backup first.".format(destination))
|
||||
assert backend.version is not None
|
||||
assert backend.prev_version is not None
|
||||
return backend
|
||||
Reference in New Issue
Block a user