chore(snix): configure rustfmt for edition 2024 crates
Add a rustfmt.toml to all the crates that are already migrated to edition 2024. Initially proposed in cl/30341. Fixes #115. Change-Id: I9f58cd45e38fec3acbb077492d5402e30560996b Reviewed-on: https://cl.snix.dev/c/snix/+/30343 Tested-by: besadii Autosubmit: Florian Klink <flokli@flokli.de> Reviewed-by: Domen Kožar <domen@cachix.org>
This commit is contained in:
parent
b39d7abc5a
commit
98703f7a41
65 changed files with 222 additions and 197 deletions
2
snix/castore/rustfmt.toml
Normal file
2
snix/castore/rustfmt.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# FUTUREWORK: move to .. once all crates are migrated (#114)
|
||||
edition = "2024"
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
use clap::{Parser, Subcommand};
|
||||
#[cfg(any(feature = "fuse", feature = "virtiofs"))]
|
||||
use snix_castore::B3Digest;
|
||||
use snix_castore::Node;
|
||||
#[cfg(feature = "fs")]
|
||||
use snix_castore::fs::SnixStoreFs;
|
||||
#[cfg(feature = "fuse")]
|
||||
use snix_castore::fs::fuse::FuseDaemon;
|
||||
#[cfg(feature = "virtiofs")]
|
||||
use snix_castore::fs::virtiofs::start_virtiofs_daemon;
|
||||
#[cfg(feature = "fs")]
|
||||
use snix_castore::fs::SnixStoreFs;
|
||||
use snix_castore::import::{archive::ingest_archive, fs::ingest_path};
|
||||
#[cfg(any(feature = "fuse", feature = "virtiofs"))]
|
||||
use snix_castore::B3Digest;
|
||||
use snix_castore::Node;
|
||||
use std::error::Error;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use futures::{ready, TryStreamExt};
|
||||
use futures::{TryStreamExt, ready};
|
||||
use pin_project_lite::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncSeekExt};
|
||||
use tokio_stream::StreamExt;
|
||||
|
|
@ -259,8 +259,8 @@ mod test {
|
|||
};
|
||||
|
||||
use crate::{
|
||||
blobservice::{chunked_reader::ChunkedReader, BlobService, MemoryBlobService},
|
||||
B3Digest,
|
||||
blobservice::{BlobService, MemoryBlobService, chunked_reader::ChunkedReader},
|
||||
};
|
||||
use hex_literal::hex;
|
||||
use tokio::io::{AsyncReadExt, AsyncSeekExt};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use url::Url;
|
||||
|
||||
use crate::composition::{
|
||||
with_registry, CompositionContext, DeserializeWithRegistry, ServiceBuilder, REG,
|
||||
CompositionContext, DeserializeWithRegistry, REG, ServiceBuilder, with_registry,
|
||||
};
|
||||
|
||||
use super::BlobService;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use super::{BlobReader, BlobService, BlobWriter, ChunkedReader};
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::{
|
||||
proto::{self, stat_blob_response::ChunkMeta},
|
||||
B3Digest,
|
||||
proto::{self, stat_blob_response::ChunkMeta},
|
||||
};
|
||||
use futures::sink::SinkExt;
|
||||
use std::{
|
||||
|
|
@ -13,13 +13,13 @@ use std::{
|
|||
};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::task::JoinHandle;
|
||||
use tokio_stream::{wrappers::ReceiverStream, StreamExt};
|
||||
use tokio_stream::{StreamExt, wrappers::ReceiverStream};
|
||||
use tokio_util::{
|
||||
io::{CopyToBytes, SinkWriter},
|
||||
sync::PollSender,
|
||||
};
|
||||
use tonic::{async_trait, Code, Status};
|
||||
use tracing::{instrument, Instrument as _};
|
||||
use tonic::{Code, Status, async_trait};
|
||||
use tracing::{Instrument as _, instrument};
|
||||
|
||||
/// Connects to a (remote) snix-store BlobService over gRPC.
|
||||
#[derive(Clone)]
|
||||
|
|
@ -323,14 +323,14 @@ mod tests {
|
|||
|
||||
use tempfile::TempDir;
|
||||
use tokio::net::UnixListener;
|
||||
use tokio_retry::strategy::ExponentialBackoff;
|
||||
use tokio_retry::Retry;
|
||||
use tokio_retry::strategy::ExponentialBackoff;
|
||||
use tokio_stream::wrappers::UnixListenerStream;
|
||||
|
||||
use crate::blobservice::MemoryBlobService;
|
||||
use crate::fixtures;
|
||||
use crate::proto::blob_service_client::BlobServiceClient;
|
||||
use crate::proto::GRPCBlobServiceWrapper;
|
||||
use crate::proto::blob_service_client::BlobServiceClient;
|
||||
|
||||
use super::BlobService;
|
||||
use super::GRPCBlobService;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ use std::io;
|
|||
use auto_impl::auto_impl;
|
||||
use tonic::async_trait;
|
||||
|
||||
use crate::B3Digest;
|
||||
use crate::composition::{Registry, ServiceBuilder};
|
||||
use crate::proto::stat_blob_response::ChunkMeta;
|
||||
use crate::B3Digest;
|
||||
|
||||
mod chunked_reader;
|
||||
mod combinator;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
collections::{hash_map, HashMap},
|
||||
collections::{HashMap, hash_map},
|
||||
io::{self, Cursor},
|
||||
pin::pin,
|
||||
sync::Arc,
|
||||
|
|
@ -9,19 +9,19 @@ use std::{
|
|||
use data_encoding::HEXLOWER;
|
||||
use fastcdc::v2020::AsyncStreamCDC;
|
||||
use futures::Future;
|
||||
use object_store::{path::Path, ObjectStore};
|
||||
use object_store::{ObjectStore, path::Path};
|
||||
use pin_project_lite::pin_project;
|
||||
use prost::Message;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
|
||||
use tokio_stream::StreamExt;
|
||||
use tonic::async_trait;
|
||||
use tracing::{debug, instrument, trace, Level};
|
||||
use tracing::{Level, debug, instrument, trace};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
composition::{CompositionContext, ServiceBuilder},
|
||||
proto::{stat_blob_response::ChunkMeta, StatBlobResponse},
|
||||
B3Digest, B3HashingReader, Error,
|
||||
composition::{CompositionContext, ServiceBuilder},
|
||||
proto::{StatBlobResponse, stat_blob_response::ChunkMeta},
|
||||
};
|
||||
|
||||
use super::{BlobReader, BlobService, BlobWriter, ChunkedReader};
|
||||
|
|
|
|||
|
|
@ -31,21 +31,25 @@ pub fn blob_services(#[case] blob_service: impl BlobService) {}
|
|||
#[apply(blob_services)]
|
||||
#[tokio::test]
|
||||
async fn has_nonexistent_false(blob_service: impl BlobService) {
|
||||
assert!(!blob_service
|
||||
.has(&BLOB_A_DIGEST)
|
||||
.await
|
||||
.expect("must not fail"));
|
||||
assert!(
|
||||
!blob_service
|
||||
.has(&BLOB_A_DIGEST)
|
||||
.await
|
||||
.expect("must not fail")
|
||||
);
|
||||
}
|
||||
|
||||
/// Using [BlobService::chunks] on a non-existing blob should return Ok(None)
|
||||
#[apply(blob_services)]
|
||||
#[tokio::test]
|
||||
async fn chunks_nonexistent_false(blob_service: impl BlobService) {
|
||||
assert!(blob_service
|
||||
.chunks(&BLOB_A_DIGEST)
|
||||
.await
|
||||
.expect("must be ok")
|
||||
.is_none());
|
||||
assert!(
|
||||
blob_service
|
||||
.chunks(&BLOB_A_DIGEST)
|
||||
.await
|
||||
.expect("must be ok")
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: do tests with `chunks`
|
||||
|
|
@ -54,11 +58,13 @@ async fn chunks_nonexistent_false(blob_service: impl BlobService) {
|
|||
#[apply(blob_services)]
|
||||
#[tokio::test]
|
||||
async fn not_found_read(blob_service: impl BlobService) {
|
||||
assert!(blob_service
|
||||
.open_read(&BLOB_A_DIGEST)
|
||||
.await
|
||||
.expect("must not fail")
|
||||
.is_none())
|
||||
assert!(
|
||||
blob_service
|
||||
.open_read(&BLOB_A_DIGEST)
|
||||
.await
|
||||
.expect("must not fail")
|
||||
.is_none()
|
||||
)
|
||||
}
|
||||
|
||||
/// Put a blob in the store, check has, get it back.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::blobservice::{BlobService, MemoryBlobService};
|
||||
use crate::proto::blob_service_client::BlobServiceClient;
|
||||
use crate::proto::GRPCBlobServiceWrapper;
|
||||
use crate::proto::blob_service_client::BlobServiceClient;
|
||||
use crate::{blobservice::GRPCBlobService, proto::blob_service_server::BlobServiceServer};
|
||||
use hyper_util::rt::TokioIo;
|
||||
use tonic::transport::{Endpoint, Server, Uri};
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@
|
|||
//! This behavior might change in the future.
|
||||
|
||||
use erased_serde::deserialize;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::FutureExt;
|
||||
use futures::future::BoxFuture;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde_tagged::de::{BoxFnSeed, SeedFactory};
|
||||
use serde_tagged::util::TagString;
|
||||
|
|
@ -152,7 +152,7 @@ impl<'r, 'de: 'r, T: 'static> SeedFactory<'de, TagString<'de>> for RegistryWithF
|
|||
// using find() and not get() because of https://github.com/rust-lang/rust/issues/80389
|
||||
let seed: &Box<dyn Any + Sync> = self
|
||||
.0
|
||||
.0
|
||||
.0
|
||||
.iter()
|
||||
.find(|(k, _)| *k == &(TypeId::of::<T>(), tag.as_ref()))
|
||||
.ok_or_else(|| serde::de::Error::custom(format!("Unknown type: {}", tag)))?
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ use data_encoding::HEXLOWER;
|
|||
use futures::stream::BoxStream;
|
||||
use prost::Message;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{serde_as, DurationSeconds};
|
||||
use serde_with::{DurationSeconds, serde_as};
|
||||
use std::sync::Arc;
|
||||
use tonic::async_trait;
|
||||
use tracing::{instrument, trace, warn};
|
||||
|
||||
use super::{
|
||||
utils::traverse_directory, Directory, DirectoryPutter, DirectoryService, SimplePutter,
|
||||
Directory, DirectoryPutter, DirectoryService, SimplePutter, utils::traverse_directory,
|
||||
};
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::{proto, B3Digest, Error};
|
||||
use crate::{B3Digest, Error, proto};
|
||||
|
||||
/// There should not be more than 10 MiB in a single cell.
|
||||
/// <https://cloud.google.com/bigtable/docs/schema-design#cells>
|
||||
|
|
@ -79,7 +79,7 @@ impl BigtableDirectoryService {
|
|||
|
||||
use async_process::{Command, Stdio};
|
||||
use tempfile::TempDir;
|
||||
use tokio_retry::{strategy::ExponentialBackoff, Retry};
|
||||
use tokio_retry::{Retry, strategy::ExponentialBackoff};
|
||||
|
||||
let tmpdir = TempDir::new().unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use futures::stream::BoxStream;
|
||||
use futures::StreamExt;
|
||||
use futures::TryFutureExt;
|
||||
use futures::TryStreamExt;
|
||||
use futures::stream::BoxStream;
|
||||
use tonic::async_trait;
|
||||
use tracing::{instrument, trace};
|
||||
|
||||
use super::{Directory, DirectoryGraph, DirectoryService, RootToLeavesValidator, SimplePutter};
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::directoryservice::DirectoryPutter;
|
||||
use crate::B3Digest;
|
||||
use crate::Error;
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::directoryservice::DirectoryPutter;
|
||||
|
||||
/// Asks near first, if not found, asks far.
|
||||
/// If found in there, returns it, and *inserts* it into
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use petgraph::{
|
||||
Direction, Incoming,
|
||||
graph::{DiGraph, NodeIndex},
|
||||
visit::{Bfs, DfsPostOrder, EdgeRef, IntoNodeIdentifiers, Walker},
|
||||
Direction, Incoming,
|
||||
};
|
||||
use tracing::instrument;
|
||||
|
||||
use super::order_validator::{LeavesToRootValidator, OrderValidator, RootToLeavesValidator};
|
||||
use crate::{path::PathComponent, B3Digest, Directory, Node};
|
||||
use crate::{B3Digest, Directory, Node, path::PathComponent};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use url::Url;
|
||||
|
||||
use crate::composition::{
|
||||
with_registry, CompositionContext, DeserializeWithRegistry, ServiceBuilder, REG,
|
||||
CompositionContext, DeserializeWithRegistry, REG, ServiceBuilder, with_registry,
|
||||
};
|
||||
|
||||
use super::DirectoryService;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use tokio::spawn;
|
|||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tokio::task::JoinHandle;
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tonic::{async_trait, Code, Status};
|
||||
use tracing::{instrument, warn, Instrument as _};
|
||||
use tonic::{Code, Status, async_trait};
|
||||
use tracing::{Instrument as _, instrument, warn};
|
||||
|
||||
/// Connects to a (remote) snix-store DirectoryService over gRPC.
|
||||
#[derive(Clone)]
|
||||
|
|
@ -320,13 +320,13 @@ mod tests {
|
|||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use tokio::net::UnixListener;
|
||||
use tokio_retry::{strategy::ExponentialBackoff, Retry};
|
||||
use tokio_retry::{Retry, strategy::ExponentialBackoff};
|
||||
use tokio_stream::wrappers::UnixListenerStream;
|
||||
|
||||
use crate::{
|
||||
directoryservice::{DirectoryService, GRPCDirectoryService, MemoryDirectoryService},
|
||||
fixtures,
|
||||
proto::{directory_service_client::DirectoryServiceClient, GRPCDirectoryServiceWrapper},
|
||||
proto::{GRPCDirectoryServiceWrapper, directory_service_client::DirectoryServiceClient},
|
||||
};
|
||||
|
||||
/// This ensures connecting via gRPC works as expected.
|
||||
|
|
@ -383,10 +383,12 @@ mod tests {
|
|||
GRPCDirectoryService::from_client("test-instance".into(), client)
|
||||
};
|
||||
|
||||
assert!(grpc_client
|
||||
.get(&fixtures::DIRECTORY_A.digest())
|
||||
.await
|
||||
.expect("must not fail")
|
||||
.is_none())
|
||||
assert!(
|
||||
grpc_client
|
||||
.get(&fixtures::DIRECTORY_A.digest())
|
||||
.await
|
||||
.expect("must not fail")
|
||||
.is_none()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
use std::collections::hash_map;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map;
|
||||
use std::sync::Arc;
|
||||
|
||||
use data_encoding::HEXLOWER;
|
||||
use futures::future::Either;
|
||||
use futures::stream::BoxStream;
|
||||
use futures::SinkExt;
|
||||
use futures::StreamExt;
|
||||
use futures::TryFutureExt;
|
||||
use futures::TryStreamExt;
|
||||
use object_store::{path::Path, ObjectStore};
|
||||
use futures::future::Either;
|
||||
use futures::stream::BoxStream;
|
||||
use object_store::{ObjectStore, path::Path};
|
||||
use prost::Message;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio_util::codec::LengthDelimitedCodec;
|
||||
use tonic::async_trait;
|
||||
use tracing::{instrument, trace, warn, Level};
|
||||
use tracing::{Level, instrument, trace, warn};
|
||||
use url::Url;
|
||||
|
||||
use super::{
|
||||
|
|
@ -22,7 +22,7 @@ use super::{
|
|||
RootToLeavesValidator,
|
||||
};
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::{proto, B3Digest, Error, Node};
|
||||
use crate::{B3Digest, Error, Node, proto};
|
||||
|
||||
/// Stores directory closures in an object store.
|
||||
/// Notably, this makes use of the option to disallow accessing child directories except when
|
||||
|
|
@ -49,7 +49,7 @@ fn derive_dirs_path(base_path: &Path, digest: &B3Digest) -> Path {
|
|||
|
||||
#[allow(clippy::identity_op)]
|
||||
const MAX_FRAME_LENGTH: usize = 1 * 1024 * 1024 * 1000; // 1 MiB
|
||||
//
|
||||
//
|
||||
impl ObjectStoreDirectoryService {
|
||||
/// Constructs a new [ObjectStoreDirectoryService] from a [Url] supported by
|
||||
/// [object_store].
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ impl OrderValidator for LeavesToRootValidator {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{LeavesToRootValidator, RootToLeavesValidator};
|
||||
use crate::directoryservice::order_validator::OrderValidator;
|
||||
use crate::directoryservice::Directory;
|
||||
use crate::directoryservice::order_validator::OrderValidator;
|
||||
use crate::fixtures::{DIRECTORY_A, DIRECTORY_B, DIRECTORY_C};
|
||||
use rstest::rstest;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ use tonic::async_trait;
|
|||
use tracing::{instrument, warn};
|
||||
|
||||
use super::{
|
||||
traverse_directory, Directory, DirectoryGraph, DirectoryPutter, DirectoryService,
|
||||
LeavesToRootValidator,
|
||||
Directory, DirectoryGraph, DirectoryPutter, DirectoryService, LeavesToRootValidator,
|
||||
traverse_directory,
|
||||
};
|
||||
use crate::{
|
||||
B3Digest, Error,
|
||||
composition::{CompositionContext, ServiceBuilder},
|
||||
proto, B3Digest, Error,
|
||||
proto,
|
||||
};
|
||||
|
||||
const DIRECTORY_TABLE: TableDefinition<[u8; B3Digest::LENGTH], Vec<u8>> =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::directoryservice::{DirectoryService, GRPCDirectoryService};
|
||||
use crate::proto::directory_service_client::DirectoryServiceClient;
|
||||
use crate::proto::GRPCDirectoryServiceWrapper;
|
||||
use crate::proto::directory_service_client::DirectoryServiceClient;
|
||||
use crate::{
|
||||
directoryservice::MemoryDirectoryService,
|
||||
proto::directory_service_server::DirectoryServiceServer,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{directoryservice::DirectoryService, Error, Node, Path};
|
||||
use crate::{Error, Node, Path, directoryservice::DirectoryService};
|
||||
use tracing::{instrument, warn};
|
||||
|
||||
/// This descends from a (root) node to the given (sub)path, returning the Node
|
||||
|
|
@ -51,9 +51,8 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
directoryservice,
|
||||
Node, PathBuf, directoryservice,
|
||||
fixtures::{DIRECTORY_COMPLICATED, DIRECTORY_WITH_KEEP, EMPTY_BLOB_DIGEST},
|
||||
Node, PathBuf,
|
||||
};
|
||||
|
||||
use super::descend_to;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use tokio::task::JoinError;
|
|||
use tonic::Status;
|
||||
|
||||
use crate::{
|
||||
path::{PathComponent, PathComponentError},
|
||||
SymlinkTargetError,
|
||||
path::{PathComponent, PathComponentError},
|
||||
};
|
||||
|
||||
/// Errors related to communication with the store.
|
||||
|
|
|
|||
|
|
@ -8,17 +8,18 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
use tempfile::TempDir;
|
||||
use tokio_stream::{wrappers::ReadDirStream, StreamExt};
|
||||
use tokio_stream::{StreamExt, wrappers::ReadDirStream};
|
||||
|
||||
use super::FuseDaemon;
|
||||
use crate::{
|
||||
Node,
|
||||
blobservice::{BlobService, MemoryBlobService},
|
||||
directoryservice::{DirectoryService, MemoryDirectoryService},
|
||||
fixtures, Node,
|
||||
fixtures,
|
||||
};
|
||||
use crate::{
|
||||
fs::{SnixStoreFs, XATTR_NAME_BLOB_DIGEST, XATTR_NAME_DIRECTORY_DIGEST},
|
||||
PathComponent,
|
||||
fs::{SnixStoreFs, XATTR_NAME_BLOB_DIGEST, XATTR_NAME_DIRECTORY_DIGEST},
|
||||
};
|
||||
|
||||
const BLOB_A_NAME: &str = "00000000000000000000000000000000-test";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//! about inodes, which present snix-castore nodes in a filesystem.
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::{path::PathComponent, B3Digest, Node};
|
||||
use crate::{B3Digest, Node, path::PathComponent};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum InodeData {
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ use self::{
|
|||
inodes::{DirectoryInodeData, InodeData},
|
||||
};
|
||||
use crate::{
|
||||
B3Digest, Node,
|
||||
blobservice::{BlobReader, BlobService},
|
||||
directoryservice::DirectoryService,
|
||||
path::PathComponent,
|
||||
B3Digest, Node,
|
||||
};
|
||||
use bstr::ByteVec;
|
||||
use fuse_backend_rs::abi::fuse_abi::{stat64, OpenOptions};
|
||||
use fuse_backend_rs::abi::fuse_abi::{OpenOptions, stat64};
|
||||
use fuse_backend_rs::api::filesystem::{
|
||||
Context, FileSystem, FsOptions, GetxattrReply, ListxattrReply, ROOT_ID,
|
||||
};
|
||||
|
|
@ -33,7 +33,7 @@ use std::{
|
|||
collections::HashMap,
|
||||
io,
|
||||
sync::atomic::AtomicU64,
|
||||
sync::{atomic::Ordering, Arc},
|
||||
sync::{Arc, atomic::Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
use std::{ffi::CStr, io::Cursor};
|
||||
|
|
@ -41,7 +41,7 @@ use tokio::{
|
|||
io::{AsyncReadExt, AsyncSeekExt},
|
||||
sync::mpsc,
|
||||
};
|
||||
use tracing::{debug, error, instrument, warn, Instrument as _, Span};
|
||||
use tracing::{Instrument as _, Span, debug, error, instrument, warn};
|
||||
|
||||
/// This implements a read-only FUSE filesystem for a snix-store
|
||||
/// with the passed [BlobService], [DirectoryService] and [RootNodes].
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::nodes::Directory;
|
||||
use crate::{path::PathComponent, Error, Node};
|
||||
use crate::{Error, Node, path::PathComponent};
|
||||
use futures::stream::BoxStream;
|
||||
use tonic::async_trait;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use petgraph::Direction;
|
||||
use petgraph::graph::{DiGraph, NodeIndex};
|
||||
use petgraph::visit::{DfsPostOrder, EdgeRef};
|
||||
use petgraph::Direction;
|
||||
use tokio::io::AsyncRead;
|
||||
use tokio_stream::StreamExt;
|
||||
use tokio_tar::Archive;
|
||||
use tracing::{instrument, warn, Level};
|
||||
use tracing::{Level, instrument, warn};
|
||||
|
||||
use crate::Node;
|
||||
use crate::blobservice::BlobService;
|
||||
use crate::directoryservice::DirectoryService;
|
||||
use crate::import::{ingest_entries, IngestionEntry, IngestionError};
|
||||
use crate::Node;
|
||||
use crate::import::{IngestionEntry, IngestionError, ingest_entries};
|
||||
|
||||
use super::blobs::{self, ConcurrentBlobUploader};
|
||||
|
||||
|
|
@ -295,8 +295,8 @@ mod test {
|
|||
use std::sync::LazyLock;
|
||||
|
||||
use super::{Error, IngestionEntryGraph};
|
||||
use crate::import::IngestionEntry;
|
||||
use crate::B3Digest;
|
||||
use crate::import::IngestionEntry;
|
||||
|
||||
use rstest::rstest;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ use tokio::{
|
|||
task::{JoinError, JoinSet},
|
||||
};
|
||||
use tokio_util::io::InspectReader;
|
||||
use tracing::{info_span, Instrument};
|
||||
use tracing::{Instrument, info_span};
|
||||
|
||||
use crate::{blobservice::BlobService, B3Digest, Path, PathBuf};
|
||||
use crate::{B3Digest, Path, PathBuf, blobservice::BlobService};
|
||||
|
||||
/// Files smaller than this threshold, in bytes, are uploaded to the [BlobService] in the
|
||||
/// background.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
//! Import from a real filesystem.
|
||||
|
||||
use futures::stream::BoxStream;
|
||||
use futures::StreamExt;
|
||||
use futures::stream::BoxStream;
|
||||
use std::fs::FileType;
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use tokio::io::BufReader;
|
||||
use tokio_util::io::InspectReader;
|
||||
use tracing::info_span;
|
||||
use tracing::instrument;
|
||||
use tracing::Instrument;
|
||||
use tracing::Span;
|
||||
use tracing::info_span;
|
||||
use tracing::instrument;
|
||||
use tracing_indicatif::span_ext::IndicatifSpanExt;
|
||||
use walkdir::DirEntry;
|
||||
use walkdir::WalkDir;
|
||||
|
|
@ -21,9 +21,9 @@ use crate::directoryservice::DirectoryService;
|
|||
use crate::refscan::{ReferenceReader, ReferenceScanner};
|
||||
use crate::{B3Digest, Node};
|
||||
|
||||
use super::ingest_entries;
|
||||
use super::IngestionEntry;
|
||||
use super::IngestionError;
|
||||
use super::ingest_entries;
|
||||
|
||||
/// Ingests the contents at a given path into the snix store, interacting with a [BlobService] and
|
||||
/// [DirectoryService]. It returns the root node or an error.
|
||||
|
|
|
|||
|
|
@ -211,11 +211,11 @@ mod test {
|
|||
use rstest::rstest;
|
||||
|
||||
use crate::fixtures::{DIRECTORY_COMPLICATED, DIRECTORY_WITH_KEEP, EMPTY_BLOB_DIGEST};
|
||||
use crate::{directoryservice::MemoryDirectoryService, fixtures::DUMMY_DIGEST};
|
||||
use crate::{Directory, Node};
|
||||
use crate::{directoryservice::MemoryDirectoryService, fixtures::DUMMY_DIGEST};
|
||||
|
||||
use super::ingest_entries;
|
||||
use super::IngestionEntry;
|
||||
use super::ingest_entries;
|
||||
|
||||
#[rstest]
|
||||
#[case::single_file(vec![IngestionEntry::Regular {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::collections::btree_map::{self, BTreeMap};
|
||||
|
||||
use crate::{errors::DirectoryError, path::PathComponent, proto, B3Digest, Node};
|
||||
use crate::{B3Digest, Node, errors::DirectoryError, path::PathComponent, proto};
|
||||
|
||||
/// A Directory contains nodes, which can be Directory, File or Symlink nodes.
|
||||
/// It attaches names to these nodes, which is the basename in that directory.
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ mod tests {
|
|||
use bytes::Bytes;
|
||||
use rstest::rstest;
|
||||
|
||||
use super::{validate_name, PathComponent, PathComponentError};
|
||||
use super::{PathComponent, PathComponentError, validate_name};
|
||||
|
||||
#[rstest]
|
||||
#[case::empty(b"", PathComponentError::Empty)]
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
use crate::{blobservice::BlobService, B3Digest};
|
||||
use crate::{B3Digest, blobservice::BlobService};
|
||||
use core::pin::pin;
|
||||
use futures::{stream::BoxStream, TryFutureExt};
|
||||
use futures::{TryFutureExt, stream::BoxStream};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
use tokio_stream::StreamExt;
|
||||
use tokio_util::io::ReaderStream;
|
||||
use tonic::{async_trait, Request, Response, Status, Streaming};
|
||||
use tracing::{instrument, warn, Span};
|
||||
use tonic::{Request, Response, Status, Streaming, async_trait};
|
||||
use tracing::{Span, instrument, warn};
|
||||
|
||||
pub struct GRPCBlobServiceWrapper<T> {
|
||||
blob_service: T,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use crate::directoryservice::{DirectoryGraph, DirectoryService, LeavesToRootValidator};
|
||||
use crate::{proto, B3Digest, DirectoryError};
|
||||
use futures::stream::BoxStream;
|
||||
use crate::{B3Digest, DirectoryError, proto};
|
||||
use futures::TryStreamExt;
|
||||
use futures::stream::BoxStream;
|
||||
use std::ops::Deref;
|
||||
use tokio_stream::once;
|
||||
use tonic::{async_trait, Request, Response, Status, Streaming};
|
||||
use tonic::{Request, Response, Status, Streaming, async_trait};
|
||||
use tracing::{instrument, warn};
|
||||
|
||||
pub struct GRPCDirectoryServiceWrapper<T> {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::cmp::Ordering;
|
|||
mod grpc_blobservice_wrapper;
|
||||
mod grpc_directoryservice_wrapper;
|
||||
|
||||
use crate::{path::PathComponent, B3Digest, DirectoryError};
|
||||
use crate::{B3Digest, DirectoryError, path::PathComponent};
|
||||
pub use grpc_blobservice_wrapper::GRPCBlobServiceWrapper;
|
||||
pub use grpc_directoryservice_wrapper::GRPCDirectoryServiceWrapper;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::proto::{Directory, DirectoryEntry, DirectoryError, FileEntry, SymlinkEntry};
|
||||
use crate::ValidateNodeError;
|
||||
use crate::proto::{Directory, DirectoryEntry, DirectoryError, FileEntry, SymlinkEntry};
|
||||
|
||||
use hex_literal::hex;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{entry, Entry, SymlinkEntry};
|
||||
use super::{Entry, SymlinkEntry, entry};
|
||||
use crate::DirectoryError;
|
||||
|
||||
mod directory;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
use pin_project::pin_project;
|
||||
use std::collections::BTreeSet;
|
||||
use std::pin::Pin;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::task::{ready, Poll};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::task::{Poll, ready};
|
||||
use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};
|
||||
use wu_manber::TwoByteWM;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::Node;
|
||||
use crate::blobservice::{self, BlobService};
|
||||
use crate::directoryservice;
|
||||
use crate::fixtures::*;
|
||||
use crate::import::fs::ingest_path;
|
||||
use crate::Node;
|
||||
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
|
@ -105,16 +105,20 @@ async fn complicated() {
|
|||
);
|
||||
|
||||
// ensure DIRECTORY_WITH_KEEP and DIRECTORY_COMPLICATED have been uploaded
|
||||
assert!(directory_service
|
||||
.get(&DIRECTORY_WITH_KEEP.digest())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_some());
|
||||
assert!(directory_service
|
||||
.get(&DIRECTORY_COMPLICATED.digest())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_some());
|
||||
assert!(
|
||||
directory_service
|
||||
.get(&DIRECTORY_WITH_KEEP.digest())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_some()
|
||||
);
|
||||
assert!(
|
||||
directory_service
|
||||
.get(&DIRECTORY_COMPLICATED.digest())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_some()
|
||||
);
|
||||
|
||||
// ensure EMPTY_BLOB_CONTENTS has been uploaded
|
||||
assert!(blob_service.has(&EMPTY_BLOB_DIGEST).await.unwrap());
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use url::Url;
|
|||
|
||||
use crate::blobservice::BlobService;
|
||||
use crate::composition::{
|
||||
with_registry, Composition, DeserializeWithRegistry, ServiceBuilder, REG,
|
||||
Composition, DeserializeWithRegistry, REG, ServiceBuilder, with_registry,
|
||||
};
|
||||
use crate::directoryservice::DirectoryService;
|
||||
|
||||
|
|
|
|||
2
snix/store/rustfmt.toml
Normal file
2
snix/store/rustfmt.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# FUTUREWORK: move to .. once all crates are migrated (#114)
|
||||
edition = "2024"
|
||||
|
|
@ -20,16 +20,16 @@ use tonic::transport::Server;
|
|||
use tower::ServiceBuilder;
|
||||
use tower_http::classify::{GrpcCode, GrpcErrorsAsFailures, SharedClassifier};
|
||||
use tower_http::trace::{DefaultMakeSpan, TraceLayer};
|
||||
use tracing::{debug, info, info_span, instrument, warn, Instrument, Level, Span};
|
||||
use tracing::{Instrument, Level, Span, debug, info, info_span, instrument, warn};
|
||||
use tracing_indicatif::span_ext::IndicatifSpanExt;
|
||||
|
||||
use snix_castore::proto::blob_service_server::BlobServiceServer;
|
||||
use snix_castore::proto::directory_service_server::DirectoryServiceServer;
|
||||
use snix_castore::proto::GRPCBlobServiceWrapper;
|
||||
use snix_castore::proto::GRPCDirectoryServiceWrapper;
|
||||
use snix_castore::proto::blob_service_server::BlobServiceServer;
|
||||
use snix_castore::proto::directory_service_server::DirectoryServiceServer;
|
||||
use snix_store::pathinfoservice::{PathInfo, PathInfoService};
|
||||
use snix_store::proto::path_info_service_server::PathInfoServiceServer;
|
||||
use snix_store::proto::GRPCPathInfoServiceWrapper;
|
||||
use snix_store::proto::path_info_service_server::PathInfoServiceServer;
|
||||
|
||||
#[cfg(any(feature = "fuse", feature = "virtiofs"))]
|
||||
use snix_store::pathinfoservice::make_fs;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ use crate::pathinfoservice::PathInfo;
|
|||
use md5::Digest;
|
||||
use nix_compat::nixhash::{CAHash, NixHash};
|
||||
use nix_compat::store_path::StorePath;
|
||||
use snix_castore::Node;
|
||||
use snix_castore::fixtures::{
|
||||
DIRECTORY_COMPLICATED, DUMMY_DIGEST, HELLOWORLD_BLOB_CONTENTS, HELLOWORLD_BLOB_DIGEST,
|
||||
};
|
||||
use snix_castore::Node;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
pub const DUMMY_PATH_STR: &str = "00000000000000000000000000000000-dummy";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use bstr::ByteSlice;
|
||||
use snix_castore::{
|
||||
blobservice::BlobService, directoryservice::DirectoryService, import::fs::ingest_path, Node,
|
||||
Node, blobservice::BlobService, directoryservice::DirectoryService, import::fs::ingest_path,
|
||||
};
|
||||
use std::path::Path;
|
||||
use tracing::{debug, instrument};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use std::{
|
||||
io::Result,
|
||||
pin::Pin,
|
||||
task::{ready, Context, Poll},
|
||||
task::{Context, Poll, ready},
|
||||
};
|
||||
|
||||
use md5::{digest::DynDigest, Digest};
|
||||
use md5::{Digest, digest::DynDigest};
|
||||
use nix_compat::nixhash::{HashAlgo, NixHash};
|
||||
use pin_project_lite::pin_project;
|
||||
use tokio::io::{AsyncRead, ReadBuf};
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ use nix_compat::{
|
|||
};
|
||||
use sha2::Digest;
|
||||
use snix_castore::{
|
||||
Node, PathBuf,
|
||||
blobservice::BlobService,
|
||||
directoryservice::DirectoryService,
|
||||
import::{
|
||||
IngestionEntry, IngestionError,
|
||||
blobs::{self, ConcurrentBlobUploader},
|
||||
ingest_entries, IngestionEntry, IngestionError,
|
||||
ingest_entries,
|
||||
},
|
||||
Node, PathBuf,
|
||||
};
|
||||
use tokio::{
|
||||
io::{AsyncBufRead, AsyncRead},
|
||||
|
|
@ -232,7 +233,7 @@ mod test {
|
|||
use crate::fixtures::{
|
||||
NAR_CONTENTS_COMPLICATED, NAR_CONTENTS_HELLOWORLD, NAR_CONTENTS_SYMLINK,
|
||||
};
|
||||
use crate::nar::{ingest_nar, ingest_nar_and_hash, NarIngestionError};
|
||||
use crate::nar::{NarIngestionError, ingest_nar, ingest_nar_and_hash};
|
||||
use std::io::Cursor;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ mod hashing_reader;
|
|||
mod import;
|
||||
mod renderer;
|
||||
pub mod seekable;
|
||||
pub use import::{ingest_nar, ingest_nar_and_hash, NarIngestionError};
|
||||
pub use import::{NarIngestionError, ingest_nar, ingest_nar_and_hash};
|
||||
pub use renderer::SimpleRenderer;
|
||||
pub use renderer::calculate_size_and_sha256;
|
||||
pub use renderer::write_nar;
|
||||
pub use renderer::SimpleRenderer;
|
||||
use snix_castore::Node;
|
||||
|
||||
#[async_trait]
|
||||
|
|
@ -16,7 +16,7 @@ pub trait NarCalculationService: Send + Sync {
|
|||
/// Return the nar size and nar sha256 digest for a given root node.
|
||||
/// This can be used to calculate NAR-based output paths.
|
||||
async fn calculate_nar(&self, root_node: &Node)
|
||||
-> Result<(u64, [u8; 32]), snix_castore::Error>;
|
||||
-> Result<(u64, [u8; 32]), snix_castore::Error>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
|
@ -44,7 +44,9 @@ pub enum RenderError {
|
|||
#[error("unable to find blob {0}, referred from {1:?}")]
|
||||
BlobNotFound(B3Digest, bytes::Bytes),
|
||||
|
||||
#[error("unexpected size in metadata for blob {0}, referred from {1:?} returned, expected {2}, got {3}")]
|
||||
#[error(
|
||||
"unexpected size in metadata for blob {0}, referred from {1:?} returned, expected {2}, got {3}"
|
||||
)]
|
||||
UnexpectedBlobMeta(B3Digest, bytes::Bytes, u32, u32),
|
||||
|
||||
#[error("failure using the NAR writer: {0}")]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use super::{NarCalculationService, RenderError};
|
|||
use count_write::CountWrite;
|
||||
use nix_compat::nar::writer::r#async as nar_writer;
|
||||
use sha2::{Digest, Sha256};
|
||||
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService, Node};
|
||||
use snix_castore::{Node, blobservice::BlobService, directoryservice::DirectoryService};
|
||||
use tokio::io::{self, AsyncWrite, BufReader};
|
||||
use tonic::async_trait;
|
||||
use tracing::instrument;
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ use super::RenderError;
|
|||
use bytes::{BufMut, Bytes};
|
||||
|
||||
use nix_compat::nar::writer::sync as nar_writer;
|
||||
use snix_castore::Directory;
|
||||
use snix_castore::blobservice::{BlobReader, BlobService};
|
||||
use snix_castore::directoryservice::{
|
||||
DirectoryGraph, DirectoryService, RootToLeavesValidator, ValidatedDirectoryGraph,
|
||||
};
|
||||
use snix_castore::Directory;
|
||||
use snix_castore::{B3Digest, Node};
|
||||
|
||||
use futures::future::{BoxFuture, FusedFuture, TryMaybeDone};
|
||||
use futures::FutureExt;
|
||||
use futures::TryStreamExt;
|
||||
use futures::future::{BoxFuture, FusedFuture, TryMaybeDone};
|
||||
|
||||
use tokio::io::AsyncSeekExt;
|
||||
|
||||
|
|
@ -364,7 +364,7 @@ impl<B: BlobService + 'static> tokio::io::AsyncRead for Reader<B> {
|
|||
return Poll::Ready(Err(io::Error::new(
|
||||
io::ErrorKind::UnexpectedEof,
|
||||
"blob short read",
|
||||
)))
|
||||
)));
|
||||
}
|
||||
(false, true) => {
|
||||
buf.set_filled(prev_read_buf_pos);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ use futures::stream::BoxStream;
|
|||
use nix_compat::nixbase32;
|
||||
use prost::Message;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{serde_as, DurationSeconds};
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use serde_with::{DurationSeconds, serde_as};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use std::sync::Arc;
|
||||
use tonic::async_trait;
|
||||
use tracing::{instrument, trace, warn, Span};
|
||||
use tracing::{Span, instrument, trace, warn};
|
||||
|
||||
/// There should not be more than 10 MiB in a single cell.
|
||||
/// <https://cloud.google.com/bigtable/docs/schema-design#cells>
|
||||
|
|
@ -77,7 +77,7 @@ impl BigtablePathInfoService {
|
|||
|
||||
use async_process::{Command, Stdio};
|
||||
use tempfile::TempDir;
|
||||
use tokio_retry::{strategy::ExponentialBackoff, Retry};
|
||||
use tokio_retry::{Retry, strategy::ExponentialBackoff};
|
||||
|
||||
let tmpdir = TempDir::new().unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use std::sync::Arc;
|
|||
|
||||
use futures::stream::BoxStream;
|
||||
use nix_compat::nixbase32;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use tonic::async_trait;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
|
|
@ -132,11 +132,12 @@ mod test {
|
|||
let svc = create_pathinfoservice().await;
|
||||
|
||||
// query the PathInfo, things should not be there.
|
||||
assert!(svc
|
||||
.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_none());
|
||||
assert!(
|
||||
svc.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
|
||||
// insert it into the far one.
|
||||
svc.far.put(PATH_INFO.clone()).await.unwrap();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use super::PathInfoService;
|
||||
|
||||
use crate::composition::REG;
|
||||
use snix_castore::composition::{
|
||||
with_registry, CompositionContext, DeserializeWithRegistry, ServiceBuilder,
|
||||
};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::composition::{
|
||||
CompositionContext, DeserializeWithRegistry, ServiceBuilder, with_registry,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use futures::stream::BoxStream;
|
||||
use futures::StreamExt;
|
||||
use futures::stream::BoxStream;
|
||||
use nix_compat::store_path::StorePathRef;
|
||||
use snix_castore::fs::{RootNodes, SnixStoreFs};
|
||||
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService};
|
||||
use snix_castore::{Error, Node, PathComponent};
|
||||
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService};
|
||||
use tonic::async_trait;
|
||||
|
||||
use super::PathInfoService;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ use crate::{
|
|||
use async_stream::try_stream;
|
||||
use futures::stream::BoxStream;
|
||||
use nix_compat::nixbase32;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::Node;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use std::sync::Arc;
|
||||
use tonic::{async_trait, Code};
|
||||
use tracing::{instrument, warn, Span};
|
||||
use tonic::{Code, async_trait};
|
||||
use tracing::{Span, instrument, warn};
|
||||
use tracing_indicatif::span_ext::IndicatifSpanExt;
|
||||
|
||||
/// Connects to a (remote) snix-store PathInfoService over gRPC.
|
||||
|
|
@ -185,8 +185,8 @@ impl ServiceBuilder for GRPCPathInfoServiceConfig {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::pathinfoservice::tests::make_grpc_path_info_service_client;
|
||||
use crate::pathinfoservice::PathInfoService;
|
||||
use crate::pathinfoservice::tests::make_grpc_path_info_service_client;
|
||||
|
||||
/// This ensures connecting via gRPC works as expected.
|
||||
#[tokio::test]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use tokio::sync::RwLock;
|
|||
use tonic::async_trait;
|
||||
use tracing::instrument;
|
||||
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
|
||||
use super::{PathInfo, PathInfoService};
|
||||
|
||||
|
|
@ -111,11 +111,12 @@ mod test {
|
|||
let svc = LruPathInfoService::with_capacity("test".into(), NonZeroUsize::new(1).unwrap());
|
||||
|
||||
// pathinfo_1 should not be there
|
||||
assert!(svc
|
||||
.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.expect("no error")
|
||||
.is_none());
|
||||
assert!(
|
||||
svc.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.expect("no error")
|
||||
.is_none()
|
||||
);
|
||||
|
||||
// insert it
|
||||
svc.put(PATH_INFO.clone()).await.expect("no error");
|
||||
|
|
@ -138,10 +139,11 @@ mod test {
|
|||
);
|
||||
|
||||
// … but pathinfo 1 not anymore.
|
||||
assert!(svc
|
||||
.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.expect("no error")
|
||||
.is_none());
|
||||
assert!(
|
||||
svc.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.expect("no error")
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use super::{PathInfo, PathInfoService};
|
|||
use async_stream::try_stream;
|
||||
use futures::stream::BoxStream;
|
||||
use nix_compat::nixbase32;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use tokio::sync::RwLock;
|
||||
use tonic::async_trait;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ mod tests;
|
|||
|
||||
use auto_impl::auto_impl;
|
||||
use futures::stream::BoxStream;
|
||||
use snix_castore::composition::{Registry, ServiceBuilder};
|
||||
use snix_castore::Error;
|
||||
use snix_castore::composition::{Registry, ServiceBuilder};
|
||||
use tonic::async_trait;
|
||||
|
||||
use crate::nar::NarCalculationService;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use super::{PathInfo, PathInfoService};
|
||||
use crate::nar::ingest_nar_and_hash;
|
||||
use futures::{stream::BoxStream, TryStreamExt};
|
||||
use futures::{TryStreamExt, stream::BoxStream};
|
||||
use nix_compat::{
|
||||
narinfo::{self, NarInfo, Signature},
|
||||
nixbase32,
|
||||
|
|
@ -9,7 +9,7 @@ use nix_compat::{
|
|||
};
|
||||
use reqwest::StatusCode;
|
||||
use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
||||
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService, Error};
|
||||
use snix_castore::{Error, blobservice::BlobService, directoryservice::DirectoryService};
|
||||
use std::sync::Arc;
|
||||
use tokio::io::{self, AsyncRead};
|
||||
use tonic::async_trait;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use super::{PathInfo, PathInfoService};
|
||||
use crate::proto;
|
||||
use data_encoding::BASE64;
|
||||
use futures::{stream::BoxStream, StreamExt};
|
||||
use futures::{StreamExt, stream::BoxStream};
|
||||
use prost::Message;
|
||||
use redb::{Database, ReadableTable, TableDefinition};
|
||||
use snix_castore::{
|
||||
composition::{CompositionContext, ServiceBuilder},
|
||||
Error,
|
||||
composition::{CompositionContext, ServiceBuilder},
|
||||
};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use snix_castore::composition::{CompositionContext, ServiceBuilder};
|
|||
|
||||
use snix_castore::Error;
|
||||
|
||||
use nix_compat::narinfo::{parse_keypair, Signature, SigningKey};
|
||||
use nix_compat::narinfo::{Signature, SigningKey, parse_keypair};
|
||||
use nix_compat::nixbase32;
|
||||
use tracing::instrument;
|
||||
|
||||
|
|
@ -158,11 +158,12 @@ mod test {
|
|||
);
|
||||
|
||||
// Asking PathInfoService, it should not be there ...
|
||||
assert!(svc
|
||||
.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.expect("no error")
|
||||
.is_none());
|
||||
assert!(
|
||||
svc.get(*PATH_INFO.store_path.digest())
|
||||
.await
|
||||
.expect("no error")
|
||||
.is_none()
|
||||
);
|
||||
|
||||
// insert it
|
||||
svc.put(PATH_INFO.clone()).await.expect("no error");
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ use rstest_reuse::{self, *};
|
|||
|
||||
use super::{PathInfo, PathInfoService};
|
||||
use crate::fixtures::{DUMMY_PATH_DIGEST, PATH_INFO};
|
||||
use crate::pathinfoservice::MemoryPathInfoService;
|
||||
use crate::pathinfoservice::redb::RedbPathInfoService;
|
||||
use crate::pathinfoservice::test_signing_service;
|
||||
use crate::pathinfoservice::MemoryPathInfoService;
|
||||
|
||||
mod utils;
|
||||
pub use self::utils::make_grpc_path_info_service_client;
|
||||
|
|
@ -38,11 +38,12 @@ pub fn path_info_services(#[case] svc: impl PathInfoService) {}
|
|||
#[apply(path_info_services)]
|
||||
#[tokio::test]
|
||||
async fn not_found(svc: impl PathInfoService) {
|
||||
assert!(svc
|
||||
.get(DUMMY_PATH_DIGEST)
|
||||
.await
|
||||
.expect("must succeed")
|
||||
.is_none());
|
||||
assert!(
|
||||
svc.get(DUMMY_PATH_DIGEST)
|
||||
.await
|
||||
.expect("must succeed")
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
/// Put a PathInfo into the store, get it back.
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use crate::{
|
|||
nar::{NarCalculationService, SimpleRenderer},
|
||||
pathinfoservice::{GRPCPathInfoService, MemoryPathInfoService, PathInfoService},
|
||||
proto::{
|
||||
path_info_service_client::PathInfoServiceClient,
|
||||
path_info_service_server::PathInfoServiceServer, GRPCPathInfoServiceWrapper,
|
||||
GRPCPathInfoServiceWrapper, path_info_service_client::PathInfoServiceClient,
|
||||
path_info_service_server::PathInfoServiceServer,
|
||||
},
|
||||
tests::fixtures::{blob_service, directory_service},
|
||||
};
|
||||
|
|
@ -71,10 +71,10 @@ pub async fn make_grpc_path_info_service_client() -> (
|
|||
}
|
||||
|
||||
#[cfg(all(feature = "cloud", feature = "integration"))]
|
||||
pub(crate) async fn make_bigtable_path_info_service(
|
||||
) -> crate::pathinfoservice::BigtablePathInfoService {
|
||||
use crate::pathinfoservice::bigtable::BigtableParameters;
|
||||
pub(crate) async fn make_bigtable_path_info_service()
|
||||
-> crate::pathinfoservice::BigtablePathInfoService {
|
||||
use crate::pathinfoservice::BigtablePathInfoService;
|
||||
use crate::pathinfoservice::bigtable::BigtableParameters;
|
||||
|
||||
BigtablePathInfoService::connect("test".into(), BigtableParameters::default_for_tests())
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use crate::nar::{NarCalculationService, RenderError};
|
||||
use crate::pathinfoservice::{PathInfo, PathInfoService};
|
||||
use crate::proto;
|
||||
use futures::{stream::BoxStream, TryStreamExt};
|
||||
use futures::{TryStreamExt, stream::BoxStream};
|
||||
use snix_castore::proto as castorepb;
|
||||
use std::ops::Deref;
|
||||
use tonic::{async_trait, Request, Response, Result, Status};
|
||||
use tonic::{Request, Response, Result, Status, async_trait};
|
||||
use tracing::{instrument, warn};
|
||||
|
||||
pub struct GRPCPathInfoServiceWrapper<PS, NS> {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ use crate::nar::write_nar;
|
|||
use crate::tests::fixtures::*;
|
||||
use rstest::*;
|
||||
use rstest_reuse::*;
|
||||
use snix_castore::Node;
|
||||
use snix_castore::blobservice::BlobService;
|
||||
use snix_castore::directoryservice::DirectoryService;
|
||||
use snix_castore::Node;
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
use tokio::io::sink;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ use crate::tests::fixtures::directory_service_with_contents as directory_service
|
|||
use crate::tests::fixtures::*;
|
||||
use rstest::*;
|
||||
use rstest_reuse::*;
|
||||
use snix_castore::Node;
|
||||
use snix_castore::blobservice::BlobService;
|
||||
use snix_castore::directoryservice::DirectoryService;
|
||||
use snix_castore::Node;
|
||||
use std::io;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use crate::composition::REG;
|
|||
use crate::nar::{NarCalculationService, SimpleRenderer};
|
||||
use crate::pathinfoservice::PathInfoService;
|
||||
use snix_castore::composition::{
|
||||
with_registry, Composition, DeserializeWithRegistry, ServiceBuilder,
|
||||
Composition, DeserializeWithRegistry, ServiceBuilder, with_registry,
|
||||
};
|
||||
|
||||
#[derive(serde::Deserialize, Default)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue