Skip to content

Commit

Permalink
Added entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoFHG committed Apr 26, 2020
1 parent 430e6f4 commit 4fd8d1f
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pylint = "*"
[packages]
flask = "*"
flask-restful = "*"
py4j = "*"
rpyc = "*"

[requires]
python_version = "3.8"
19 changes: 13 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
8 changes: 8 additions & 0 deletions file_indexer_api/common/connection_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from rpyc import connect

class ConnectionHandler(object):
connection = connect('localhost', 18861)
root = None

def get_handler(self):
return self.root
11 changes: 11 additions & 0 deletions file_indexer_api/common/connection_handler_factory.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions file_indexer_api/common/indexer_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from file_indexer_api.common.connection_handler import ConnectionHandler

class IndexerHandler(ConnectionHandler):
root = ConnectionHandler.root.index()
4 changes: 4 additions & 0 deletions file_indexer_api/common/searcher_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from file_indexer_api.common.connection_handler import ConnectionHandler

class SearcherHandler(ConnectionHandler):
root = ConnectionHandler.root.searcher()
8 changes: 8 additions & 0 deletions file_indexer_api/entities/indexer.py
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions file_indexer_api/entities/searcher.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4fd8d1f

Please sign in to comment.