Skip to content

Commit

Permalink
Merge branch 'main' into support/3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuch committed Sep 20, 2023
2 parents 3e6ec9e + 953d60c commit 18bd666
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
5 changes: 5 additions & 0 deletions code/zato-common/src/zato/common/util/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ def visit_py_source(
' common*.py',
'*_common*.py',

' model_core*.py',
' model*.py',
'*_model*.py',

Expand All @@ -636,6 +637,10 @@ def visit_py_source(

' pri_*.py',
'*_pri.py',

' core_*.py',
' channel_*.py',
' adapter_*.py',
]

# For storing names of files that we have already deployed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,14 @@ def http_request(
data = data.encode('utf-8')

# Log what we are sending ..
msg = f'HTTP out; cid={cid} {method} {address} name:{self.config["name"]}; params={params}; len={len(data)}'
msg = f'HTTP outcid={cid}; {method} {address} name:{self.config["name"]}; params={params}; len={len(data)}'
logger.info(msg)

# .. do invoke the connection ..
response = self.invoke_http(cid, method, address, data, headers, {}, params=qs_params, *args, **kwargs)

# .. now, log what we received.
msg = f'HTTP out; cid={cid} {response.status_code} time={response.elapsed}; len={len(response.text)}'
msg = f'HTTP outcid={cid}; {response.status_code} time={response.elapsed}; len={len(response.text)}'
logger.info(msg)

# .. check if we are explicitly told that we handle JSON ..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ################################################################################################################################

if 0:

from zato.common.typing_ import any_, anylist, anylistnone, anyset, intlist, strbytes, strlist, strset
from zato.server.service.store import InRAMService
InRAMService = InRAMService

Expand All @@ -46,9 +46,9 @@

@dataclass(init=False)
class DeploymentCtx:
model_name_list: list
service_id_list: list
service_name_list: list
model_name_list: 'strlist'
service_id_list: 'intlist'
service_name_list: 'strlist'

# ################################################################################################################################
# ################################################################################################################################
Expand Down Expand Up @@ -151,20 +151,22 @@ def backup_current_work_dir(self):

# ################################################################################################################################

def _deploy_models(self, current_work_dir, file_name):
# type: (str, str) -> list
def _deploy_models(self, current_work_dir:'str', file_name:'str') -> 'strset':

# Reusable
from zato.server.service import store as service_store_mod

# Local aliases
model_class = None

# This returns names of all the model classes deployed from the file
model_name_list = set(self.server.service_store.import_models_from_file(file_name, False, current_work_dir))

# A set of Python objects, each representing a model class (rather than its name)
model_classes = set()
model_classes:'anyset' = set()

# All the modules to be reloaded due to changes to the data model
to_auto_deploy = set()
to_auto_deploy:'anyset' = set()

for item in gc.get_objects():

Expand All @@ -184,7 +186,7 @@ def _deploy_models(self, current_work_dir, file_name):
for ref in gc.get_referrers(model_class):

if isinstance(ref, dict):
mod_name = ref.get('__module__')
mod_name:'str' = ref.get('__module__') # type: ignore
if mod_name:

# Import the live Python module object ..
Expand All @@ -209,7 +211,7 @@ def _deploy_models(self, current_work_dir, file_name):
if to_auto_deploy:

# .. format lexicographically for logging ..
to_auto_deploy = sorted(to_auto_deploy)
to_auto_deploy = sorted(to_auto_deploy) # type: ignore

# .. nform users that we are to auto-redeploy services and why we are doing it ..
self.logger.info('Model class `%s` changed; auto-redeploying `%s`', model_class, to_auto_deploy)
Expand All @@ -222,13 +224,13 @@ def _deploy_models(self, current_work_dir, file_name):

# ################################################################################################################################

def _deploy_services(self, current_work_dir, file_name):
# type: (str, str) -> list
def _deploy_services(self, current_work_dir:'str', file_name:'str') -> 'intlist':

service_id_list = []
service:'InRAMService'
service_id_list:'intlist' = []
info = self.server.service_store.import_services_from_anywhere(file_name, current_work_dir)

for service in info.to_process: # type: InRAMService
for service in info.to_process: # type: ignore

service_id = self.server.service_store.impl_name_to_id[service.impl_name]
service_id_list.append(service_id)
Expand Down Expand Up @@ -266,7 +268,15 @@ def _deploy_file(self, current_work_dir, payload, file_name, should_deploy_in_pl

# ################################################################################################################################

def _deploy_package(self, session, package_id, payload_name, payload, should_deploy_in_place, in_place_dir_name):
def _deploy_package(
self,
session, # type: any_
package_id, # type: int
payload_name, # type: str
payload, # type: strbytes
should_deploy_in_place, # type: bool
in_place_dir_name # type: str
) -> 'anylistnone':
""" Deploy a package, either a plain Python file or an archive, and update
the deployment status.
"""
Expand All @@ -276,7 +286,7 @@ def _deploy_package(self, session, package_id, payload_name, payload, should_dep
if should_deploy_in_place:
work_dir = in_place_dir_name
else:
work_dir = self.server.hot_deploy_config.current_work_dir
work_dir:'str' = self.server.hot_deploy_config.current_work_dir

file_name = os.path.join(work_dir, payload_name)

Expand Down Expand Up @@ -309,8 +319,7 @@ def _deploy_package(self, session, package_id, payload_name, payload, should_dep

# ################################################################################################################################

def _report_deployment(self, file_name, items, noun):
# type: (str, list, str)
def _report_deployment(self, file_name:'str', items:'anylist', noun:'str') -> 'None':
msg = 'Deployed %s {}%sfrom `%s` -> %s'.format(noun)
len_items = len(items)
suffix = 's ' if len_items > 1 else ' '
Expand Down

0 comments on commit 18bd666

Please sign in to comment.