kopia lustrzana https://github.com/bugout-dev/moonstream
				
				
				
			Improvments.
							rodzic
							
								
									36a5be3fed
								
							
						
					
					
						commit
						bb1206829e
					
				| 
						 | 
				
			
			@ -7,6 +7,7 @@ from moonstreamdb.db import (
 | 
			
		|||
    MOONSTREAM_POOL_SIZE,
 | 
			
		||||
    create_moonstream_engine,
 | 
			
		||||
)
 | 
			
		||||
from moonstreamdbv3.db import MoonstreamCustomDBEngine
 | 
			
		||||
from sqlalchemy.orm import Session, sessionmaker
 | 
			
		||||
 | 
			
		||||
from .settings import (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -486,3 +486,7 @@ if MOONSTREAM_STATE_CRAWLER_JOURNAL_ID == "":
 | 
			
		|||
MOONSTREAM_DB_V3_CONTROLLER_API = os.environ.get(
 | 
			
		||||
    "MOONSTREAM_DB_V3_CONTROLLER_API", "https://mdb-v3-api.moonstream.to"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
MOONSTREAM_DB_V3_SCHEMA_NAME = os.environ.get(
 | 
			
		||||
    "MOONSTREAM_DB_V3_SCHEMA_NAME", "blockchain"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,15 +13,16 @@ from sqlalchemy.sql.expression import TextClause
 | 
			
		|||
 | 
			
		||||
from ..actions import push_data_to_bucket, get_customer_db_uri
 | 
			
		||||
from ..db import (
 | 
			
		||||
    create_moonstream_engine,
 | 
			
		||||
    MOONSTREAM_QUERY_API_DB_STATEMENT_TIMEOUT_MILLIS,
 | 
			
		||||
    RO_pre_ping_query_engine,
 | 
			
		||||
    MOONSTREAM_DB_URI_READ_ONLY,
 | 
			
		||||
    MoonstreamCustomDBEngine,
 | 
			
		||||
)
 | 
			
		||||
from ..reporter import reporter
 | 
			
		||||
from ..settings import (
 | 
			
		||||
    MOONSTREAM_S3_QUERIES_BUCKET_PREFIX,
 | 
			
		||||
    CRAWLER_LABEL,
 | 
			
		||||
    SEER_CRAWLER_LABEL,
 | 
			
		||||
    MOONSTREAM_DB_V3_SCHEMA_NAME,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
logging.basicConfig(level=logging.INFO)
 | 
			
		||||
| 
						 | 
				
			
			@ -85,18 +86,14 @@ def data_generate(
 | 
			
		|||
        db_uri = get_customer_db_uri(customer_id, instance_id, "customer")
 | 
			
		||||
        label = SEER_CRAWLER_LABEL
 | 
			
		||||
 | 
			
		||||
    if db_uri is None:
 | 
			
		||||
        logger.error("No DB URI provided")
 | 
			
		||||
        return
 | 
			
		||||
        engine = MoonstreamCustomDBEngine(
 | 
			
		||||
            url=db_uri, schema=MOONSTREAM_DB_V3_SCHEMA_NAME
 | 
			
		||||
        )
 | 
			
		||||
    else:
 | 
			
		||||
        engine = RO_pre_ping_query_engine
 | 
			
		||||
 | 
			
		||||
    data_engine = create_moonstream_engine(
 | 
			
		||||
        url=db_uri,
 | 
			
		||||
        pool_size=1,
 | 
			
		||||
        statement_timeout=MOONSTREAM_QUERY_API_DB_STATEMENT_TIMEOUT_MILLIS,
 | 
			
		||||
        pool_pre_ping=True,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    db_session = sessionmaker(bind=data_engine)()
 | 
			
		||||
    process_session = sessionmaker(bind=engine)
 | 
			
		||||
    db_session = process_session()
 | 
			
		||||
 | 
			
		||||
    metadata = {
 | 
			
		||||
        "source": "drone-query-generation",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -484,9 +484,7 @@ async def update_query_data_handler(
 | 
			
		|||
        json_payload["query"] = content
 | 
			
		||||
        json_payload["params"] = request_update.params
 | 
			
		||||
        json_payload["file_type"] = file_type
 | 
			
		||||
        json_payload["blockchain"] = (
 | 
			
		||||
            request_update.blockchain if request_update.blockchain else None
 | 
			
		||||
        )
 | 
			
		||||
        json_payload["blockchain"] = request_update.blockchain
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            responce = requests.post(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue