diff --git a/Pipfile b/Pipfile index b9b8a97..e02890a 100644 --- a/Pipfile +++ b/Pipfile @@ -9,7 +9,7 @@ pylint = "*" [packages] flask = "*" flask-restful = "*" -py4j = "*" +rpyc = "*" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 47acebc..e575b17 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "56e21e883b88bd518d06d6cecd8c75cf0d5c09f1b60cb50b82dc74de28167229" + "sha256": "de1680d698e61d8425df60c51a09aa4b3d02d29b3970dcc185dfb5e206b20bd8" }, "pipfile-spec": 6, "requires": { @@ -98,13 +98,12 @@ ], "version": "==1.1.1" }, - "py4j": { + "plumbum": { "hashes": [ - "sha256:36ec57f43ff8ced260a18aa9a4e46c3500a730cac8860e259cbaa546c2b9db2f", - "sha256:859ba728a7bb43e9c2bf058832759fb97a598bb28cc12f34f5fc4abdec08ede6" + "sha256:16b9e19d96c80f2e9d051ef5f04927b834a6ac0ce5d2768eb8662b5cd53e43df", + "sha256:91418dcc66b58ab9d2e3b04b3d1e0d787dc45923154fb8b4a826bd9316dba0d6" ], - "index": "pypi", - "version": "==0.10.9" + "version": "==1.6.9" }, "pytz": { "hashes": [ @@ -113,6 +112,14 @@ ], "version": "==2019.3" }, + "rpyc": { + "hashes": [ + "sha256:397bb0d6f73fd20a2aa4f2aa89d2776ea76ba4a3da7c1ba40696d17288b1001b", + "sha256:6153e1b2746b3cd70c8bf40c5e3353cca21db01067332bdf511e587453e43b53" + ], + "index": "pypi", + "version": "==4.1.5" + }, "six": { "hashes": [ "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", diff --git a/file_indexer_api/common/__init__.py b/file_indexer_api/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/file_indexer_api/common/connection_handler.py b/file_indexer_api/common/connection_handler.py new file mode 100644 index 0000000..53a6573 --- /dev/null +++ b/file_indexer_api/common/connection_handler.py @@ -0,0 +1,8 @@ +from rpyc import connect + +class ConnectionHandler(object): + connection = connect('localhost', 18861) + root = None + + def get_handler(self): + return self.root diff --git a/file_indexer_api/common/connection_handler_factory.py b/file_indexer_api/common/connection_handler_factory.py new file mode 100644 index 0000000..fd71b43 --- /dev/null +++ b/file_indexer_api/common/connection_handler_factory.py @@ -0,0 +1,11 @@ +from file_indexer_api.common.connection_handler import ConnectionHandler +from file_indexer_api.common.indexer_handler import IndexerHandler +from file_indexer_api.common.searcher_handler import SearcherHandler + +class ConnectionHandlerFactory(): + @staticmethod + def create_connection_handler(type): + if type == 'indexer': + return IndexerHandler + if type == 'searcher': + return SearcherHandler diff --git a/file_indexer_api/common/indexer_handler.py b/file_indexer_api/common/indexer_handler.py new file mode 100644 index 0000000..8b71413 --- /dev/null +++ b/file_indexer_api/common/indexer_handler.py @@ -0,0 +1,4 @@ +from file_indexer_api.common.connection_handler import ConnectionHandler + +class IndexerHandler(ConnectionHandler): + root = ConnectionHandler.root.index() diff --git a/file_indexer_api/common/searcher_handler.py b/file_indexer_api/common/searcher_handler.py new file mode 100644 index 0000000..dd3c6fa --- /dev/null +++ b/file_indexer_api/common/searcher_handler.py @@ -0,0 +1,4 @@ +from file_indexer_api.common.connection_handler import ConnectionHandler + +class SearcherHandler(ConnectionHandler): + root = ConnectionHandler.root.searcher() diff --git a/file_indexer_api/entities/indexer.py b/file_indexer_api/entities/indexer.py index e69de29..bf64eea 100644 --- a/file_indexer_api/entities/indexer.py +++ b/file_indexer_api/entities/indexer.py @@ -0,0 +1,8 @@ +from file_indexer_api.common.connection_handler_factory import ConnectionHandlerFactory + +class Indexer(): + def __init__(self): + self.indexer = ConnectionHandlerFactory.create_connection_handler('indexer') + + def index(self, path): + self.indexer.get_handler(path) diff --git a/file_indexer_api/entities/searcher.py b/file_indexer_api/entities/searcher.py index e69de29..5cef427 100644 --- a/file_indexer_api/entities/searcher.py +++ b/file_indexer_api/entities/searcher.py @@ -0,0 +1,8 @@ +from file_indexer_api.common.connection_handler_factory import ConnectionHandlerFactory + +class Searcher(): + def __init__(self): + self.searcher = ConnectionHandlerFactory.create_connection_handler('indexer') + + def search(self, query): + self.searcher.get_handler(query)