rename to smartpack n smartunpack
This commit is contained in:
@@ -263,7 +263,7 @@ def _publish(subject, message, correlation_id):
|
||||
# Placeholder - actual implementation would publish via preferred transport
|
||||
|
||||
|
||||
def smartsend(subject, data, **kwargs):
|
||||
def smartpack(subject, data, **kwargs):
|
||||
"""
|
||||
Send data with automatic transport selection.
|
||||
|
||||
@@ -306,7 +306,7 @@ def smartsend(subject, data, **kwargs):
|
||||
|
||||
Example:
|
||||
>>> # Send text payload
|
||||
>>> env, env_json_str = smartsend(
|
||||
>>> env, env_json_str = smartpack(
|
||||
... "/chat",
|
||||
... [("message", "Hello!", "text")]
|
||||
... )
|
||||
@@ -330,7 +330,7 @@ def smartsend(subject, data, **kwargs):
|
||||
is_publish = kwargs.get('is_publish', True)
|
||||
fileserver_upload_handler = kwargs.get('fileserver_upload_handler', _sync_fileserver_upload)
|
||||
|
||||
log_trace(correlation_id, f"Starting smartsend for subject: {subject}")
|
||||
log_trace(correlation_id, f"Starting smartpack for subject: {subject}")
|
||||
|
||||
# Process payloads
|
||||
payloads = []
|
||||
@@ -390,7 +390,7 @@ def smartsend(subject, data, **kwargs):
|
||||
return env, env_json_str
|
||||
|
||||
|
||||
def smartreceive(msg, **kwargs):
|
||||
def smartunpack(msg, **kwargs):
|
||||
"""
|
||||
Receive and process messages.
|
||||
|
||||
@@ -414,10 +414,10 @@ def smartreceive(msg, **kwargs):
|
||||
|
||||
Example:
|
||||
>>> # Receive from JSON string
|
||||
>>> env = smartreceive(json_string)
|
||||
>>> env = smartunpack(json_string)
|
||||
>>>
|
||||
>>> # Receive from transport message object
|
||||
>>> env = smartreceive(transport_msg, fileserver_download_handler=_sync_fileserver_download)
|
||||
>>> env = smartunpack(transport_msg, fileserver_download_handler=_sync_fileserver_download)
|
||||
>>> # env is a Dict with "payloads" key containing List[Tuple[str, Any, str]]
|
||||
>>> for dataname, data, type_ in env["payloads"]:
|
||||
... print(f"{dataname}: {data} (type: {type_})")
|
||||
@@ -530,34 +530,34 @@ class msghandler:
|
||||
self.broker_url = broker_url or self.DEFAULT_BROKER_URL
|
||||
self.fileserver_url = fileserver_url or self.DEFAULT_FILESERVER_URL
|
||||
|
||||
def smartsend(self, subject, data, **kwargs):
|
||||
def smartpack(self, subject, data, **kwargs):
|
||||
"""
|
||||
Send data.
|
||||
|
||||
Args:
|
||||
subject: Subject/topic to send to
|
||||
data: List of (dataname, data, type) tuples
|
||||
**kwargs: Additional options passed to smartsend
|
||||
**kwargs: Additional options passed to smartpack
|
||||
|
||||
Returns:
|
||||
Tuple of (env, env_json_str)
|
||||
"""
|
||||
kwargs['broker_url'] = kwargs.get('broker_url', self.broker_url)
|
||||
kwargs['fileserver_url'] = kwargs.get('fileserver_url', self.fileserver_url)
|
||||
return smartsend(subject, data, **kwargs)
|
||||
return smartpack(subject, data, **kwargs)
|
||||
|
||||
def smartreceive(self, msg, **kwargs):
|
||||
def smartunpack(self, msg, **kwargs):
|
||||
"""
|
||||
Receive and process message.
|
||||
|
||||
Args:
|
||||
msg: Message to process
|
||||
**kwargs: Additional options passed to smartreceive
|
||||
**kwargs: Additional options passed to smartunpack
|
||||
|
||||
Returns:
|
||||
Dict with envelope metadata and payloads
|
||||
"""
|
||||
return smartreceive(msg, **kwargs)
|
||||
return smartunpack(msg, **kwargs)
|
||||
|
||||
|
||||
# Convenience functions for module-level usage
|
||||
@@ -573,7 +573,7 @@ def send(subject, data, **kwargs):
|
||||
Returns:
|
||||
Tuple of (env, env_json_str)
|
||||
"""
|
||||
return smartsend(subject, data, **kwargs)
|
||||
return smartpack(subject, data, **kwargs)
|
||||
|
||||
|
||||
def receive(msg, **kwargs):
|
||||
@@ -587,12 +587,12 @@ def receive(msg, **kwargs):
|
||||
Returns:
|
||||
Dict with envelope metadata and payloads
|
||||
"""
|
||||
return smartreceive(msg, **kwargs)
|
||||
return smartunpack(msg, **kwargs)
|
||||
|
||||
|
||||
__all__ = [
|
||||
'smartsend',
|
||||
'smartreceive',
|
||||
'smartpack',
|
||||
'smartunpack',
|
||||
'msghandler',
|
||||
'send',
|
||||
'receive',
|
||||
|
||||
Reference in New Issue
Block a user