mermaid diagram

This commit is contained in:
2026-03-13 15:57:27 +07:00
parent 42fffb8a4f
commit e99fb09298

View File

@@ -572,92 +572,44 @@ function fileserver_download_handler(
### Sending Flow ### Sending Flow
``` ```mermaid
┌─────────────────────────────────────────────────────────────────┐ flowchart TD
│ 1. User calls smartsend(subject, data) │ A[User calls smartsend\(subject, data\)] --> B[Serialize payload according to payload_type]
└─────────────────────────────────────────────────────────────────┘ B --> C{Calculate serialized size}
C -->|Size < Threshold| D[Direct Transport: Encode as Base64]
C -->|Size >= Threshold| E[Link Transport: Upload to file server]
┌─────────────────────────────────────────────────────────────────┐ D --> F[Build envelope with metadata]
│ 2. For each payload: │ E --> F
- Serialize data according to payload_type │ F --> G[Convert envelope to JSON string]
- Calculate serialized size │ G --> H[Publish to NATS subject]
└─────────────────────────────────────────────────────────────────┘ H --> I[Return envelope and JSON string to caller]
├─ Size < Threshold ────────────────►┐ style A fill:#f9f9f9,stroke:#333
│ │ style I fill:#e0e7ff,stroke:#3b82f6
▼ ▼ style D fill:#d1fae5,stroke:#10b981
┌─────────────────────────────────────────────────────────────────┐ │ style E fill:#fef3c7,stroke:#f59e0b
│ 3. Direct Transport: │ │
│ - Encode as Base64 │ │
│ - Include in payload.data │ │
└─────────────────────────────────────────────────────────────────┘ │
│ │
▼ │
┌─────────────────────────────────────────────────────────────────┐ │
│ 4. Build envelope with metadata │ │
│ - correlation_id, msg_id, timestamp │ │
│ - sender/receiver info │ │
│ - payloads array │ │
└─────────────────────────────────────────────────────────────────┘ │
│ │
▼ │
┌─────────────────────────────────────────────────────────────────┐ │
│ 5. Convert envelope to JSON string │ │
│ 6. Publish to NATS subject │ │
└─────────────────────────────────────────────────────────────────┘ │
┌─────────────────────────────────────────────────────────────────┐ │
│ 7. Return envelope and JSON string to caller │ │
└─────────────────────────────────────────────────────────────────┘ │
``` ```
### Receiving Flow ### Receiving Flow
``` ```mermaid
┌─────────────────────────────────────────────────────────────────┐ flowchart TD
│ 1. NATS message arrives A[NATS message arrives] --> B[Parse JSON envelope]
└─────────────────────────────────────────────────────────────────┘ B --> C[For each payload: Check transport type]
C -->|transport == direct| D[Direct Transport: Extract Base64]
C -->|transport == link| E[Link Transport: Fetch from URL]
┌─────────────────────────────────────────────────────────────────┐ D --> F[Decode Base64]
│ 2. Parse JSON envelope │ E --> G[Fetch with exponential backoff]
└─────────────────────────────────────────────────────────────────┘ F --> H[Deserialize based on payload_type]
G --> H
H --> I[Build payloads array]
┌─────────────────────────────────────────────────────────────────┐ I --> J[Replace payloads array with deserialized tuples]
│ 3. For each payload: │ J --> K[Return envelope with processed payloads]
- Check transport type │
└─────────────────────────────────────────────────────────────────┘ style A fill:#f9f9f9,stroke:#333
style K fill:#e0e7ff,stroke:#3b82f6
├─ transport == "direct" ──────────►┐ style D fill:#d1fae5,stroke:#10b981
│ │ style E fill:#fef3c7,stroke:#f59e0b
▼ ▼
┌─────────────────────────────────────────────────────────────────┐ │
│ 4. Direct Transport: │ │
│ - Extract Base64 data │ │
│ - Decode Base64 │ │
│ - Deserialize based on payload_type │ │
└─────────────────────────────────────────────────────────────────┘ │
│ │
▼ │
┌─────────────────────────────────────────────────────────────────┐ │
│ 5. Link Transport: │ │
│ - Extract URL from data │ │
│ - Fetch with exponential backoff │ │
│ - Deserialize based on payload_type │ │
└─────────────────────────────────────────────────────────────────┘ │
│ │
▼ │
┌─────────────────────────────────────────────────────────────────┐ │
│ 6. Replace payloads array with deserialized tuples │ │
│ - [(dataname, data, type), ...] │ │
└─────────────────────────────────────────────────────────────────┘ │
┌─────────────────────────────────────────────────────────────────┐
│ 7. Return envelope with processed payloads │
└─────────────────────────────────────────────────────────────────┘
``` ```
--- ---