Skip to content

Commit

Permalink
Merge pull request #63 from outerbase/bwilmoth/release-0.1.4
Browse files Browse the repository at this point in the history
Release 0.1.4
  • Loading branch information
Brayden authored Jan 15, 2025
2 parents 496e9c9 + 2ac2730 commit b0a381e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 136 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@outerbase/starbasedb",
"version": "0.1.0",
"version": "0.1.4",
"files": [
"src",
"dist",
Expand All @@ -23,6 +23,7 @@
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"publish-npm-module": "npm publish --access public",
"cf-typegen": "wrangler types",
"delete": "wrangler delete",
"prepare": "husky",
Expand Down
135 changes: 0 additions & 135 deletions src/do.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { DurableObject } from 'cloudflare:workers'
// import { OperationQueueItem } from "./operation";
// import { createResponse } from "./utils";

export class StarbaseDBDurableObject extends DurableObject {
// Durable storage for the SQL database
public sql: SqlStorage
public storage: DurableObjectStorage

// // Queue of operations to be processed, with each operation containing a list of queries to be executed
// private operationQueue: Array<OperationQueueItem> = [];

// // Flag to indicate if an operation is currently being processed
// private processingOperation: { value: boolean } = { value: false };

/**
* The constructor is invoked once upon creation of the Durable Object, i.e. the first call to
* `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
Expand Down Expand Up @@ -73,44 +65,6 @@ export class StarbaseDBDurableObject extends DurableObject {
}
}

// TODO: Hiding for now as it's not used in the current implementation
// /**
// * Execute a raw SQL query on the database, typically used for external requests
// * from other service bindings (e.g. auth). This serves as an exposed function for
// * other service bindings to query the database without having to have knowledge of
// * the current operation queue or processing state.
// *
// * @param sql - The SQL query to execute.
// * @param params - Optional parameters for the SQL query.
// * @returns A response containing the query result or an error message.
// */
// private async executeExternalQuery(
// sql: string,
// params: any[] | undefined
// ): Promise<any> {
// try {
// const queries = [{ sql, params }];
// const response = await this.enqueueOperation(
// queries,
// false,
// false,
// this.operationQueue,
// () =>
// this.processNextOperation(
// this.sql,
// this.operationQueue,
// this.ctx,
// this.processingOperation
// )
// );

// return response;
// } catch (error: any) {
// console.error("Execute External Query Error:", error);
// return null;
// }
// }

private async executeRawQuery<
T extends Record<string, SqlStorageValue> = Record<
string,
Expand Down Expand Up @@ -177,93 +131,4 @@ export class StarbaseDBDurableObject extends DurableObject {
}
})
}

// TODO: Hiding for now as it's not used in the current implementation
// private enqueueOperation(
// queries: { sql: string; params?: any[] }[],
// isTransaction: boolean,
// isRaw: boolean,
// operationQueue: any[],
// processNextOperation: () => Promise<void>
// ): Promise<{ result?: any; error?: string | undefined; status: number }> {
// const MAX_WAIT_TIME = 25000;
// return new Promise((resolve, reject) => {
// const timeout = setTimeout(() => {
// reject(createResponse(undefined, "Operation timed out.", 503));
// }, MAX_WAIT_TIME);

// operationQueue.push({
// queries,
// isTransaction,
// isRaw,
// resolve: (value: any) => {
// clearTimeout(timeout);

// resolve({
// result: value,
// error: undefined,
// status: 200,
// });
// },
// reject: (reason?: any) => {
// clearTimeout(timeout);

// reject({
// result: undefined,
// error: reason ?? "Operation failed.",
// status: 500,
// });
// },
// });

// processNextOperation().catch((err) => {
// console.error("Error processing operation queue:", err);
// });
// });
// }

// TODO: Hiding for now as it's not used in the current implementation
// private async processNextOperation(
// sqlInstance: any,
// operationQueue: OperationQueueItem[],
// ctx: any,
// processingOperation: { value: boolean }
// ) {
// if (processingOperation.value) {
// // Already processing an operation
// return;
// }

// if (operationQueue.length === 0) {
// // No operations remaining to process
// return;
// }

// processingOperation.value = true;
// const { queries, isTransaction, isRaw, resolve, reject } =
// operationQueue.shift()!;

// try {
// let result;

// if (isTransaction) {
// result = await this.executeTransaction(queries, isRaw);
// } else {
// const { sql, params } = queries[0];
// result = this.executeQuery({ sql, params });
// }

// resolve(result);
// } catch (error: any) {
// reject(error.message || "Operation failed.");
// } finally {
// processingOperation.value = false;
// await this.processNextOperation(
// sqlInstance,
// operationQueue,
// ctx,
// processingOperation
// );
// }
// }
}

0 comments on commit b0a381e

Please sign in to comment.