MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / pack_rows

Function pack_rows

src/environmentd/src/http/webhook.rs:187–200  ·  view source on GitHub ↗

Packs the body and headers of a webhook request into as many rows as necessary. TODO(parkmycar): Should we be consolidating the returned Rows here? Presumably something in storage would already be doing it, so no need to do it twice?

(
    body: &[u8],
    body_format: &WebhookBodyFormat,
    headers: &BTreeMap<String, String>,
    header_tys: &WebhookHeaders,
)

Source from the content-addressed store, hash-verified

185/// TODO(parkmycar): Should we be consolidating the returned Rows here? Presumably something in
186/// storage would already be doing it, so no need to do it twice?
187fn pack_rows(
188 body: &[u8],
189 body_format: &WebhookBodyFormat,
190 headers: &BTreeMap<String, String>,
191 header_tys: &WebhookHeaders,
192) -> Result<Vec<(Row, Diff)>, AppendWebhookError> {
193 // This method isn't that "deep" but it reflects the way we intend for the packing process to
194 // work and makes testing easier.
195 let rows = transform_body(body, body_format)?
196 .into_iter()
197 .map(|row| pack_header(row, headers, header_tys).map(|row| (row, Diff::ONE)))
198 .collect::<Result<_, _>>()?;
199 Ok(rows)
200}
201
202/// Transforms the body of a webhook request into a `Vec<BodyRow>`.
203fn transform_body(

Callers 3

append_webhookFunction · 0.85
test_json_array_singleFunction · 0.85

Calls 4

transform_bodyFunction · 0.85
pack_headerFunction · 0.85
mapMethod · 0.45
into_iterMethod · 0.45

Tested by 2

test_json_array_singleFunction · 0.68