MCPcopy Create free account
hub / github.com/electric-sql/electric / append

Method append

packages/agents-server/src/stream-client.ts:286–311  ·  view source on GitHub ↗
(
    path: string,
    data: Uint8Array | string,
    opts?: { close?: boolean }
  )

Source from the content-addressed store, hash-verified

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,

Callers 15

flush_eventFunction · 0.45
mainFunction · 0.45
pbt-micro.test.tsFile · 0.45
canonicalShapeKeyFunction · 0.45
startStreamMethod · 0.45
ensurePrincipalMethod · 0.45
forkSubtreeInnerMethod · 0.45
sendMethod · 0.45
writeCollectionMethod · 0.45
updateInboxMessageMethod · 0.45
deleteInboxMessageMethod · 0.45
writeManifestEntryMethod · 0.45

Calls 5

streamUrlMethod · 0.95
streamHeadersMethod · 0.95
withSpanFunction · 0.85
headMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected