milvus/shards/discovery/factory.py

23 lines
754 B
Python
Raw Normal View History

2019-10-26 16:27:16 +08:00
import logging
from discovery import DiscoveryConfig
2019-10-26 16:54:31 +08:00
from utils.plugins import BaseMixin
2019-10-26 16:27:16 +08:00
logger = logging.getLogger(__name__)
PLUGIN_PACKAGE_NAME = 'discovery.plugins'
2019-10-26 16:54:31 +08:00
class DiscoveryFactory(BaseMixin):
2019-10-26 16:27:16 +08:00
PLUGIN_TYPE = 'Discovery'
2019-10-26 17:19:57 +08:00
2019-10-26 16:27:16 +08:00
def __init__(self, searchpath=None):
2019-10-26 16:54:31 +08:00
super().__init__(searchpath=searchpath, package_name=PLUGIN_PACKAGE_NAME)
2019-10-26 16:27:16 +08:00
2019-10-26 16:54:31 +08:00
def _create(self, plugin_class, **kwargs):
[skip ci] (shards) Upgrade Mishards for #1569 (#1570) * [skip ci](shards): export MAX_WORKERS as configurable parameter Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): skip mishards .env git info Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): support more robust static discovery host configuration Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): update static provider that terminate server if connection to downstream server error during startup Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add topology.py Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add connection pool Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add topology test Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): refactory using topo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): refactory static discovery using topo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): refactory kubernetes discovery using topo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add more test for connection pool Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): export 19541 and 19542 for all_in_one demo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): check version on new connection Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): mock connections Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): update tests Signed-off-by: peng.xu <peng.xu@zilliz.com>
2020-03-14 13:30:21 +08:00
readonly_topo = kwargs.pop('readonly_topo', None)
if not readonly_topo:
raise RuntimeError('Please pass readonly_topo to create discovery!')
2019-10-26 16:27:16 +08:00
plugin_config = DiscoveryConfig.Create()
[skip ci] (shards) Upgrade Mishards for #1569 (#1570) * [skip ci](shards): export MAX_WORKERS as configurable parameter Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): skip mishards .env git info Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): support more robust static discovery host configuration Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): update static provider that terminate server if connection to downstream server error during startup Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add topology.py Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add connection pool Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add topology test Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): refactory using topo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): refactory static discovery using topo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): refactory kubernetes discovery using topo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): add more test for connection pool Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): export 19541 and 19542 for all_in_one demo Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): check version on new connection Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): mock connections Signed-off-by: peng.xu <peng.xu@zilliz.com> * [skip ci](shards): update tests Signed-off-by: peng.xu <peng.xu@zilliz.com>
2020-03-14 13:30:21 +08:00
plugin = plugin_class.Create(plugin_config=plugin_config, readonly_topo=readonly_topo, **kwargs)
2019-10-26 16:27:16 +08:00
return plugin