1 # Copyright (c) 2019 AT&T Intellectual Property.
2 # Copyright (c) 2018-2019 Nokia.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 # This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 # platform project (RICP).
22 """Shared Data Layer (SDL) database backend module."""
24 from importlib import import_module
27 def get_backend_instance(configuration):
29 Select database backend solution and return and instance of it.
30 For now only Redis backend solution is supported.
32 backend_name = 'RedisBackend'
33 backend_module_name = 'redis'
35 package = __package__ or __name__
36 backend_module = import_module('.' + backend_module_name, package=package)
37 backend_class = getattr(backend_module, backend_name)
38 instance = backend_class(configuration)
42 def get_backend_lock_instance(ns, name, expiration, backend):
44 Select database backend lock solution and return and instance of it.
45 For now only Redis backend lock solution is supported.
47 backend_lock_name = 'RedisBackendLock'
48 backend_module_name = 'redis'
50 package = __package__ or __name__
51 backend_module = import_module('.' + backend_module_name, package=package)
52 backend_lock_class = getattr(backend_module, backend_lock_name)
53 instance = backend_lock_class(ns, name, expiration, backend)