( doc: MessageDoc, lastSentReply: Option.Option<Reply.Encoded> )
| 238 | } |
| 239 | |
| 240 | const envelopeFromDoc = ( |
| 241 | doc: MessageDoc, |
| 242 | lastSentReply: Option.Option<Reply.Encoded> |
| 243 | ): { |
| 244 | readonly envelope: Envelope.Encoded |
| 245 | readonly lastSentReply: Option.Option<Reply.Encoded> |
| 246 | } => { |
| 247 | switch (doc.kind) { |
| 248 | case "Request": { |
| 249 | const envelope: Envelope.PartialRequestEncoded = { |
| 250 | _tag: "Request", |
| 251 | requestId: doc.requestId, |
| 252 | address: { |
| 253 | shardId: shardIdFromString(doc.shardId), |
| 254 | entityType: doc.entityType, |
| 255 | entityId: doc.entityId |
| 256 | }, |
| 257 | tag: doc.tag ?? "", |
| 258 | payload: doc.payload, |
| 259 | headers: doc.headers ?? {}, |
| 260 | ...(doc.traceId !== undefined && { traceId: doc.traceId }), |
| 261 | ...(doc.spanId !== undefined && { spanId: doc.spanId }), |
| 262 | ...(doc.sampled !== undefined && { sampled: doc.sampled }) |
| 263 | } |
| 264 | return { |
| 265 | envelope, |
| 266 | lastSentReply |
| 267 | } |
| 268 | } |
| 269 | case "AckChunk": |
| 270 | return { |
| 271 | envelope: { |
| 272 | _tag: "AckChunk", |
| 273 | id: doc.rowid, |
| 274 | requestId: doc.requestId, |
| 275 | replyId: doc.replyId ?? "", |
| 276 | address: { |
| 277 | shardId: shardIdFromString(doc.shardId), |
| 278 | entityType: doc.entityType, |
| 279 | entityId: doc.entityId |
| 280 | } |
| 281 | }, |
| 282 | lastSentReply: Option.none() |
| 283 | } |
| 284 | case "Interrupt": |
| 285 | return { |
| 286 | envelope: { |
| 287 | _tag: "Interrupt", |
| 288 | id: doc.rowid, |
| 289 | requestId: doc.requestId, |
| 290 | address: { |
| 291 | shardId: shardIdFromString(doc.shardId), |
| 292 | entityType: doc.entityType, |
| 293 | entityId: doc.entityId |
| 294 | } |
| 295 | }, |
| 296 | lastSentReply: Option.none() |
| 297 | } |
no test coverage detected
searching dependent graphs…