-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Enable default and CLI options
- Loading branch information
1 parent
53c97c3
commit 7014052
Showing
8 changed files
with
121 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,7 @@ impl TestBedBuilder { | |
Some(token.clone()), | ||
vec![], | ||
None, | ||
None, | ||
) | ||
.await | ||
.unwrap(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { serve } from 'https://deno.land/[email protected]/http/server.ts'; | ||
|
||
console.log('main function started'); | ||
|
||
serve(async (req: Request) => { | ||
const url = new URL(req.url); | ||
const { pathname } = url; | ||
const path_parts = pathname.split('/'); | ||
const service_name = path_parts[1]; | ||
|
||
if (!service_name || service_name === '') { | ||
const error = { msg: 'missing function name in request' }; | ||
return new Response( | ||
JSON.stringify(error), | ||
{ status: 400, headers: { 'Content-Type': 'application/json' } }, | ||
); | ||
} | ||
|
||
const servicePath = `./test_cases/${service_name}`; | ||
console.error(`serving the request with ${servicePath}`); | ||
|
||
const createWorker = async () => { | ||
const memoryLimitMb = 150; | ||
const workerTimeoutMs = 1 * 60 * 1000; | ||
const noModuleCache = false; | ||
const importMapPath = null; | ||
const envVarsObj = Deno.env.toObject(); | ||
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]]); | ||
|
||
return await EdgeRuntime.userWorkers.create({ | ||
servicePath, | ||
memoryLimitMb, | ||
workerTimeoutMs, | ||
noModuleCache, | ||
importMapPath, | ||
envVars | ||
}); | ||
}; | ||
|
||
const callWorker = async () => { | ||
try { | ||
const worker = await createWorker(); | ||
return await worker.fetch(req); | ||
} catch (e) { | ||
console.error(e); | ||
const error = { msg: e.toString() }; | ||
return new Response( | ||
JSON.stringify(error), | ||
{ status: 500, headers: { 'Content-Type': 'application/json' } }, | ||
); | ||
} | ||
}; | ||
|
||
return callWorker(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters