MCPcopy Index your code
hub / github.com/simstudioai/sim / openSession

Function openSession

apps/sim/lib/data-drains/destinations/gcs.ts:289–319  ·  view source on GitHub ↗
({ config, credentials })

Source from the content-addressed store, hash-verified

287 },
288
289 openSession({ config, credentials }) {
290 const account = parseServiceAccount(credentials.serviceAccountJson)
291 const jwt = buildJwt(account)
292 return {
293 async deliver({ body, contentType, metadata, signal }) {
294 const objectName = buildObjectKey(config.prefix, metadata)
295 await uploadObject('put-object', {
296 bucket: config.bucket,
297 objectName,
298 body,
299 contentType,
300 metadata: {
301 'sim-drain-id': metadata.drainId,
302 'sim-run-id': metadata.runId,
303 'sim-source': metadata.source,
304 'sim-sequence': metadata.sequence.toString(),
305 'sim-row-count': metadata.rowCount.toString(),
306 },
307 signal,
308 jwt,
309 })
310 logger.debug('GCS chunk delivered', {
311 bucket: config.bucket,
312 objectName,
313 bytes: body.byteLength,
314 })
315 return { locator: `gs://${config.bucket}/${objectName}` }
316 },
317 async close() {},
318 }
319 },
320}

Callers

nothing calls this directly

Calls 2

parseServiceAccountFunction · 0.90
buildJwtFunction · 0.70

Tested by

no test coverage detected