({ id, type, payload, channel, priority, refId, expiresAt })
| 353 | } |
| 354 | |
| 355 | writeInbound({ id, type, payload, channel, priority, refId, expiresAt }) { |
| 356 | const msgId = id || generateUUIDv7(); |
| 357 | // At-least-once delivery from the Hub / retry loops can send the same |
| 358 | // message id twice. Without idempotency, poll() and countPending() would |
| 359 | // double-count the retry. See community PR #515. |
| 360 | if (this._messages.has(msgId)) return msgId; |
| 361 | |
| 362 | const now = Date.now(); |
| 363 | const msg = { |
| 364 | id: msgId, |
| 365 | channel: channel || DEFAULT_CHANNEL, |
| 366 | direction: 'inbound', |
| 367 | type, |
| 368 | status: 'pending', |
| 369 | payload: safeParse(payload), |
| 370 | priority: priority || 'normal', |
| 371 | ref_id: refId || null, |
| 372 | created_at: now, |
| 373 | synced_at: null, |
| 374 | expires_at: expiresAt || null, |
| 375 | retry_count: 0, |
| 376 | next_retry_at: null, |
| 377 | error: null, |
| 378 | }; |
| 379 | this._appendMessage(msg); |
| 380 | return msgId; |
| 381 | } |
| 382 | |
| 383 | writeInboundBatch(messages) { |
| 384 | const ids = []; |
no test coverage detected