MCPcopy Index your code
hub / github.com/Effect-TS/effect / messageFromRow

Function messageFromRow

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

Source from the content-addressed store, hash-verified

133 })
134
135 const messageFromRow = (row: MessageRow & ReplyJoinRow): {
136 readonly envelope: Envelope.Envelope.Encoded
137 readonly lastSentReply: Option.Option<Reply.ReplyEncoded<any>>
138 } => {
139 switch (Number(row.kind) as 0 | 1 | 2) {
140 case 0:
141 return {
142 envelope: {
143 _tag: "Request",
144 requestId: String(row.id),
145 address: {
146 shardId: ShardId.fromStringEncoded(row.shard_id),
147 entityType: row.entity_type,
148 entityId: row.entity_id
149 },
150 tag: row.tag!,
151 payload: JSON.parse(row.payload!),
152 headers: JSON.parse(row.headers!),
153 traceId: row.trace_id ?? undefined,
154 spanId: row.span_id ?? undefined,
155 sampled: !!row.sampled
156 },
157 lastSentReply: row.reply_reply_id ?
158 Option.some({
159 _tag: "Chunk",
160 id: String(row.reply_reply_id),
161 requestId: String(row.request_id),
162 sequence: Number(row.reply_sequence!),
163 values: JSON.parse(row.reply_payload!)
164 } as any) :
165 Option.none()
166 }
167 case 1:
168 return {
169 envelope: {
170 _tag: "AckChunk",
171 id: String(row.id),
172 requestId: String(row.request_id!),
173 replyId: String(row.reply_id!),
174 address: {
175 shardId: ShardId.fromStringEncoded(row.shard_id),
176 entityType: row.entity_type,
177 entityId: row.entity_id
178 }
179 },
180 lastSentReply: Option.none()
181 }
182 case 2:
183 return {
184 envelope: {
185 _tag: "Interrupt",
186 id: String(row.id),
187 requestId: String(row.request_id!),
188 address: {
189 shardId: ShardId.fromStringEncoded(row.shard_id),
190 entityType: row.entity_type,
191 entityId: row.entity_id
192 }

Callers 1

Calls 4

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

Tested by

no test coverage detected