From f366a2fd63d4d5a371f756e584a668eb0968d92f Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 11 Jan 2024 21:25:17 +0100 Subject: [PATCH] More cleanup --- common/space_index.ts | 2 +- plugos/lib/mq.datastore.ts | 4 +--- plugos/syscalls/datastore.ts | 7 +++---- web/syscalls/datastore.proxy.ts | 9 +++++++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/space_index.ts b/common/space_index.ts index 0ee89f11..4df2beef 100644 --- a/common/space_index.ts +++ b/common/space_index.ts @@ -4,7 +4,7 @@ import { System } from "../plugos/system.ts"; const indexVersionKey = ["$indexVersion"]; // Bump this one every time a full reinxex is needed -const desiredIndexVersion = 2; +const desiredIndexVersion = 1; let indexOngoing = false; diff --git a/plugos/lib/mq.datastore.ts b/plugos/lib/mq.datastore.ts index b49cb3d7..bc2da069 100644 --- a/plugos/lib/mq.datastore.ts +++ b/plugos/lib/mq.datastore.ts @@ -51,8 +51,6 @@ export class DataStoreMQ implements MessageQueue { } async poll(queue: string, maxItems: number): Promise { - // console.log("Polling", queue, maxItems); - // console.trace(); // Note: this is not happening in a transactional way, so we may get duplicate message delivery // Retrieve a batch of messages const messages = await this.ds.query({ @@ -109,7 +107,7 @@ export class DataStoreMQ implements MessageQueue { if (timeout) { clearTimeout(timeout); } - timeout = setTimeout(run, options.pollInterval || 5000); + // timeout = setTimeout(run, options.pollInterval || 5000); } catch (e: any) { console.error("Error in MQ subscription handler", e); } diff --git a/plugos/syscalls/datastore.ts b/plugos/syscalls/datastore.ts index 8fd6d0db..bd60be05 100644 --- a/plugos/syscalls/datastore.ts +++ b/plugos/syscalls/datastore.ts @@ -1,5 +1,5 @@ import { KV, KvKey, KvQuery } from "$sb/types.ts"; -import type { DataStore, IDataStore } from "../lib/datastore.ts"; +import type { IDataStore } from "../lib/datastore.ts"; import type { SyscallContext, SysCallMapping } from "../system.ts"; /** @@ -9,7 +9,6 @@ import type { SyscallContext, SysCallMapping } from "../system.ts"; */ export function dataStoreSyscalls( ds: IDataStore, - prefix: KvKey = ["ds"], ): SysCallMapping { return { "datastore.delete": (ctx, key: KvKey) => { @@ -66,10 +65,10 @@ export function dataStoreSyscalls( }; function applyPrefix(ctx: SyscallContext, key?: KvKey): KvKey { - return [...prefix, ctx.plug.name!, ...(key ? key : [])]; + return [ctx.plug.name!, ...(key ? key : [])]; } function stripPrefix(key: KvKey): KvKey { - return key.slice(prefix.length + 1); + return key.slice(1); } } diff --git a/web/syscalls/datastore.proxy.ts b/web/syscalls/datastore.proxy.ts index 860e37ad..1b270983 100644 --- a/web/syscalls/datastore.proxy.ts +++ b/web/syscalls/datastore.proxy.ts @@ -12,6 +12,9 @@ export function dataStoreProxySyscalls( ]); }, "datastore.batchDelete": (ctx, keys: KvKey[]) => { + if (keys.length === 0) { + return Promise.resolve(); + } return rpcCall( httpSpacePrimitives, "datastore.batchDelete", @@ -24,6 +27,9 @@ export function dataStoreProxySyscalls( ]); }, "datastore.batchSet": (ctx, entries: KV[]) => { + if (entries.length === 0) { + return Promise.resolve(); + } return rpcCall( httpSpacePrimitives, "datastore.batchSet", @@ -41,6 +47,9 @@ export function dataStoreProxySyscalls( return result; }, "datastore.batchGet": (ctx, keys: KvKey[]) => { + if (keys.length === 0) { + return Promise.resolve([]); + } return rpcCall( httpSpacePrimitives, "datastore.batchGet",