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

Function messageFromRow

packages/cluster/src/SqlMessageStorage.ts:152–214  ·  view source on GitHub ↗
(row: MessageRow & ReplyJoinRow)

Source from the content-addressed store, hash-verified

150 })
151
152 const messageFromRow = (row: MessageRow & ReplyJoinRow): {
153 readonly envelope: Envelope.Envelope.Encoded
154 readonly lastSentReply: Option.Option<Reply.ReplyEncoded<any>>
155 } => {
156 switch (Number(row.kind) as 0 | 1 | 2) {
157 case 0:
158 return {
159 envelope: {
160 _tag: "Request",
161 requestId: String(row.id),
162 address: {
163 shardId: ShardId.fromStringEncoded(row.shard_id),
164 entityType: row.entity_type,
165 entityId: row.entity_id
166 },
167 tag: row.tag!,
168 payload: JSON.parse(row.payload!),
169 headers: JSON.parse(row.headers!),
170 traceId: row.trace_id ?? undefined,
171 spanId: row.span_id ?? undefined,
172 sampled: !!row.sampled
173 },
174 lastSentReply: row.reply_reply_id ?
175 Option.some({
176 _tag: "Chunk",
177 id: String(row.reply_reply_id),
178 requestId: String(row.request_id),
179 sequence: Number(row.reply_sequence!),
180 values: JSON.parse(row.reply_payload!)
181 } as any) :
182 Option.none()
183 }
184 case 1:
185 return {
186 envelope: {
187 _tag: "AckChunk",
188 id: String(row.id),
189 requestId: String(row.request_id!),
190 replyId: String(row.reply_id!),
191 address: {
192 shardId: ShardId.fromStringEncoded(row.shard_id),
193 entityType: row.entity_type,
194 entityId: row.entity_id
195 }
196 },
197 lastSentReply: Option.none()
198 }
199 case 2:
200 return {
201 envelope: {
202 _tag: "Interrupt",
203 id: String(row.id),
204 requestId: String(row.request_id!),
205 address: {
206 shardId: ShardId.fromStringEncoded(row.shard_id),
207 entityType: row.entity_type,
208 entityId: row.entity_id
209 }

Callers 1

Calls 4

NumberInterface · 0.85
StringInterface · 0.85
fromStringEncodedMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected