Random instance selection (#136)

* wip

* revert some'

* revert more

* poor-man's integration test

* remove test

* fmt

* --workspace

* fix build

* fix integration test

* another stab

* log

* run after integration

* cargo test after integration

* revert

* revert more

* Refactor + clean up

* more clean up
This commit is contained in:
Mostafa Abdelraouf
2022-08-22 00:15:20 -05:00
committed by GitHub
parent 5948fef6cf
commit 5f5b5e2543
3 changed files with 46 additions and 83 deletions

View File

@@ -499,7 +499,6 @@ where
// The query router determines where the query is going to go,
// e.g. primary, replica, which shard.
let mut query_router = QueryRouter::new();
let mut round_robin = rand::random();
// Our custom protocol loop.
// We expect the client to either start a transaction with regular queries
@@ -631,12 +630,7 @@ where
// Grab a server from the pool.
let connection = match pool
.get(
query_router.shard(),
query_router.role(),
self.process_id,
round_robin,
)
.get(query_router.shard(), query_router.role(), self.process_id)
.await
{
Ok(conn) => {
@@ -655,8 +649,6 @@ where
let address = connection.1;
let server = &mut *reference;
round_robin += 1;
// Server is assigned to the client in case the client wants to
// cancel a query later.
server.claim(self.process_id, self.secret_key);