Generic backend pool
pip install ramos
make install
import ramos
ramos.configure(pools={
'backend_type': [
'path.to.backend_a',
'path.to.backend_b',
]
})
Ramos can uses Django or Simple Settings to get backends configurations if set settings.POOL_OF_RAMOS:
POOL_OF_RAMOS = {
'backend_type': [
'path.to.backend_a',
'path.to.backend_b',
]
}
from ramos.mixins import ThreadSafeCreateMixin
class BackendA(ThreadSafeCreateMixin):
id = 'backend_a'
def say(self):
return 'A'
class BackendB(ThreadSafeCreateMixin):
id = 'backend_b'
def say(self):
return 'B'
from ramos.pool import BackendPool
class BackendTypePool(BackendPool)
backend_type = 'backend_type'
backends = BackendTypePool.all()
for backend in backends:
print(backend.say())
# backend_a = BackendTypePool.get('backend_a')
# backend_b = BackendTypePool.get('backend_b')