MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / encode_sync_response

Function encode_sync_response

gateway/src/web_routes/wavekv_sync.rs:55–71  ·  view source on GitHub ↗

Encode and compress sync response

(response: &SyncResponse)

Source from the content-addressed store, hash-verified

53
54/// Encode and compress sync response
55fn encode_sync_response(response: &SyncResponse) -> Result<Vec<u8>, Status> {
56 let encoded = encode(response).map_err(|e| {
57 warn!("failed to encode sync response: {e}");
58 Status::InternalServerError
59 })?;
60
61 // Compress
62 let mut encoder = GzEncoder::new(Vec::new(), Compression::fast());
63 encoder.write_all(&encoded).map_err(|e| {
64 warn!("failed to compress sync response: {e}");
65 Status::InternalServerError
66 })?;
67 encoder.finish().map_err(|e| {
68 warn!("failed to finish compression: {e}");
69 Status::InternalServerError
70 })
71}
72
73/// Verify that the request is from a gateway with the same app_id (mTLS verification)
74fn verify_gateway_peer(state: &Proxy, cert: Option<Certificate<'_>>) -> Result<(), Status> {

Callers 1

sync_storeFunction · 0.85

Calls 2

encodeFunction · 0.85
finishMethod · 0.45

Tested by

no test coverage detected