Changed config keys
This commit is contained in:
parent
83416678a3
commit
0dedcd867d
6
.config
6
.config
@ -2,10 +2,8 @@ dblayer: riak
|
|||||||
redis:
|
redis:
|
||||||
host: localhost
|
host: localhost
|
||||||
port: '6379'
|
port: '6379'
|
||||||
riak:
|
solar_db:
|
||||||
|
mode: riak
|
||||||
host: localhost
|
host: localhost
|
||||||
port: '8087'
|
port: '8087'
|
||||||
protocol: pbc
|
protocol: pbc
|
||||||
sqlite:
|
|
||||||
backend: memory
|
|
||||||
location: ':memory:'
|
|
||||||
|
@ -6,8 +6,7 @@ CWD = os.getcwd()
|
|||||||
|
|
||||||
C = Bunch()
|
C = Bunch()
|
||||||
C.redis = Bunch(port='6379', host='10.0.0.2')
|
C.redis = Bunch(port='6379', host='10.0.0.2')
|
||||||
C.riak = Bunch(port='8087', host='10.0.0.2', protocol='pbc')
|
C.solar_db = Bunch(mode='riak', port='8087', host='10.0.0.2', protocol='pbc')
|
||||||
C.sqlite = Bunch(backend='memory', location=':memory:')
|
|
||||||
C.dblayer = 'riak'
|
C.dblayer = 'riak'
|
||||||
|
|
||||||
|
|
||||||
@ -52,6 +51,7 @@ def from_configs():
|
|||||||
config[path[-1]] = vals
|
config[path[-1]] = vals
|
||||||
_lookup_vals(_setter, C)
|
_lookup_vals(_setter, C)
|
||||||
|
|
||||||
|
|
||||||
def from_env():
|
def from_env():
|
||||||
def _setter(config, path):
|
def _setter(config, path):
|
||||||
env_key = '_'.join(path).upper()
|
env_key = '_'.join(path).upper()
|
||||||
|
@ -2,27 +2,28 @@ from solar.dblayer.model import ModelMeta
|
|||||||
from solar.dblayer.riak_client import RiakClient
|
from solar.dblayer.riak_client import RiakClient
|
||||||
from solar.config import C
|
from solar.config import C
|
||||||
|
|
||||||
if C.dblayer == 'sqlite':
|
|
||||||
|
if C.solar_db.mode == 'sqlite':
|
||||||
from solar.dblayer.sql_client import SqlClient
|
from solar.dblayer.sql_client import SqlClient
|
||||||
if C.sqlite.backend == 'memory':
|
if C.solar_db.backend == 'memory':
|
||||||
client = SqlClient(C.sqlite.location, threadlocals=False, autocommit=False)
|
client = SqlClient(C.solar_db.location, threadlocals=False, autocommit=False)
|
||||||
elif C.sqlite.backend == 'file':
|
elif C.solar_db.backend == 'file':
|
||||||
client = SqlClient(C.sqlite.location, threadlocals=True,
|
client = SqlClient(C.solar_db.location, threadlocals=True,
|
||||||
autocommit=False, pragmas=(('journal_mode', 'WAL'),
|
autocommit=False, pragmas=(('journal_mode', 'WAL'),
|
||||||
('synchronous', 'NORMAL')))
|
('synchronous', 'NORMAL')))
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown sqlite backend %s', C.sqlite.backend)
|
raise Exception('Unknown sqlite backend %s', C.solar_db.backend)
|
||||||
|
|
||||||
elif C.dblayer == 'riak':
|
elif C.solar_db.mode == 'riak':
|
||||||
from solar.dblayer.riak_client import RiakClient
|
from solar.dblayer.riak_client import RiakClient
|
||||||
if C.riak.protocol == 'pbc':
|
if C.solar_db.protocol == 'pbc':
|
||||||
client = RiakClient(
|
client = RiakClient(
|
||||||
protocol=C.riak.protocol, host=C.riak.host, pb_port=C.riak.port)
|
protocol=C.solar_db.protocol, host=C.solar_db.host, pb_port=C.solar_db.port)
|
||||||
elif C.riak.protocol == 'http':
|
elif C.solar_db.protocol == 'http':
|
||||||
client = RiakClient(
|
client = RiakClient(
|
||||||
protocol=C.riak.protocol, host=C.riak.host, http_port=C.riak.port)
|
protocol=C.solar_db.protocol, host=C.solar_db.host, http_port=C.solar_db.port)
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown riak protocol %s', C.riak.protocol)
|
raise Exception('Unknown riak protocol %s', C.solar_db.protocol)
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown dblayer backend %s', C.dblayer)
|
raise Exception('Unknown dblayer backend %s', C.dblayer)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user