Merge pull request #137 from simon-mo/list-request-impl
Implement the input parameters for snapshotter::list
This commit is contained in:
commit
c54a467f16
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue