feat: add all_shards in admin_getFileLocation (#138)

This commit is contained in:
MiniFrenchBread 2024-07-22 11:28:05 +08:00 committed by GitHub
parent 085c34beb0
commit a782cf2d54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -40,5 +40,9 @@ pub trait Rpc {
async fn get_peers(&self) -> RpcResult<HashMap<String, PeerInfo>>;
#[method(name = "getFileLocation")]
async fn get_file_location(&self, tx_seq: u64) -> RpcResult<Option<Vec<LocationInfo>>>;
async fn get_file_location(
&self,
tx_seq: u64,
all_shards: bool,
) -> RpcResult<Option<Vec<LocationInfo>>>;
}

View File

@ -185,7 +185,11 @@ impl RpcServer for RpcServerImpl {
.collect())
}
async fn get_file_location(&self, tx_seq: u64) -> RpcResult<Option<Vec<LocationInfo>>> {
async fn get_file_location(
&self,
tx_seq: u64,
all_shards: bool,
) -> RpcResult<Option<Vec<LocationInfo>>> {
let tx = match self.ctx.log_store.get_tx_by_seq_number(tx_seq).await? {
Some(tx) => tx,
None => {
@ -221,7 +225,7 @@ impl RpcServer for RpcServerImpl {
shard_config: shard_config.unwrap(),
})
.collect();
if all_shards_available(info.iter().map(|info| info.shard_config).collect()) {
if all_shards && all_shards_available(info.iter().map(|info| info.shard_config).collect()) {
Ok(Some(info))
} else {
Ok(None)