added support for tarantool in bigchain db

This commit is contained in:
liviu-lesan 2022-02-08 16:14:59 +02:00
parent f366aab1f2
commit 9ff47136c8
3 changed files with 55 additions and 2 deletions

View File

@ -0,0 +1,23 @@
import tarantool
import os
from planetmint.backend.tarantool.utils import run
class TarantoolDB:
def __init__(self , host , port , username , password):
self.conn = tarantool.connect(host=host , port=port , user = username , password=password)
def connect_to_sapce(self,spacename):
self.conn.space(spacename)
def init_tarantool():
path = os.getcwd()
run(["mkdir" , "tarantool"])
run(["ln","-s",path +"/init.lua","init.lua"] , path+"/tarantool")
run (["tarantool" , "init.lua"] ,path+ "/tarantool")
def drop_tarantool():
#TODO drop tarantool
pass

View File

@ -0,0 +1,26 @@
import os
import subprocess
def run(command , path=None):
if path is not None:
os.chdir(path)
p=subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output , error = p.communicate()
if p.returncode != 0:
print(p.returncode + "\n" + output + "\n" +error)
else:
p=subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output , error = p.communicate()
if p.returncode != 0:
print(p.returncode + "\n" + output + "\n" +error)

View File

@ -13,6 +13,7 @@ import argparse
import copy import copy
import json import json
import sys import sys
from planetmint.backend.tarantool.database import TarantoolDB, init_tarantool
from planetmint.core import rollback from planetmint.core import rollback
from planetmint.migrations.chain_migration_election import ChainMigrationElection from planetmint.migrations.chain_migration_election import ChainMigrationElection
@ -25,6 +26,7 @@ import planetmint
from planetmint import (backend, ValidatorElection, from planetmint import (backend, ValidatorElection,
Planetmint) Planetmint)
from planetmint.backend import schema from planetmint.backend import schema
from planetmint.backend.tarantool import tarantool
from planetmint.commands import utils from planetmint.commands import utils
from planetmint.commands.utils import (configure_planetmint, from planetmint.commands.utils import (configure_planetmint,
input_on_stderr) input_on_stderr)
@ -241,9 +243,11 @@ def run_election_show(args, planet):
def _run_init(): def _run_init():
bdb = planetmint.Planetmint() #bdb = planetmint.Planetmint()
schema.init_database(connection=bdb.connection) #schema.init_database(connection=bdb.connection)
init_tarantool()
@configure_planetmint @configure_planetmint