Work on sync stuff

This commit is contained in:
Zef Hemel
2022-04-05 17:02:17 +02:00
parent 1b0048cdcf
commit 38faf50ab8
51 changed files with 704 additions and 257 deletions
+10 -10
View File
@@ -2,18 +2,18 @@
import express from "express";
import yargs from "yargs";
import {hideBin} from "yargs/helpers";
import {DiskPlugLoader} from "../plug_loader";
import {CronHookT, NodeCronHook} from "../hooks/node_cron";
import { hideBin } from "yargs/helpers";
import { DiskPlugLoader } from "../plug_loader";
import { CronHookT, NodeCronHook } from "../hooks/node_cron";
import shellSyscalls from "../syscalls/shell.node";
import {System} from "../system";
import {EndpointHook, EndpointHookT} from "../hooks/endpoint";
import {safeRun} from "../util";
import { System } from "../system";
import { EndpointHook, EndpointHookT } from "../hooks/endpoint";
import { safeRun } from "../util";
import knex from "knex";
import {ensureTable, storeSyscalls} from "../syscalls/store.knex_node";
import {fetchSyscalls} from "../syscalls/fetch.node";
import {EventHook, EventHookT} from "../hooks/event";
import {eventSyscalls} from "../syscalls/event";
import { ensureTable, storeSyscalls } from "../syscalls/store.knex_node";
import { fetchSyscalls } from "../syscalls/fetch.node";
import { EventHook, EventHookT } from "../hooks/event";
import { eventSyscalls } from "../syscalls/event";
let args = yargs(hideBin(process.argv))
.option("port", {
+2 -2
View File
@@ -1,5 +1,5 @@
import {safeRun} from "../util";
import {ControllerMessage, WorkerMessage} from "./worker";
import { safeRun } from "../util";
import { ControllerMessage, WorkerMessage } from "./worker";
let loadedFunctions = new Map<string, Function>();
let pendingRequests = new Map<
+3 -3
View File
@@ -1,6 +1,6 @@
import {Hook, Manifest} from "../types";
import {System} from "../system";
import {safeRun} from "../util";
import { Hook, Manifest } from "../types";
import { System } from "../system";
import { safeRun } from "../util";
// System events:
// - plug:load (plugName: string)
+3 -3
View File
@@ -1,6 +1,6 @@
import {createSandbox} from "./environments/node_sandbox";
import {expect, test} from "@jest/globals";
import {System} from "./system";
import { createSandbox } from "./environments/node_sandbox";
import { expect, test } from "@jest/globals";
import { System } from "./system";
test("Run a Node sandbox", async () => {
let system = new System("server");
+2 -2
View File
@@ -1,5 +1,5 @@
import {SysCallMapping} from "../system";
import {EventHook} from "../hooks/event";
import { SysCallMapping } from "../system";
import { EventHook } from "../hooks/event";
export function eventSyscalls(eventHook: EventHook): SysCallMapping {
return {
+2 -2
View File
@@ -1,5 +1,5 @@
import fetch, {RequestInfo, RequestInit} from "node-fetch";
import {SysCallMapping} from "../system";
import fetch, { RequestInfo, RequestInit } from "node-fetch";
import { SysCallMapping } from "../system";
export function fetchSyscalls(): SysCallMapping {
return {
+3 -3
View File
@@ -1,6 +1,6 @@
import {promisify} from "util";
import {execFile} from "child_process";
import type {SysCallMapping} from "../system";
import { promisify } from "util";
import { execFile } from "child_process";
import type { SysCallMapping } from "../system";
const execFilePromise = promisify(execFile);
+4 -4
View File
@@ -1,7 +1,7 @@
import {createSandbox} from "../environments/node_sandbox";
import {expect, test} from "@jest/globals";
import {System} from "../system";
import {storeSyscalls} from "./store.dexie_browser";
import { createSandbox } from "../environments/node_sandbox";
import { expect, test } from "@jest/globals";
import { System } from "../system";
import { storeSyscalls } from "./store.dexie_browser";
// For testing in node.js
require("fake-indexeddb/auto");
+1 -1
View File
@@ -1,5 +1,5 @@
import Dexie from "dexie";
import {SysCallMapping} from "../system";
import { SysCallMapping } from "../system";
export type KV = {
key: string;
+4 -4
View File
@@ -1,7 +1,7 @@
import {createSandbox} from "../environments/node_sandbox";
import {expect, test} from "@jest/globals";
import {System} from "../system";
import {ensureTable, storeSyscalls} from "./store.knex_node";
import { createSandbox } from "../environments/node_sandbox";
import { expect, test } from "@jest/globals";
import { System } from "../system";
import { ensureTable, storeSyscalls } from "./store.knex_node";
import knex from "knex";
import fs from "fs/promises";
+2 -2
View File
@@ -1,5 +1,5 @@
import {Knex} from "knex";
import {SysCallMapping} from "../system";
import { Knex } from "knex";
import { SysCallMapping } from "../system";
type Item = {
page: string;
+1 -1
View File
@@ -1,6 +1,6 @@
import { SyscallContext, SysCallMapping } from "../system";
export function transportSyscalls(
export function proxySyscalls(
names: string[],
transportCall: (
ctx: SyscallContext,
+4 -4
View File
@@ -1,7 +1,7 @@
import {Hook, Manifest, RuntimeEnvironment} from "./types";
import {EventEmitter} from "../common/event";
import {SandboxFactory} from "./sandbox";
import {Plug} from "./plug";
import { Hook, Manifest, RuntimeEnvironment } from "./types";
import { EventEmitter } from "../common/event";
import { SandboxFactory } from "./sandbox";
import { Plug } from "./plug";
export interface SysCallMapping {
[key: string]: (ctx: SyscallContext, ...args: any) => Promise<any> | any;