Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
cleanup console logs for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingsilverfin committed Jan 14, 2022
1 parent 81b6d02 commit d0f135f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 53 deletions.
33 changes: 11 additions & 22 deletions common/rpc/TypeDBStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
*/


import {ClientDuplexStream, ServiceError} from "@grpc/grpc-js";
import { Session } from "typedb-protocol/common/session_pb";
import { CoreDatabase as CoreDatabaseProto, CoreDatabaseManager as CoreDatabaseMgrProto } from "typedb-protocol/core/core_database_pb";
import { TypeDBClient } from "typedb-protocol/core/core_service_grpc_pb";
import { TypeDBDatabaseImpl } from "../../connection/TypeDBDatabaseImpl";
import {ClientDuplexStream} from "@grpc/grpc-js";
import {Session} from "typedb-protocol/common/session_pb";
import {
CoreDatabase as CoreDatabaseProto,
CoreDatabaseManager as CoreDatabaseMgrProto
} from "typedb-protocol/core/core_database_pb";
import {TypeDBClient} from "typedb-protocol/core/core_service_grpc_pb";
import {TypeDBDatabaseImpl} from "../../connection/TypeDBDatabaseImpl";
import * as common_transaction_pb from "typedb-protocol/common/transaction_pb";
import {TypeDBClientError} from "../errors/TypeDBClientError";

Expand All @@ -37,10 +40,7 @@ export abstract class TypeDBStub {
return new Promise((resolve, reject) => {
this.stub().databases_create(req, (err) => {
if (err) reject(new TypeDBClientError(err));
else {
resolve();
console.error("Databases create finished: '" + req.getName() + "'");
}
else resolve();
})
});
}
Expand All @@ -49,15 +49,7 @@ export abstract class TypeDBStub {
return new Promise((resolve, reject) => {
this.stub().databases_contains(req, (err, res) => {
if (err) reject(new TypeDBClientError(err));
else {
try {
resolve(res.getContains());
} catch {
console.log("ERROR in databases contains");
} finally {
console.error("Databases contains finished: '" + req.getName() + "' is: '" + res.getContains() + "'");
}
}
else resolve(res.getContains());
});
});
}
Expand All @@ -66,10 +58,7 @@ export abstract class TypeDBStub {
return new Promise((resolve, reject) => {
this.stub().databases_all(req, (err, res) => {
if (err) reject(new TypeDBClientError(err));
else {
resolve(res.getNamesList().map(name => new TypeDBDatabaseImpl(name, this)));
console.error("Databases all finished: " + res.getNamesList());
}
else resolve(res.getNamesList().map(name => new TypeDBDatabaseImpl(name, this)));
})
})
}
Expand Down
12 changes: 5 additions & 7 deletions connection/TypeDBDatabaseImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
* under the License.
*/

import { Database } from "../api/connection/database/Database";
import { ErrorMessage } from "../common/errors/ErrorMessage";
import { TypeDBClientError } from "../common/errors/TypeDBClientError";
import { RequestBuilder } from "../common/rpc/RequestBuilder";
import { TypeDBStub } from "../common/rpc/TypeDBStub";
import {Database} from "../api/connection/database/Database";
import {ErrorMessage} from "../common/errors/ErrorMessage";
import {TypeDBClientError} from "../common/errors/TypeDBClientError";
import {RequestBuilder} from "../common/rpc/RequestBuilder";
import {TypeDBStub} from "../common/rpc/TypeDBStub";

export class TypeDBDatabaseImpl implements Database {

Expand All @@ -42,8 +42,6 @@ export class TypeDBDatabaseImpl implements Database {
delete(): Promise<void> {
if (!this._name) throw new TypeDBClientError(ErrorMessage.Client.MISSING_DB_NAME.message());
const req = RequestBuilder.Core.Database.deleteReq(this._name);
console.error("---- DELETING DATABASE START INIT PROMISE");
console.trace();
return this._stub.databaseDelete(req);
}

Expand Down
17 changes: 8 additions & 9 deletions connection/TypeDBDatabaseManagerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* under the License.
*/

import { Database } from "../api/connection/database/Database";
import { DatabaseManager } from "../api/connection/database/DatabaseManager";
import { ErrorMessage } from "../common/errors/ErrorMessage";
import { TypeDBClientError } from "../common/errors/TypeDBClientError";
import { RequestBuilder } from "../common/rpc/RequestBuilder";
import { TypeDBStub } from "../common/rpc/TypeDBStub";
import { TypeDBDatabaseImpl } from "./TypeDBDatabaseImpl";
import {Database} from "../api/connection/database/Database";
import {DatabaseManager} from "../api/connection/database/DatabaseManager";
import {ErrorMessage} from "../common/errors/ErrorMessage";
import {TypeDBClientError} from "../common/errors/TypeDBClientError";
import {RequestBuilder} from "../common/rpc/RequestBuilder";
import {TypeDBStub} from "../common/rpc/TypeDBStub";
import {TypeDBDatabaseImpl} from "./TypeDBDatabaseImpl";

export class TypeDBDatabaseManagerImpl implements DatabaseManager {

Expand All @@ -38,8 +38,7 @@ export class TypeDBDatabaseManagerImpl implements DatabaseManager {
public async get(name: string): Promise<Database> {
if (await this.contains(name)) {
return new TypeDBDatabaseImpl(name, this._stub);
}
else throw new TypeDBClientError(ErrorMessage.Client.DB_DOES_NOT_EXIST.message(name));
} else throw new TypeDBClientError(ErrorMessage.Client.DB_DOES_NOT_EXIST.message(name));
}

public create(name: string): Promise<void> {
Expand Down
25 changes: 11 additions & 14 deletions connection/TypeDBSessionImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
* under the License.
*/

import { Database } from "../api/connection/database/Database";
import { TypeDBOptions } from "../api/connection/TypeDBOptions";
import { SessionType, TypeDBSession } from "../api/connection/TypeDBSession";
import { TransactionType, TypeDBTransaction } from "../api/connection/TypeDBTransaction";
import { ErrorMessage } from "../common/errors/ErrorMessage";
import { TypeDBClientError } from "../common/errors/TypeDBClientError";
import { RequestBuilder } from "../common/rpc/RequestBuilder";
import { TypeDBStub } from "../common/rpc/TypeDBStub";
import { RequestTransmitter } from "../stream/RequestTransmitter";
import { CoreClient } from "./core/CoreClient";
import { TypeDBTransactionImpl } from "./TypeDBTransactionImpl";
import SESSION_CLOSED = ErrorMessage.Client.SESSION_CLOSED;
import {Database} from "../api/connection/database/Database";
import {TypeDBOptions} from "../api/connection/TypeDBOptions";
import {SessionType, TypeDBSession} from "../api/connection/TypeDBSession";
import {TransactionType, TypeDBTransaction} from "../api/connection/TypeDBTransaction";
import {ErrorMessage} from "../common/errors/ErrorMessage";
import {TypeDBClientError} from "../common/errors/TypeDBClientError";
import {RequestBuilder} from "../common/rpc/RequestBuilder";
import {TypeDBStub} from "../common/rpc/TypeDBStub";
import {RequestTransmitter} from "../stream/RequestTransmitter";
import {TypeDBTransactionImpl} from "./TypeDBTransactionImpl";
import {TypeDBClientImpl} from "./TypeDBClientImpl";
import SESSION_CLOSED = ErrorMessage.Client.SESSION_CLOSED;

export class TypeDBSessionImpl implements TypeDBSession {

Expand All @@ -57,9 +56,7 @@ export class TypeDBSessionImpl implements TypeDBSession {

async open(): Promise<void> {
const openReq = RequestBuilder.Session.openReq(this._databaseName, this._type.proto(), this._options.proto())
console.error("----> Opening session by doing databases.get()");
this._database = await this._client.databases.get(this._databaseName);
console.error("---------> databases.get() succeeded");
const start = (new Date()).getMilliseconds();
const res = await this._client.stub().sessionOpen(openReq);
const end = (new Date()).getMilliseconds(); // TODO will this work?
Expand Down
2 changes: 1 addition & 1 deletion dependencies/vaticle/artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def vaticle_typedb_artifacts():
artifact_name = "typedb-server-{platform}-{version}.{ext}",
tag_source = deployment["artifact.release"],
commit_source = deployment["artifact.snapshot"],
commit = "1a2b1baaa6c41dd8b6e9ce757527dbf04f6e7483",
tag = "2.6.1",
)

def vaticle_typedb_cluster_artifacts():
Expand Down

0 comments on commit d0f135f

Please sign in to comment.