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

Function rpcImpl

vmm/ui/src/lib/vmmRpcClient.ts:65–87  ·  view source on GitHub ↗
(method: any, requestData: Uint8Array, callback: (err?: Error | null, data?: Uint8Array) => void)

Source from the content-addressed store, hash-verified

63 }
64
65 const rpcImpl = (method: any, requestData: Uint8Array, callback: (err?: Error | null, data?: Uint8Array) => void) => {
66 const methodName = resolveMethodName(method);
67 const payload = normalizeRequestData(requestData);
68 fetch(`${basePath}/${methodName}`, {
69 method: 'POST',
70 headers: {
71 'Content-Type': 'application/octet-stream',
72 },
73 body: payload as unknown as BodyInit,
74 credentials: 'same-origin',
75 })
76 .then(async (response) => {
77 const buffer = new Uint8Array(await response.arrayBuffer());
78 if (!response.ok) {
79 callback(new Error(decodePrpcError(buffer)));
80 return;
81 }
82 callback(null, buffer);
83 })
84 .catch((error) => {
85 callback(error);
86 });
87 };
88
89 cachedClient = vmm.Vmm.create(rpcImpl, false, false);
90 return cachedClient;

Callers

nothing calls this directly

Calls 3

resolveMethodNameFunction · 0.85
normalizeRequestDataFunction · 0.85
decodePrpcErrorFunction · 0.85

Tested by

no test coverage detected