(
path: string,
data: Uint8Array | string,
opts?: { close?: boolean }
)
| 284 | } |
| 285 | |
| 286 | async append( |
| 287 | path: string, |
| 288 | data: Uint8Array | string, |
| 289 | opts?: { close?: boolean } |
| 290 | ): Promise<StreamAppendResult> { |
| 291 | return await withSpan(`stream.append`, async (span) => { |
| 292 | span.setAttributes({ |
| 293 | [ATTR.STREAM_PATH]: path, |
| 294 | [ATTR.STREAM_OP]: opts?.close ? `append+close` : `append`, |
| 295 | }) |
| 296 | const handle = new DurableStream({ |
| 297 | url: this.streamUrl(path), |
| 298 | headers: this.streamHeaders(), |
| 299 | contentType: `application/json`, |
| 300 | batching: false, |
| 301 | }) |
| 302 | if (opts?.close) { |
| 303 | const result = await handle.close({ body: data }) |
| 304 | return { offset: result.finalOffset } |
| 305 | } |
| 306 | |
| 307 | await handle.append(data) |
| 308 | const head = await handle.head() |
| 309 | return { offset: (head.exists && head.offset) || `` } |
| 310 | }) |
| 311 | } |
| 312 | |
| 313 | async appendIdempotent( |
| 314 | path: string, |
no test coverage detected