MCPcopy Create free account
hub / github.com/Effect-TS/effect / dehydrate

Function dehydrate

packages/effect/src/ui/Query.ts:7190–7246  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7188 | Map<string, Map<string, AsyncResult.Success<any, any>>>
7189 | undefined
7190 const dehydrate: CacheInternals["dehydrate"] = () => {
7191 const out: Dehydrated = {}
7192 emitted = new Map()
7193 for (const entry of allEntries()) {
7194 dropFetch(entry)
7195 resumeAll(entry.waiters, Exit.interrupt())
7196 resumeAll(entry.moreWaiters, Exit.interrupt())
7197 entry.target = undefined
7198 if (entry.shared !== undefined) endShared(entry.shared, Exit.interrupt())
7199 const result = entry.result
7200 if (
7201 result === undefined ||
7202 holdsRedacted(entry.def.args.ast) ||
7203 holdsRedacted(entry.def.success.ast) ||
7204 holdsRedacted(entry.def.error.ast)
7205 ) {
7206 afterQuiet(entry)
7207 continue
7208 }
7209 try {
7210 const codec = entry.def.codec()
7211 const tuple: RawTuple = result._tag === "Success"
7212 ? [
7213 entry.argsKey,
7214 0,
7215 codec.encodeSuccess(result.value),
7216 result.timestamp
7217 ]
7218 : [
7219 entry.argsKey,
7220 1,
7221 result.cause.reasons.filter(Cause.isFailReason).map((reason) => codec.encodeError(reason.error)),
7222 entry.settledAt
7223 ]
7224 ;(out[entry.def.name] ??= []).push(tuple)
7225 if (result._tag === "Success") {
7226 let byKey = emitted.get(entry.def.name)
7227 if (byKey === undefined) {
7228 emitted.set(entry.def.name, byKey = new Map())
7229 }
7230 byKey.set(entry.argsKey, result)
7231 }
7232 } catch {
7233 const logKey = logKeyOf(entry)
7234 report(
7235 new EncodeFailed({
7236 query: entry.def.name,
7237 logKey,
7238 message: "[Query] the entry of " + quote(entry.def.name) + " at " +
7239 logKey +
7240 " failed to encode. It was left out, and the client fetches it."
7241 })
7242 )
7243 }
7244 }
7245 return out
7246 }
7247 const checkWire: CacheInternals["checkWire"] = (input) => {

Callers

nothing calls this directly

Calls 14

allEntriesFunction · 0.85
dropFetchFunction · 0.85
resumeAllFunction · 0.85
endSharedFunction · 0.85
afterQuietFunction · 0.85
logKeyOfFunction · 0.85
reportFunction · 0.70
quoteFunction · 0.70
pushMethod · 0.65
getMethod · 0.65
setMethod · 0.65
interruptMethod · 0.45

Tested by

no test coverage detected