This commit is contained in:
2026-02-23 19:18:12 +07:00
parent f8a92a45a0
commit 46fdf668c6
22 changed files with 260 additions and 141 deletions

View File

@@ -146,7 +146,22 @@ All three implementations (Julia, JavaScript, Python/Micropython) follow the sam
└─────────────────┘ └─────────────────┘
```
## Files
## smartsend Return Value
The `smartsend` function now returns a tuple containing both the envelope object and the JSON string representation:
```julia
env, msg_json_str = smartsend(...)
# env::msgEnvelope_v1 - The envelope object with all metadata and payloads
# msg_json_str::String - JSON string for publishing to NATS
```
**Options:**
- `is_publish::Bool = true` - When `true` (default), the message is automatically published to NATS. When `false`, the function returns the envelope and JSON string without publishing, allowing manual publishing via NATS request-reply pattern.
This enables two use cases:
1. **Programmatic envelope access**: Access envelope fields directly via the `env` object
2. **Direct JSON publishing**: Publish the JSON string directly using NATS request-reply pattern
### Julia Module: [`src/NATSBridge.jl`](../src/NATSBridge.jl)
@@ -345,7 +360,9 @@ df = DataFrame(
)
# Send via SmartSend - wrapped in a list (type is part of each tuple)
await SmartSend("analysis_results", [("table_data", df, "table")]);
env, msg_json_str = SmartSend("analysis_results", [("table_data", df, "table")])
# env: msgEnvelope_v1 object with all metadata and payloads
# msg_json_str: JSON string representation of the envelope for publishing
```
#### JavaScript (Receiver)