diff --git a/docs/implementation.md b/docs/implementation.md index 304ad44..301d430 100644 --- a/docs/implementation.md +++ b/docs/implementation.md @@ -118,43 +118,35 @@ env = smartreceive(msg; fileserver_download_handler=_fetch_with_backoff, max_ret The Julia implementation follows the Claim-Check pattern: ```mermaid -flowchart TB - subgraph Sender["Julia Application (Sender)"] - App[App Code] - NATSBridge[NATSBridge] - NATS_Client[NATS.jl] - end - - subgraph Receiver["Julia Application (Receiver)"] - App_Recv[App Code] - NATSBridge_Recv[NATSBridge] - NATS_Client_Recv[NATS.jl] - end - - subgraph Infrastructure["Infrastructure"] - NATS[NATS Server
Message Broker] - FileServer[HTTP File Server
Upload/Download] - end - - App --> NATSBridge - NATSBridge --> NATS_Client - NATS_Client --> NATS +flowchart TD + A[SmartSend Function] --> B{Is payload size < 1MB?} + B -->|Yes | C[Direct Path
< 1MB] + B -->|No | D[Link Path
>= 1MB] - NATS --> NATS_Client_Recv - NATS_Client_Recv --> NATSBridge_Recv - NATSBridge_Recv --> App_Recv - - NATSBridge -.->|HTTP POST upload| FileServer - FileServer -.->|HTTP GET download| NATSBridge_Recv - - style App fill:#e8f5e9 - style App_Recv fill:#e8f5e9 - style NATSBridge fill:#c5e1a5 - style NATSBridge_Recv fill:#c5e1a5 - style NATS fill:#fff3e0 - style FileServer fill:#f3e5f5 + C --> C1[Serialize to Buffer] + C1 --> C2[Base64 encode] + C2 --> C3[Publish to NATS] + + D --> D1[Serialize to Buffer] + D1 --> D2[Upload to HTTP Server] + D2 --> D3[Publish to NATS with URL] + + style A fill:#e1f5ff,stroke:#0066cc,stroke-width:2px + style B fill:#fff4e1,stroke:#cc6600,stroke-width:2px + style C fill:#e8f5e9,stroke:#008000,stroke-width:2px + style D fill:#e8f5e9,stroke:#008000,stroke-width:2px + style C1 fill:#f5f5f5,stroke:#666,stroke-width:1px + style C2 fill:#f5f5f5,stroke:#666,stroke-width:1px + style C3 fill:#f5f5f5,stroke:#666,stroke-width:1px + style D1 fill:#f5f5f5,stroke:#666,stroke-width:1px + style D2 fill:#f5f5f5,stroke:#666,stroke-width:1px + style D3 fill:#f5f5f5,stroke:#666,stroke-width:1px ``` +**Claim-Check Pattern Overview:** +- **Direct Path** (< 1MB): Payload is serialized, Base64-encoded, and published directly to NATS +- **Link Path** (≥ 1MB): Payload is serialized, uploaded to an HTTP file server, and only the URL is published to NATS (claim-check pattern) + ## smartsend Return Value The `smartsend` function now returns a tuple containing both the envelope object and the JSON string representation: