milvus/shards/mishards/__init__.py

43 lines
1.7 KiB
Python
Raw Normal View History

2019-10-21 16:21:32 +08:00
import logging
from mishards import settings
logger = logging.getLogger()
from mishards.db_base import DB
db = DB()
from mishards.server import Server
grpc_server = Server()
def create_app(testing_config=None):
config = testing_config if testing_config else settings.DefaultConfig
2019-11-18 17:25:38 +08:00
db.init_db(uri=config.SQLALCHEMY_DATABASE_URI, echo=config.SQL_ECHO, pool_size=config.SQL_POOL_SIZE,
pool_recycle=config.SQL_POOL_RECYCLE, pool_timeout=config.SQL_POOL_TIMEOUT,
pool_pre_ping=config.SQL_POOL_PRE_PING, max_overflow=config.SQL_MAX_OVERFLOW)
2019-10-21 16:21:32 +08:00
from mishards.connections import ConnectionMgr
connect_mgr = ConnectionMgr()
2019-10-26 16:27:16 +08:00
from discovery.factory import DiscoveryFactory
discover = DiscoveryFactory(config.DISCOVERY_PLUGIN_PATH).create(config.DISCOVERY_CLASS_NAME,
conn_mgr=connect_mgr)
2019-10-21 16:21:32 +08:00
from mishards.grpc_utils import GrpcSpanDecorator
2019-10-25 20:24:03 +08:00
from tracer.factory import TracerFactory
2019-10-26 17:26:59 +08:00
tracer = TracerFactory(config.TRACER_PLUGIN_PATH).create(config.TRACER_CLASS_NAME,
2019-10-28 11:19:46 +08:00
plugin_config=settings.TracingConfig,
span_decorator=GrpcSpanDecorator())
2019-10-21 16:21:32 +08:00
2019-10-26 12:49:50 +08:00
from mishards.router.factory import RouterFactory
router = RouterFactory(config.ROUTER_PLUGIN_PATH).create(config.ROUTER_CLASS_NAME,
conn_mgr=connect_mgr)
2019-10-21 16:21:32 +08:00
2019-10-25 20:24:03 +08:00
grpc_server.init_app(conn_mgr=connect_mgr,
tracer=tracer,
router=router,
discover=discover)
2019-10-21 16:21:32 +08:00
from mishards import exception_handlers
return grpc_server