-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinjector.py
48 lines (37 loc) · 1.33 KB
/
injector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from config.log_config import create_log
from config import config
from elasticsearch import Elasticsearch
from dotenv import load_dotenv
# import yaml
import json
import os
from service.es_search_handler import (
SearchAPIHandler,
SearchOmniHandler
)
from service.query_builder import QueryBuilder
# def read_config_yaml():
# with open('./config.yaml', 'r') as f:
# doc = yaml.load(f, Loader=yaml.FullLoader)
# logger.info(json.dumps(doc, indent=2))
# return doc
#--
# read host file to make an enum
def read_hosts(server_file):
server_list_dict = {}
with open(server_file) as data_file:
for line in data_file:
line = line.strip().split(",")
# print(f"{line}")
server_list_dict.update({line[0] : str(line[1]).lower()})
return server_list_dict
load_dotenv()
# Initialize & Inject with only one instance
logger = create_log()
hosts = read_hosts("./repository/hosts")
''' hosts = ['localhost', 'dev',...] '''
# logger.info(list(hosts.keys()))
es_hosts_enum_list =list(hosts.keys())
SearchAPIHandlerInject = SearchAPIHandler(logger, hosts)
SearchOmniHandlerInject = SearchOmniHandler(logger, hosts)
QueryBuilderInject = QueryBuilder(logger)