-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CCI] BaseConnectionPool
missing implementation of markAlive
and markDead
methods
#449
Changes from 5 commits
9da9e35
2d9df8e
8851b28
76e14b0
e320f72
510e970
4b05ae0
d8cbc63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,18 @@ test('API', (t) => { | |
let connection = pool.addConnection(href); | ||
t.same(pool.markDead(connection), pool); | ||
connection = pool.connections.find((c) => c.id === href); | ||
t.equal(connection.status, Connection.statuses.ALIVE); | ||
t.equal(connection.status, Connection.statuses.DEAD); | ||
t.end(); | ||
}); | ||
|
||
t.test('call markDead twice', (t) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you have to call markDead twice? Calling it once won't work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
#430 (review) |
||
const pool = new BaseConnectionPool({ Connection, sniffEnabled: true }); | ||
const href = 'http://localhost:9200/'; | ||
let connection = pool.addConnection(href); | ||
t.same(pool.markDead(connection), pool); | ||
t.same(pool.markDead(connection), pool); | ||
connection = pool.connections.find((c) => c.id === href); | ||
t.equal(connection.status, Connection.statuses.DEAD); | ||
t.end(); | ||
}); | ||
|
||
|
@@ -90,6 +101,31 @@ test('API', (t) => { | |
t.end(); | ||
}); | ||
|
||
t.test('call markAlive twice', (t) => { | ||
const pool = new BaseConnectionPool({ Connection, sniffEnabled: true }); | ||
const href = 'http://localhost:9200/'; | ||
let connection = pool.addConnection(href); | ||
t.same(pool.markAlive(connection), pool); | ||
t.same(pool.markAlive(connection), pool); | ||
connection = pool.connections.find((c) => c.id === href); | ||
t.equal(connection.status, Connection.statuses.ALIVE); | ||
t.end(); | ||
}); | ||
|
||
t.test('call markDead and markAlive', (t) => { | ||
const pool = new BaseConnectionPool({ Connection, sniffEnabled: true }); | ||
const href = 'http://localhost:9200/'; | ||
let connection = pool.addConnection(href); | ||
t.same(pool.markDead(connection), pool); | ||
t.equal(connection.status, Connection.statuses.DEAD); | ||
t.same(pool.markAlive(connection), pool); | ||
t.equal(connection.status, Connection.statuses.ALIVE); | ||
connection = pool.connections.find((c) => c.id === href); | ||
t.equal(connection.status, Connection.statuses.ALIVE); | ||
t.not(connection.status, Connection.statuses.DEAD); | ||
t.end(); | ||
}); | ||
|
||
t.test('getConnection should throw', (t) => { | ||
const pool = new BaseConnectionPool({ Connection }); | ||
const href = 'http://localhost:9200/'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd explain what the purpose of this call is, and ensure it fails when called twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By fail you mean a runtime error should be thrown when
markDead
is called on the same connection twice?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Unless there's a reason not to.
I still don't quite get how and when this API is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods are probably syntactical sugar for set status method (There only 2 valid connection Statuses: DEAD or ALIVE). I still don't understand why it must throw an error when you set status to DEAD twice though. Wouldn't that also introduce new business logic that will cause trouble for users who are marking a connection as DEAD again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also since we have
set status
in Connection class, it makes more sense to movemarkDead
andmarkAlive
from ConnectionPool into Connection since you can change the status of the connection directly anyway. That is instead ofclient.connectionPool.markAlive(connection)
, we will doconnection.markAlive()
. A lot more convenient and less confusing because it has nothing to do with ConnectionPool.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like an RFC to me
Should we implement this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move it to
Connection
for the reason mentioned above