Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit aae0b9a

Browse files
author
Paul Korzhyk
committed
Remove linRead
1 parent 43758d4 commit aae0b9a

21 files changed

+3940
-6403
lines changed

jest.config.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
module.exports = {
22
testEnvironment: "node",
33
transform: {
4-
".(ts|tsx)": "ts-jest"
4+
".ts": "ts-jest"
55
},
66
moduleFileExtensions: [
77
"ts",
8-
"tsx",
98
"js",
10-
"jsx",
119
],
12-
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)x?$",
10+
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)$",
1311
coverageDirectory: "coverage",
1412
collectCoverageFrom: [
15-
"src/**/*.{ts,tsx,js,jsx}",
16-
"!src/index.{ts,tsx,js,jsx}",
13+
"src/**/*.{ts,js}",
14+
"!src/index.{ts,js}",
1715
"!src/**/*.d.ts",
1816
],
1917
};

lib/client.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { DgraphClientStub } from "./clientStub";
22
import { Txn } from "./txn";
3-
import { LinRead, Operation, Payload } from "./types";
3+
import { Operation, Payload } from "./types";
44
export declare class DgraphClient {
55
private readonly clients;
6-
private readonly linRead;
76
private debugMode;
87
constructor(...clients: DgraphClientStub[]);
98
alter(op: Operation): Promise<Payload>;
109
newTxn(): Txn;
1110
setDebugMode(mode?: boolean): void;
1211
debug(msg: string): void;
13-
getLinRead(): LinRead;
14-
mergeLinReads(src?: LinRead | null): void;
1512
anyClient(): DgraphClientStub;
1613
}

lib/client.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1414
function step(op) {
1515
if (f) throw new TypeError("Generator is already executing.");
1616
while (_) try {
17-
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
18-
if (y = 0, t) op = [0, t.value];
17+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18+
if (y = 0, t) op = [op[0] & 2, t.value];
1919
switch (op[0]) {
2020
case 0: case 1: t = op; break;
2121
case 4: _.label++; return { value: op[1], done: false };
@@ -49,7 +49,6 @@ var DgraphClient = (function () {
4949
throw errors_1.ERR_NO_CLIENTS;
5050
}
5151
this.clients = clients;
52-
this.linRead = { ids: {} };
5352
}
5453
DgraphClient.prototype.alter = function (op) {
5554
return __awaiter(this, void 0, void 0, function () {
@@ -73,17 +72,6 @@ var DgraphClient = (function () {
7372
console.log(msg);
7473
}
7574
};
76-
DgraphClient.prototype.getLinRead = function () {
77-
var _this = this;
78-
var lr = { ids: {} };
79-
Object.keys(this.linRead.ids).forEach(function (group) {
80-
lr.ids[group] = _this.linRead.ids[group];
81-
});
82-
return lr;
83-
};
84-
DgraphClient.prototype.mergeLinReads = function (src) {
85-
util_1.mergeLinReads(this.linRead, src);
86-
};
8775
DgraphClient.prototype.anyClient = function () {
8876
return this.clients[Math.floor(Math.random() * this.clients.length)];
8977
};

lib/clientStub.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export declare class DgraphClientStub {
99
commit(ctx: TxnContext): Promise<TxnContext>;
1010
abort(ctx: TxnContext): Promise<TxnContext>;
1111
health(): Promise<string>;
12-
private callAPI<T>(path, config);
13-
private getURL(path);
12+
private callAPI;
13+
private getURL;
1414
}

lib/clientStub.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var errors_1 = require("./errors");
55
var DgraphClientStub = (function () {
66
function DgraphClientStub(addr) {
77
if (addr == null) {
8-
this.addr = "localhost:8080";
8+
this.addr = "http://localhost:8080";
99
}
1010
else {
1111
this.addr = addr;
@@ -35,9 +35,6 @@ var DgraphClientStub = (function () {
3535
if (req.vars != null) {
3636
headers["X-Dgraph-Vars"] = JSON.stringify(req.vars);
3737
}
38-
if (req.linRead != null) {
39-
headers["X-Dgraph-LinRead"] = JSON.stringify(req.linRead.ids);
40-
}
4138
return this.callAPI("query" + (req.startTs == null ? "" : "/" + req.startTs), {
4239
method: "POST",
4340
body: req.query,

lib/errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ var CustomError = (function (_super) {
2020
var _this = _super.call(this, message) || this;
2121
_this.name = _newTarget.name;
2222
var setPrototypeOf = Object.setPrototypeOf;
23-
setPrototypeOf
23+
setPrototypeOf != null
2424
? setPrototypeOf(_this, _newTarget.prototype)
2525
: (_this.__proto__ = _newTarget.prototype);
2626
var captureStackTrace = Error.captureStackTrace;
27-
if (captureStackTrace) {
27+
if (captureStackTrace != null) {
2828
captureStackTrace(_this, _this.constructor);
2929
}
3030
return _this;

lib/txn.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export declare class Txn {
1313
mutate(mu: Mutation): Promise<Assigned>;
1414
commit(): Promise<void>;
1515
discard(): Promise<void>;
16-
private mergeContext(src?);
16+
private mergeContext;
1717
}

lib/txn.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1414
function step(op) {
1515
if (f) throw new TypeError("Generator is already executing.");
1616
while (_) try {
17-
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
18-
if (y = 0, t) op = [0, t.value];
17+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18+
if (y = 0, t) op = [op[0] & 2, t.value];
1919
switch (op[0]) {
2020
case 0: case 1: t = op; break;
2121
case 4: _.label++; return { value: op[1], done: false };
@@ -42,7 +42,7 @@ var Txn = (function () {
4242
this.finished = false;
4343
this.mutated = false;
4444
this.dc = dc;
45-
this.ctx = { start_ts: 0, lin_read: this.dc.getLinRead() };
45+
this.ctx = { start_ts: 0 };
4646
}
4747
Txn.prototype.query = function (q) {
4848
return this.queryWithVars(q, null);
@@ -60,7 +60,6 @@ var Txn = (function () {
6060
req = {
6161
query: q,
6262
startTs: this.ctx.start_ts,
63-
linRead: this.ctx.lin_read,
6463
};
6564
if (vars != null) {
6665
varsObj_1 = {};
@@ -182,11 +181,10 @@ var Txn = (function () {
182181
});
183182
};
184183
Txn.prototype.mergeContext = function (src) {
184+
var _a;
185185
if (src == null) {
186186
return;
187187
}
188-
util_1.mergeLinReads(this.ctx.lin_read, src.lin_read);
189-
this.dc.mergeLinReads(src.lin_read);
190188
if (this.ctx.start_ts === 0) {
191189
this.ctx.start_ts = src.start_ts;
192190
}
@@ -201,7 +199,6 @@ var Txn = (function () {
201199
(_a = this.ctx.keys).push.apply(_a, src.keys);
202200
}
203201
}
204-
var _a;
205202
};
206203
return Txn;
207204
}());

lib/types.d.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export interface Request {
1212
[k: string]: string;
1313
} | null;
1414
startTs?: number | null;
15-
linRead?: LinRead | null;
1615
}
1716
export interface Response {
1817
data: {};
@@ -32,24 +31,18 @@ export interface Assigned {
3231
}
3332
export interface AssignedData {
3433
uids: {
35-
[k: string]: number;
34+
[k: string]: string;
3635
};
3736
}
3837
export interface Extensions {
3938
server_latency: Latency;
4039
txn: TxnContext;
4140
}
42-
export interface LinRead {
43-
ids: {
44-
[k: string]: number;
45-
};
46-
}
4741
export interface TxnContext {
4842
start_ts: number;
4943
commit_ts?: number | null;
5044
aborted?: boolean | null;
5145
keys?: string[] | null;
52-
lin_read: LinRead;
5346
}
5447
export interface Latency {
5548
parsing_ns?: number | null;

lib/util.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { LinRead } from "./types";
2-
export declare function mergeLinReads(target: LinRead, src?: LinRead | null): LinRead;
31
export declare function isAbortedError(error: any): boolean;
42
export declare function isConflictError(error: any): boolean;
53
export declare function stringifyMessage(msg: object): string;

0 commit comments

Comments
 (0)