More cleanup

pull/628/head
Zef Hemel 2024-01-11 21:25:17 +01:00
parent b644801e7b
commit f366a2fd63
4 changed files with 14 additions and 8 deletions

View File

@ -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;

View File

@ -51,8 +51,6 @@ export class DataStoreMQ implements MessageQueue {
}
async poll(queue: string, maxItems: number): Promise<MQMessage[]> {
// 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<MQMessage>({
@ -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);
}

View File

@ -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);
}
}

View File

@ -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",