Merge pull request #137 from simon-mo/list-request-impl

Implement the input parameters for snapshotter::list
This commit is contained in:
Maksym Pavlenko 2023-04-23 19:28:03 +02:00 committed by GitHub
commit c54a467f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -100,7 +100,12 @@ impl snapshots::Snapshotter for Example {
}
type InfoStream = EmptyStream;
async fn list(&self) -> Result<Self::InfoStream, Self::Error> {
async fn list(
&self,
snapshotter: String,
filters: Vec<String>,
) -> Result<Self::InfoStream, Self::Error> {
info!("List: snapshotter={}, filters={:?}", snapshotter, filters);
// Returns no snapshots.
Ok(EmptyStream)
}

View File

@ -283,5 +283,9 @@ pub trait Snapshotter: Send + Sync + 'static {
/// })
/// }
/// ```
async fn list(&self) -> Result<Self::InfoStream, Self::Error>;
async fn list(
&self,
snapshotter: String,
filters: Vec<String>,
) -> Result<Self::InfoStream, Self::Error>;
}

View File

@ -158,11 +158,12 @@ impl<S: Snapshotter> Snapshots for Wrapper<S> {
async fn list(
&self,
_request: tonic::Request<ListSnapshotsRequest>,
request: tonic::Request<ListSnapshotsRequest>,
) -> Result<tonic::Response<Self::ListStream>, tonic::Status> {
let request = request.into_inner();
let sn = self.snapshotter.clone();
let output = async_stream::try_stream! {
let walk_stream = sn.list().await?;
let walk_stream = sn.list(request.snapshotter, request.filters).await?;
pin_utils::pin_mut!(walk_stream);
let mut infos = Vec::<Info>::new();
while let Some(info) = walk_stream.next().await {