This commit is contained in:
2026-03-06 08:19:15 +07:00
parent 1b86a9252d
commit aa7cdbd36f
31 changed files with 89 additions and 89 deletions

View File

@@ -47,9 +47,9 @@ NATSBridge enables seamless communication across multiple platforms through NATS
| Platform | Implementation | Features |
|----------|----------------|----------|
| **Julia** | [`src/NATSBridge.jl`](src/NATSBridge.jl) | Full feature set, Arrow IPC, multiple dispatch |
| **JavaScript** | [`src/natbridge.js`](src/natbridge.js) | Node.js & browser, async/await |
| **Python** | [`src/natbridge.py`](src/natbridge.py) | Desktop Python, asyncio, type hints |
| **MicroPython** | [`src/natbridge_mpy.py`](src/natbridge_mpy.py) | Memory-constrained, synchronous API |
| **JavaScript** | [`src/natsbridge.js`](src/natsbridge.js) | Node.js & browser, async/await |
| **Python** | [`src/natsbridge.py`](src/natsbridge.py) | Desktop Python, asyncio, type hints |
| **MicroPython** | [`src/natsbridge_mpy.py`](src/natsbridge_mpy.py) | Memory-constrained, synchronous API |
### Platform Comparison
@@ -332,7 +332,7 @@ env, env_json_str = NATSBridge.smartsend(
#### JavaScript
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
const [env, env_json_str] = await NATSBridge.smartsend(
subject,
@@ -361,7 +361,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
env, env_json_str = await NATSBridge.smartsend(
subject: str,
@@ -388,7 +388,7 @@ env, env_json_str = await NATSBridge.smartsend(
#### MicroPython
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
# Limited to direct transport (< 100KB threshold)
env, env_json_str = NATSBridge.smartsend(
@@ -551,7 +551,7 @@ env, env_json_str = NATSBridge.smartsend("/chat/room1", data; fileserver_url="ht
#### JavaScript
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
const data = [
["message_text", "Hello!", "text"],
@@ -569,7 +569,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
data = [
("message_text", "Hello!", "text"),
@@ -606,7 +606,7 @@ env, env_json_str = NATSBridge.smartsend("/device/config", data)
#### JavaScript
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
const config = {
wifi_ssid: "MyNetwork",
@@ -623,7 +623,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
config = {
"wifi_ssid": "MyNetwork",
@@ -658,7 +658,7 @@ env, env_json_str = NATSBridge.smartsend("/data/analysis", data)
#### JavaScript
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
const df = [
{ id: 1, name: "Alice", score: 95 },
@@ -675,7 +675,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
import pandas as pd
df = pd.DataFrame({
@@ -735,7 +735,7 @@ end
#### JavaScript
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
// Requester
const [env, env_json_str] = await NATSBridge.smartsend(
@@ -748,7 +748,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
```javascript
// Responder
const nats = require('nats');
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
async function testResponder() {
const conn = await nats.connect('nats://localhost:4222');
@@ -782,7 +782,7 @@ async function testResponder() {
#### Python
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
# Requester
env, env_json_str = await NATSBridge.smartsend(
@@ -795,7 +795,7 @@ env, env_json_str = await NATSBridge.smartsend(
```python
# Responder
from natbridge import NATSBridge
from natsbridge import NATSBridge
import asyncio
import nats

View File

@@ -82,7 +82,7 @@ env = smartreceive(msg; fileserver_download_handler=_fetch_with_backoff)
**JavaScript:**
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
// Send
const [env, env_json_str] = await NATSBridge.smartsend(
@@ -104,7 +104,7 @@ const env = await NATSBridge.smartreceive(msg, {
**Python:**
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
# Send
env, env_json_str = NATSBridge.smartsend(
@@ -124,7 +124,7 @@ env = NATSBridge.smartreceive(
**MicroPython:**
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
# Send (limited to direct transport due to memory constraints)
env, env_json_str = NATSBridge.smartsend(

View File

@@ -16,9 +16,9 @@ This document describes the implementation of the high-performance, bi-direction
| Language | Implementation File | Description |
|----------|---------------------|-------------|
| **Julia** | [`src/NATSBridge.jl`](../src/NATSBridge.jl) | Full Julia implementation with Arrow IPC support |
| **JavaScript** | `src/natbridge.js` | Node.js/browser implementation |
| **Python** | `src/natbridge.py` | Desktop Python implementation |
| **MicroPython** | `src/natbridge_mpy.py` | MicroPython implementation (limited features) |
| **JavaScript** | `src/natsbridge.js` | Node.js/browser implementation |
| **Python** | `src/natsbridge.py` | Desktop Python implementation |
| **MicroPython** | `src/natsbridge_mpy.py` | MicroPython implementation (limited features) |
---
@@ -228,7 +228,7 @@ end
#### JavaScript
```javascript
const NATSBridge = require('natbridge');
const NATSBridge = require('natsbridge');
// Single payload
const [env, env_json_str] = await NATSBridge.smartsend(
@@ -275,7 +275,7 @@ for (const [dataname, data, type] of env.payloads) {
#### Python
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
# Single payload
env, env_json_str = await NATSBridge.smartsend(
@@ -317,7 +317,7 @@ for dataname, data, type_ in env["payloads"]:
#### MicroPython
```python
from natbridge import NATSBridge
from natsbridge import NATSBridge
# Limited to text and binary (no tables due to memory constraints)
env, env_json_str = NATSBridge.smartsend(
@@ -929,7 +929,7 @@ end
#### Module Structure
```javascript
// natbridge.js
// natsbridge.js
const nats = require('nats');
const { v4: uuidv4 } = require('uuid');
const fetch = require('node-fetch');
@@ -1272,7 +1272,7 @@ async function plikOneshotUpload(file_server_url, dataname, data) {
#### Module Structure
```python
# natbridge.py
# natsbridge.py
import asyncio
import base64
import json
@@ -1690,7 +1690,7 @@ MicroPython has significant constraints compared to desktop implementations:
### MicroPython Module Structure
```python
# natbridge_mpy.py (MicroPython)
# natsbridge_mpy.py (MicroPython)
import network
import time
import json

View File

@@ -134,7 +134,7 @@ env, env_json_str = smartsend("/chat/room1", data, broker_url="nats://localhost:
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
// Send a text message
const data = [["message", "Hello World", "text"]];
@@ -158,7 +158,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import smartsend
from natsbridge import smartsend
# Send a text message
data = [("message", "Hello World", "text")]
@@ -185,7 +185,7 @@ env, env_json_str = await smartsend(
#### MicroPython
```python
from natbridge_mpy import NATSBridge
from natsbridge_mpy import NATSBridge
bridge = NATSBridge()
@@ -218,7 +218,7 @@ end
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
// Receive and process message
const env = await NATSBridge.smartreceive(msg, {
@@ -233,7 +233,7 @@ for (const [dataname, data, type] of env.payloads) {
#### Python
```python
from natbridge import smartreceive, fetch_with_backoff
from natsbridge import smartreceive, fetch_with_backoff
# Receive and process message
env = await smartreceive(
@@ -269,7 +269,7 @@ env, env_json_str = smartsend("/device/config", data, broker_url="nats://localho
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const config = {
wifi_ssid: "MyNetwork",
@@ -288,7 +288,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import smartsend
from natsbridge import smartsend
config = {
"wifi_ssid": "MyNetwork",
@@ -307,7 +307,7 @@ env, env_json_str = await smartsend(
#### MicroPython
```python
from natbridge_mpy import NATSBridge
from natsbridge_mpy import NATSBridge
bridge = NATSBridge()
@@ -342,7 +342,7 @@ env, env_json_str = smartsend("/chat/image", data, broker_url="nats://localhost:
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const fs = require('fs');
// Read image file
@@ -359,7 +359,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import smartsend
from natsbridge import smartsend
# Read image file
with open("image.png", "rb") as f:
@@ -376,7 +376,7 @@ env, env_json_str = await smartsend(
#### MicroPython
```python
from natbridge_mpy import NATSBridge
from natsbridge_mpy import NATSBridge
bridge = NATSBridge()
@@ -413,7 +413,7 @@ env, env_json_str = smartsend(
#### JavaScript (Requester)
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
// Send command with reply-to
const data = [["command", { action: "read_sensor" }, "dictionary"]];
@@ -431,7 +431,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python (Requester)
```python
from natbridge import smartsend
from natsbridge import smartsend
# Send command with reply-to
data = [("command", {"action": "read_sensor"}, "dictionary")]
@@ -506,7 +506,7 @@ println("File uploaded to: $(env.payloads[1].data)")
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
// Create large data (> 1MB)
const large_data = Buffer.alloc(2_000_000);
@@ -530,7 +530,7 @@ console.log("File uploaded to:", env.payloads[0].data);
#### Python
```python
from natbridge import smartsend
from natsbridge import smartsend
# Create large data (> 1MB)
import os
@@ -552,7 +552,7 @@ print(f"File uploaded to: {env['payloads'][0]['data']}")
MicroPython enforces a hard limit of 50KB per payload:
```python
from natbridge_mpy import NATSBridge
from natsbridge_mpy import NATSBridge
bridge = NATSBridge()
@@ -590,7 +590,7 @@ env, env_json_str = smartsend("/chat/mixed", data, broker_url="nats://localhost:
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const fs = require('fs');
const image_data = fs.readFileSync('avatar.png');
@@ -610,7 +610,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import smartsend
from natsbridge import smartsend
with open("avatar.png", "rb") as f:
image_data = f.read()
@@ -652,7 +652,7 @@ env, env_json_str = smartsend("/data/students", data, broker_url="nats://localho
#### JavaScript
```javascript
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
// Create table data (array of objects)
const table_data = [
@@ -672,7 +672,7 @@ const [env, env_json_str] = await NATSBridge.smartsend(
#### Python
```python
from natbridge import smartsend
from natsbridge import smartsend
import pandas as pd
# Create DataFrame

View File

@@ -177,7 +177,7 @@ end
```javascript
// src/chat_ui.js
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
class ChatUI {
constructor() {
@@ -333,7 +333,7 @@ end
```javascript
// src/chat_handler.js
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const nats = require('nats');
class ChatHandler {
@@ -393,7 +393,7 @@ module.exports = ChatHandler;
# src/chat_handler.py
import asyncio
from typing import Optional
from natbridge import smartreceive, fetch_with_backoff
from natsbridge import smartreceive, fetch_with_backoff
class ChatHandler:
def __init__(self, nats_connection):
@@ -526,7 +526,7 @@ end
```javascript
// src/file_upload_service.js
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const fs = require('fs');
class FileUploadService {
@@ -580,7 +580,7 @@ module.exports = FileUploadService;
```python
# src/file_upload_service.py
from natbridge import smartsend
from natsbridge import smartsend
import os
class FileUploadService:
@@ -659,7 +659,7 @@ end
```javascript
// src/file_download_service.js
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const fs = require('fs');
class FileDownloadService {
@@ -690,7 +690,7 @@ module.exports = FileDownloadService;
```python
# src/file_download_service.py
from natbridge import smartreceive, fetch_with_backoff
from natsbridge import smartreceive, fetch_with_backoff
import os
class FileDownloadService:
@@ -832,7 +832,7 @@ end
```javascript
// src/sensor_data.js
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
class SensorReading {
constructor(sensorId, value, unit, metadata = {}) {
@@ -985,7 +985,7 @@ end
```javascript
// src/sensor_sender.js
const NATSBridge = require('./src/natbridge.js');
const NATSBridge = require('./src/natsbridge.js');
const { SensorReading, SensorBatch } = require('./sensor_data.js');
class SensorSender {
@@ -1069,7 +1069,7 @@ module.exports = SensorSender;
```python
# src/sensor_sender.py
from natbridge import smartsend
from natsbridge import smartsend
from sensor_data import SensorReading, SensorBatch
class SensorSender:
@@ -1282,7 +1282,7 @@ end
# Cache file server responses
import asyncio
import threading
from natbridge import fetch_with_backoff
from natsbridge import fetch_with_backoff
file_cache = {}
cache_lock = threading.Lock()

View File

@@ -6,7 +6,7 @@ This module provides functionality for sending and receiving data across network
using NATS as the message bus, with support for both direct payload transport and
URL-based transport for larger payloads.
@package natbridge
@package natsbridge
"""
import asyncio

View File

@@ -3,7 +3,7 @@
* Tests the smartreceive function with binary/image/audio/video payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';
const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080';

View File

@@ -3,7 +3,7 @@
* Tests the smartsend function with binary/image/audio/video payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_SUBJECT = '/test/binary';
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';

View File

@@ -3,7 +3,7 @@
* Tests the smartreceive function with dictionary payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';
const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080';

View File

@@ -3,7 +3,7 @@
* Tests the smartsend function with dictionary payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_SUBJECT = '/test/dictionary';
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';

View File

@@ -3,7 +3,7 @@
* Tests the smartsend function with mixed payload types
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_SUBJECT = '/test/mix';
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';

View File

@@ -3,7 +3,7 @@
* Tests the smartreceive function with table (Arrow IPC) payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';
const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080';

View File

@@ -3,7 +3,7 @@
* Tests the smartsend function with table (Arrow IPC) payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_SUBJECT = '/test/table';
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';

View File

@@ -3,7 +3,7 @@
* Tests the smartreceive function with text payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';
const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080';

View File

@@ -3,7 +3,7 @@
* Tests the smartsend function with text payloads
*/
const NATSBridge = require('../src/natbridge.js');
const NATSBridge = require('../src/natsbridge.js');
const TEST_SUBJECT = '/test/text';
const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222';

View File

@@ -14,7 +14,7 @@ import base64
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
@@ -23,7 +23,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
def run_test():
print('=== MicroPython Binary Receiver Test ===\n')
from natbridge_mpy import _generate_uuid
from natsbridge_mpy import _generate_uuid
# Create mock NATS message with binary payloads
image_data = bytes([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]) # PNG header

View File

@@ -13,7 +13,7 @@ import base64
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE
from natsbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE
TEST_SUBJECT = '/test/binary'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
@@ -23,7 +23,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
def run_test():
print('=== MicroPython Binary Sender Test ===\n')
from natbridge_mpy import _generate_uuid
from natsbridge_mpy import _generate_uuid
correlation_id = 'mpy-binary-test-' + _generate_uuid()
print(f'Correlation ID: {correlation_id}')
print(f'Subject: {TEST_SUBJECT}')

View File

@@ -13,7 +13,7 @@ import json
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
@@ -22,7 +22,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
def run_test():
print('=== MicroPython Dictionary Receiver Test ===\n')
from natbridge_mpy import _generate_uuid
from natsbridge_mpy import _generate_uuid
# Create a mock NATS message with dictionary payloads
import base64

View File

@@ -13,7 +13,7 @@ import json
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE
from natsbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE
TEST_SUBJECT = '/test/dictionary'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
@@ -23,7 +23,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
def run_test():
print('=== MicroPython Dictionary Sender Test ===\n')
from natbridge_mpy import _generate_uuid
from natsbridge_mpy import _generate_uuid
correlation_id = 'mpy-dict-test-' + _generate_uuid()
print(f'Correlation ID: {correlation_id}')
print(f'Subject: {TEST_SUBJECT}')

View File

@@ -13,7 +13,7 @@ import json
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
@@ -22,7 +22,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
def run_test():
print('=== MicroPython Text Receiver Test ===\n')
from natbridge_mpy import _generate_uuid
from natsbridge_mpy import _generate_uuid
# Create a mock NATS message with text payload
test_text = 'Hello, NATSBridge! This is a test message.'

View File

@@ -12,7 +12,7 @@ import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE
from natsbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE
TEST_SUBJECT = '/test/text'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
@@ -22,7 +22,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')
def run_test():
print('=== MicroPython Text Sender Test ===\n')
from natbridge_mpy import _generate_uuid
from natsbridge_mpy import _generate_uuid
correlation_id = 'mpy-text-test-' + _generate_uuid()
print(f'Correlation ID: {correlation_id}')
print(f'Subject: {TEST_SUBJECT}')

View File

@@ -12,7 +12,7 @@ import base64
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')

View File

@@ -11,7 +11,7 @@ import base64
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_SUBJECT = '/test/binary'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')

View File

@@ -11,7 +11,7 @@ import json
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')

View File

@@ -11,7 +11,7 @@ import json
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_SUBJECT = '/test/dictionary'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')

View File

@@ -11,7 +11,7 @@ import base64
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_SUBJECT = '/test/mix'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')

View File

@@ -10,7 +10,7 @@ import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_SUBJECT = '/test/table'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')

View File

@@ -11,7 +11,7 @@ import json
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')
TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080')

View File

@@ -10,7 +10,7 @@ import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL
TEST_SUBJECT = '/test/text'
TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')