Skip to content

Commit b27fa91

Browse files
committed
Rename Connection#sync() to #flush()
Later better describes the logic of the function. There is no sync operation, only flushing of the queued messages/chunks. Responses arrive asynchronously are de-chunked and forwarded for the corresponding observers.
1 parent 1479707 commit b27fa91

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

src/v1/internal/connector.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class Connection {
278278
this._packer.packStruct(INIT, [this._packable(clientName), this._packable(token)],
279279
(err) => this._handleFatalError(err));
280280
this._chunker.messageBoundary();
281-
this.sync();
281+
this.flush();
282282
}
283283
}
284284

@@ -321,7 +321,7 @@ class Connection {
321321

322322
/**
323323
* Send a RESET-message to the database. Mutes failure handling.
324-
* Message is immediately flushed to the network. Separate {@link Connection#sync()} call is not required.
324+
* Message is immediately flushed to the network. Separate {@link Connection#flush()} call is not required.
325325
* @return {Promise<void>} promise resolved when SUCCESS-message response arrives, or failed when other response messages arrives.
326326
*/
327327
resetAndFlush() {
@@ -371,7 +371,7 @@ class Connection {
371371
if (queued) {
372372
this._packer.packStruct(RESET, [], err => this._handleFatalError(err));
373373
this._chunker.messageBoundary();
374-
this.sync();
374+
this.flush();
375375
}
376376
}
377377

@@ -412,10 +412,9 @@ class Connection {
412412
}
413413

414414
/**
415-
* Synchronize - flush all queued outgoing messages and route their responses
416-
* to their respective handlers.
415+
* Flush all queued outgoing messages.
417416
*/
418-
sync() {
417+
flush() {
419418
this._chunker.flush();
420419
}
421420

src/v1/session.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Session {
7575
connectionHolder.getConnection(streamObserver).then(connection => {
7676
statementRunner(connection, streamObserver);
7777
connection.pullAll(streamObserver);
78-
connection.sync();
78+
connection.flush();
7979
}).catch(error => streamObserver.onError(error));
8080
} else {
8181
streamObserver.onError(newError('Statements cannot be run directly on a ' +

src/v1/transaction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let _states = {
162162
connectionHolder.getConnection(observer).then(conn => {
163163
conn.run(statement, parameters || {}, observer);
164164
conn.pullAll(observer);
165-
conn.sync();
165+
conn.flush();
166166
}).catch(error => observer.onError(error));
167167

168168
return _newRunResult(observer, statement, parameters, () => observer.serverMetadata());
@@ -240,7 +240,7 @@ function _runPullAll(msg, connectionHolder, observer) {
240240
connectionHolder.getConnection(observer).then(conn => {
241241
conn.run(msg, {}, observer);
242242
conn.pullAll(observer);
243-
conn.sync();
243+
conn.flush();
244244
}).catch(error => observer.onError(error));
245245

246246
// for commit & rollback we need result that uses real connection holder and notifies it when

test/internal/connector.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('connector', () => {
7373
},
7474
onError: console.log
7575
});
76-
connection.sync();
76+
connection.flush();
7777

7878
});
7979

@@ -94,7 +94,7 @@ describe('connector', () => {
9494
done();
9595
}
9696
});
97-
connection.sync();
97+
connection.flush();
9898
});
9999

100100
it('should use DummyChannel to read what gets written', done => {
@@ -113,7 +113,7 @@ describe('connector', () => {
113113
// When
114114
connection.initialize('mydriver/0.0.0', basicAuthToken());
115115
connection.run('RETURN 1', {});
116-
connection.sync();
116+
connection.flush();
117117
expect(observer.instance.toHex()).toBe('00 44 b2 01 8e 6d 79 64 72 69 76 65 72 2f 30 2e 30 2e 30 a3 86 73 63 68 65 6d 65 85 62 61 73 69 63 89 70 72 69 6e 63 69 70 61 6c 85 6e 65 6f 34 6a 8b 63 72 65 64 65 6e 74 69 61 6c 73 88 70 61 73 73 77 6f 72 64 00 00 00 0c b2 10 88 52 45 54 55 52 4e 20 31 a0 00 00 ');
118118
done();
119119
});
@@ -135,7 +135,7 @@ describe('connector', () => {
135135
done();
136136
}
137137
});
138-
connection.sync();
138+
connection.flush();
139139

140140
});
141141

test/internal/fake-connection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class FakeConnection {
3131
this.creationTimestamp = Date.now();
3232

3333
this.resetInvoked = 0;
34-
this.syncInvoked = 0;
34+
this.flushInvoked = 0;
3535
this.releaseInvoked = 0;
3636
this.initializationInvoked = 0;
3737
this.seenStatements = [];
@@ -58,8 +58,8 @@ export default class FakeConnection {
5858
return Promise.resolve();
5959
}
6060

61-
sync() {
62-
this.syncInvoked++;
61+
flush() {
62+
this.flushInvoked++;
6363
}
6464

6565
_release() {

0 commit comments

Comments
 (0)