mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-25 10:06:28 +00:00
Compare commits
2 Commits
circleci_g
...
circleci_n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0ae53484f | ||
|
|
a1690a76c5 |
@@ -179,6 +179,7 @@ primary_reads_enabled = true
|
|||||||
# `random`: picks a shard at random
|
# `random`: picks a shard at random
|
||||||
# `random_healthy`: picks a shard at random favoring shards with the least number of recent errors
|
# `random_healthy`: picks a shard at random favoring shards with the least number of recent errors
|
||||||
# `shard_<number>`: e.g. shard_0, shard_4, etc. picks a specific shard, everytime
|
# `shard_<number>`: e.g. shard_0, shard_4, etc. picks a specific shard, everytime
|
||||||
|
# `fail`: fails to pick up shard. (require explicit shard setup)
|
||||||
# default_shard = "shard_0"
|
# default_shard = "shard_0"
|
||||||
|
|
||||||
# So what if you wanted to implement a different hashing function,
|
# So what if you wanted to implement a different hashing function,
|
||||||
|
|||||||
@@ -773,6 +773,7 @@ pub enum DefaultShard {
|
|||||||
Shard(usize),
|
Shard(usize),
|
||||||
Random,
|
Random,
|
||||||
RandomHealthy,
|
RandomHealthy,
|
||||||
|
Fail,
|
||||||
}
|
}
|
||||||
impl Default for DefaultShard {
|
impl Default for DefaultShard {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -787,6 +788,7 @@ impl serde::Serialize for DefaultShard {
|
|||||||
}
|
}
|
||||||
DefaultShard::Random => serializer.serialize_str("random"),
|
DefaultShard::Random => serializer.serialize_str("random"),
|
||||||
DefaultShard::RandomHealthy => serializer.serialize_str("random_healthy"),
|
DefaultShard::RandomHealthy => serializer.serialize_str("random_healthy"),
|
||||||
|
DefaultShard::Fail => serializer.serialize_str("fail"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -804,6 +806,7 @@ impl<'de> serde::Deserialize<'de> for DefaultShard {
|
|||||||
match s.as_str() {
|
match s.as_str() {
|
||||||
"random" => Ok(DefaultShard::Random),
|
"random" => Ok(DefaultShard::Random),
|
||||||
"random_healthy" => Ok(DefaultShard::RandomHealthy),
|
"random_healthy" => Ok(DefaultShard::RandomHealthy),
|
||||||
|
"fail" => Ok(DefaultShard::Fail),
|
||||||
_ => Err(serde::de::Error::custom(
|
_ => Err(serde::de::Error::custom(
|
||||||
"invalid value for no_shard_specified_behavior",
|
"invalid value for no_shard_specified_behavior",
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ pub enum Error {
|
|||||||
QueryRouterError(String),
|
QueryRouterError(String),
|
||||||
InvalidShardId(usize),
|
InvalidShardId(usize),
|
||||||
PreparedStatementError,
|
PreparedStatementError,
|
||||||
|
NoShardSelected,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
|||||||
@@ -720,6 +720,7 @@ impl ConnectionPool {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
DefaultShard::Fail => return Err(Error::NoShardSelected),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user