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:
Florian Klink 2025-04-30 11:30:50 +03:00 committed by clbot
parent b39d7abc5a
commit 98703f7a41
65 changed files with 222 additions and 197 deletions

View file

@ -0,0 +1,2 @@
# FUTUREWORK: move to .. once all crates are migrated (#114)
edition = "2024"

View file

@ -1,14 +1,14 @@
use clap::{Parser, Subcommand}; 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")] #[cfg(feature = "fuse")]
use snix_castore::fs::fuse::FuseDaemon; use snix_castore::fs::fuse::FuseDaemon;
#[cfg(feature = "virtiofs")] #[cfg(feature = "virtiofs")]
use snix_castore::fs::virtiofs::start_virtiofs_daemon; 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}; 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::error::Error;
use std::io::Write; use std::io::Write;
use std::path::PathBuf; use std::path::PathBuf;

View file

@ -1,4 +1,4 @@
use futures::{ready, TryStreamExt}; use futures::{TryStreamExt, ready};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncSeekExt}; use tokio::io::{AsyncRead, AsyncSeekExt};
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
@ -259,8 +259,8 @@ mod test {
}; };
use crate::{ use crate::{
blobservice::{chunked_reader::ChunkedReader, BlobService, MemoryBlobService},
B3Digest, B3Digest,
blobservice::{BlobService, MemoryBlobService, chunked_reader::ChunkedReader},
}; };
use hex_literal::hex; use hex_literal::hex;
use tokio::io::{AsyncReadExt, AsyncSeekExt}; use tokio::io::{AsyncReadExt, AsyncSeekExt};

View file

@ -3,7 +3,7 @@ use std::sync::Arc;
use url::Url; use url::Url;
use crate::composition::{ use crate::composition::{
with_registry, CompositionContext, DeserializeWithRegistry, ServiceBuilder, REG, CompositionContext, DeserializeWithRegistry, REG, ServiceBuilder, with_registry,
}; };
use super::BlobService; use super::BlobService;

View file

@ -1,8 +1,8 @@
use super::{BlobReader, BlobService, BlobWriter, ChunkedReader}; use super::{BlobReader, BlobService, BlobWriter, ChunkedReader};
use crate::composition::{CompositionContext, ServiceBuilder}; use crate::composition::{CompositionContext, ServiceBuilder};
use crate::{ use crate::{
proto::{self, stat_blob_response::ChunkMeta},
B3Digest, B3Digest,
proto::{self, stat_blob_response::ChunkMeta},
}; };
use futures::sink::SinkExt; use futures::sink::SinkExt;
use std::{ use std::{
@ -13,13 +13,13 @@ use std::{
}; };
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tokio_stream::{wrappers::ReceiverStream, StreamExt}; use tokio_stream::{StreamExt, wrappers::ReceiverStream};
use tokio_util::{ use tokio_util::{
io::{CopyToBytes, SinkWriter}, io::{CopyToBytes, SinkWriter},
sync::PollSender, sync::PollSender,
}; };
use tonic::{async_trait, Code, Status}; use tonic::{Code, Status, async_trait};
use tracing::{instrument, Instrument as _}; use tracing::{Instrument as _, instrument};
/// Connects to a (remote) snix-store BlobService over gRPC. /// Connects to a (remote) snix-store BlobService over gRPC.
#[derive(Clone)] #[derive(Clone)]
@ -323,14 +323,14 @@ mod tests {
use tempfile::TempDir; use tempfile::TempDir;
use tokio::net::UnixListener; use tokio::net::UnixListener;
use tokio_retry::strategy::ExponentialBackoff;
use tokio_retry::Retry; use tokio_retry::Retry;
use tokio_retry::strategy::ExponentialBackoff;
use tokio_stream::wrappers::UnixListenerStream; use tokio_stream::wrappers::UnixListenerStream;
use crate::blobservice::MemoryBlobService; use crate::blobservice::MemoryBlobService;
use crate::fixtures; use crate::fixtures;
use crate::proto::blob_service_client::BlobServiceClient;
use crate::proto::GRPCBlobServiceWrapper; use crate::proto::GRPCBlobServiceWrapper;
use crate::proto::blob_service_client::BlobServiceClient;
use super::BlobService; use super::BlobService;
use super::GRPCBlobService; use super::GRPCBlobService;

View file

@ -3,9 +3,9 @@ use std::io;
use auto_impl::auto_impl; use auto_impl::auto_impl;
use tonic::async_trait; use tonic::async_trait;
use crate::B3Digest;
use crate::composition::{Registry, ServiceBuilder}; use crate::composition::{Registry, ServiceBuilder};
use crate::proto::stat_blob_response::ChunkMeta; use crate::proto::stat_blob_response::ChunkMeta;
use crate::B3Digest;
mod chunked_reader; mod chunked_reader;
mod combinator; mod combinator;

View file

@ -1,5 +1,5 @@
use std::{ use std::{
collections::{hash_map, HashMap}, collections::{HashMap, hash_map},
io::{self, Cursor}, io::{self, Cursor},
pin::pin, pin::pin,
sync::Arc, sync::Arc,
@ -9,19 +9,19 @@ use std::{
use data_encoding::HEXLOWER; use data_encoding::HEXLOWER;
use fastcdc::v2020::AsyncStreamCDC; use fastcdc::v2020::AsyncStreamCDC;
use futures::Future; use futures::Future;
use object_store::{path::Path, ObjectStore}; use object_store::{ObjectStore, path::Path};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use prost::Message; use prost::Message;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
use tonic::async_trait; use tonic::async_trait;
use tracing::{debug, instrument, trace, Level}; use tracing::{Level, debug, instrument, trace};
use url::Url; use url::Url;
use crate::{ use crate::{
composition::{CompositionContext, ServiceBuilder},
proto::{stat_blob_response::ChunkMeta, StatBlobResponse},
B3Digest, B3HashingReader, Error, B3Digest, B3HashingReader, Error,
composition::{CompositionContext, ServiceBuilder},
proto::{StatBlobResponse, stat_blob_response::ChunkMeta},
}; };
use super::{BlobReader, BlobService, BlobWriter, ChunkedReader}; use super::{BlobReader, BlobService, BlobWriter, ChunkedReader};

View file

@ -31,21 +31,25 @@ pub fn blob_services(#[case] blob_service: impl BlobService) {}
#[apply(blob_services)] #[apply(blob_services)]
#[tokio::test] #[tokio::test]
async fn has_nonexistent_false(blob_service: impl BlobService) { async fn has_nonexistent_false(blob_service: impl BlobService) {
assert!(!blob_service assert!(
!blob_service
.has(&BLOB_A_DIGEST) .has(&BLOB_A_DIGEST)
.await .await
.expect("must not fail")); .expect("must not fail")
);
} }
/// Using [BlobService::chunks] on a non-existing blob should return Ok(None) /// Using [BlobService::chunks] on a non-existing blob should return Ok(None)
#[apply(blob_services)] #[apply(blob_services)]
#[tokio::test] #[tokio::test]
async fn chunks_nonexistent_false(blob_service: impl BlobService) { async fn chunks_nonexistent_false(blob_service: impl BlobService) {
assert!(blob_service assert!(
blob_service
.chunks(&BLOB_A_DIGEST) .chunks(&BLOB_A_DIGEST)
.await .await
.expect("must be ok") .expect("must be ok")
.is_none()); .is_none()
);
} }
// TODO: do tests with `chunks` // TODO: do tests with `chunks`
@ -54,11 +58,13 @@ async fn chunks_nonexistent_false(blob_service: impl BlobService) {
#[apply(blob_services)] #[apply(blob_services)]
#[tokio::test] #[tokio::test]
async fn not_found_read(blob_service: impl BlobService) { async fn not_found_read(blob_service: impl BlobService) {
assert!(blob_service assert!(
blob_service
.open_read(&BLOB_A_DIGEST) .open_read(&BLOB_A_DIGEST)
.await .await
.expect("must not fail") .expect("must not fail")
.is_none()) .is_none()
)
} }
/// Put a blob in the store, check has, get it back. /// Put a blob in the store, check has, get it back.

View file

@ -1,6 +1,6 @@
use crate::blobservice::{BlobService, MemoryBlobService}; use crate::blobservice::{BlobService, MemoryBlobService};
use crate::proto::blob_service_client::BlobServiceClient;
use crate::proto::GRPCBlobServiceWrapper; use crate::proto::GRPCBlobServiceWrapper;
use crate::proto::blob_service_client::BlobServiceClient;
use crate::{blobservice::GRPCBlobService, proto::blob_service_server::BlobServiceServer}; use crate::{blobservice::GRPCBlobService, proto::blob_service_server::BlobServiceServer};
use hyper_util::rt::TokioIo; use hyper_util::rt::TokioIo;
use tonic::transport::{Endpoint, Server, Uri}; use tonic::transport::{Endpoint, Server, Uri};

View file

@ -97,8 +97,8 @@
//! This behavior might change in the future. //! This behavior might change in the future.
use erased_serde::deserialize; use erased_serde::deserialize;
use futures::future::BoxFuture;
use futures::FutureExt; use futures::FutureExt;
use futures::future::BoxFuture;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use serde_tagged::de::{BoxFnSeed, SeedFactory}; use serde_tagged::de::{BoxFnSeed, SeedFactory};
use serde_tagged::util::TagString; use serde_tagged::util::TagString;

View file

@ -4,16 +4,16 @@ use data_encoding::HEXLOWER;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use prost::Message; use prost::Message;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DurationSeconds}; use serde_with::{DurationSeconds, serde_as};
use std::sync::Arc; use std::sync::Arc;
use tonic::async_trait; use tonic::async_trait;
use tracing::{instrument, trace, warn}; use tracing::{instrument, trace, warn};
use super::{ use super::{
utils::traverse_directory, Directory, DirectoryPutter, DirectoryService, SimplePutter, Directory, DirectoryPutter, DirectoryService, SimplePutter, utils::traverse_directory,
}; };
use crate::composition::{CompositionContext, ServiceBuilder}; 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. /// There should not be more than 10 MiB in a single cell.
/// <https://cloud.google.com/bigtable/docs/schema-design#cells> /// <https://cloud.google.com/bigtable/docs/schema-design#cells>
@ -79,7 +79,7 @@ impl BigtableDirectoryService {
use async_process::{Command, Stdio}; use async_process::{Command, Stdio};
use tempfile::TempDir; use tempfile::TempDir;
use tokio_retry::{strategy::ExponentialBackoff, Retry}; use tokio_retry::{Retry, strategy::ExponentialBackoff};
let tmpdir = TempDir::new().unwrap(); let tmpdir = TempDir::new().unwrap();

View file

@ -1,17 +1,17 @@
use std::sync::Arc; use std::sync::Arc;
use futures::stream::BoxStream;
use futures::StreamExt; use futures::StreamExt;
use futures::TryFutureExt; use futures::TryFutureExt;
use futures::TryStreamExt; use futures::TryStreamExt;
use futures::stream::BoxStream;
use tonic::async_trait; use tonic::async_trait;
use tracing::{instrument, trace}; use tracing::{instrument, trace};
use super::{Directory, DirectoryGraph, DirectoryService, RootToLeavesValidator, SimplePutter}; use super::{Directory, DirectoryGraph, DirectoryService, RootToLeavesValidator, SimplePutter};
use crate::composition::{CompositionContext, ServiceBuilder};
use crate::directoryservice::DirectoryPutter;
use crate::B3Digest; use crate::B3Digest;
use crate::Error; use crate::Error;
use crate::composition::{CompositionContext, ServiceBuilder};
use crate::directoryservice::DirectoryPutter;
/// Asks near first, if not found, asks far. /// Asks near first, if not found, asks far.
/// If found in there, returns it, and *inserts* it into /// If found in there, returns it, and *inserts* it into

View file

@ -1,14 +1,14 @@
use std::collections::HashMap; use std::collections::HashMap;
use petgraph::{ use petgraph::{
Direction, Incoming,
graph::{DiGraph, NodeIndex}, graph::{DiGraph, NodeIndex},
visit::{Bfs, DfsPostOrder, EdgeRef, IntoNodeIdentifiers, Walker}, visit::{Bfs, DfsPostOrder, EdgeRef, IntoNodeIdentifiers, Walker},
Direction, Incoming,
}; };
use tracing::instrument; use tracing::instrument;
use super::order_validator::{LeavesToRootValidator, OrderValidator, RootToLeavesValidator}; 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)] #[derive(thiserror::Error, Debug)]
pub enum Error { pub enum Error {

View file

@ -3,7 +3,7 @@ use std::sync::Arc;
use url::Url; use url::Url;
use crate::composition::{ use crate::composition::{
with_registry, CompositionContext, DeserializeWithRegistry, ServiceBuilder, REG, CompositionContext, DeserializeWithRegistry, REG, ServiceBuilder, with_registry,
}; };
use super::DirectoryService; use super::DirectoryService;

View file

@ -11,8 +11,8 @@ use tokio::spawn;
use tokio::sync::mpsc::UnboundedSender; use tokio::sync::mpsc::UnboundedSender;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tokio_stream::wrappers::UnboundedReceiverStream; use tokio_stream::wrappers::UnboundedReceiverStream;
use tonic::{async_trait, Code, Status}; use tonic::{Code, Status, async_trait};
use tracing::{instrument, warn, Instrument as _}; use tracing::{Instrument as _, instrument, warn};
/// Connects to a (remote) snix-store DirectoryService over gRPC. /// Connects to a (remote) snix-store DirectoryService over gRPC.
#[derive(Clone)] #[derive(Clone)]
@ -320,13 +320,13 @@ mod tests {
use std::time::Duration; use std::time::Duration;
use tempfile::TempDir; use tempfile::TempDir;
use tokio::net::UnixListener; use tokio::net::UnixListener;
use tokio_retry::{strategy::ExponentialBackoff, Retry}; use tokio_retry::{Retry, strategy::ExponentialBackoff};
use tokio_stream::wrappers::UnixListenerStream; use tokio_stream::wrappers::UnixListenerStream;
use crate::{ use crate::{
directoryservice::{DirectoryService, GRPCDirectoryService, MemoryDirectoryService}, directoryservice::{DirectoryService, GRPCDirectoryService, MemoryDirectoryService},
fixtures, fixtures,
proto::{directory_service_client::DirectoryServiceClient, GRPCDirectoryServiceWrapper}, proto::{GRPCDirectoryServiceWrapper, directory_service_client::DirectoryServiceClient},
}; };
/// This ensures connecting via gRPC works as expected. /// This ensures connecting via gRPC works as expected.
@ -383,10 +383,12 @@ mod tests {
GRPCDirectoryService::from_client("test-instance".into(), client) GRPCDirectoryService::from_client("test-instance".into(), client)
}; };
assert!(grpc_client assert!(
grpc_client
.get(&fixtures::DIRECTORY_A.digest()) .get(&fixtures::DIRECTORY_A.digest())
.await .await
.expect("must not fail") .expect("must not fail")
.is_none()) .is_none()
)
} }
} }

View file

@ -1,20 +1,20 @@
use std::collections::hash_map;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::hash_map;
use std::sync::Arc; use std::sync::Arc;
use data_encoding::HEXLOWER; use data_encoding::HEXLOWER;
use futures::future::Either;
use futures::stream::BoxStream;
use futures::SinkExt; use futures::SinkExt;
use futures::StreamExt; use futures::StreamExt;
use futures::TryFutureExt; use futures::TryFutureExt;
use futures::TryStreamExt; 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 prost::Message;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio_util::codec::LengthDelimitedCodec; use tokio_util::codec::LengthDelimitedCodec;
use tonic::async_trait; use tonic::async_trait;
use tracing::{instrument, trace, warn, Level}; use tracing::{Level, instrument, trace, warn};
use url::Url; use url::Url;
use super::{ use super::{
@ -22,7 +22,7 @@ use super::{
RootToLeavesValidator, RootToLeavesValidator,
}; };
use crate::composition::{CompositionContext, ServiceBuilder}; use crate::composition::{CompositionContext, ServiceBuilder};
use crate::{proto, B3Digest, Error, Node}; use crate::{B3Digest, Error, Node, proto};
/// Stores directory closures in an object store. /// Stores directory closures in an object store.
/// Notably, this makes use of the option to disallow accessing child directories except when /// 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)] #[allow(clippy::identity_op)]
const MAX_FRAME_LENGTH: usize = 1 * 1024 * 1024 * 1000; // 1 MiB const MAX_FRAME_LENGTH: usize = 1 * 1024 * 1024 * 1000; // 1 MiB
// //
impl ObjectStoreDirectoryService { impl ObjectStoreDirectoryService {
/// Constructs a new [ObjectStoreDirectoryService] from a [Url] supported by /// Constructs a new [ObjectStoreDirectoryService] from a [Url] supported by
/// [object_store]. /// [object_store].

View file

@ -107,8 +107,8 @@ impl OrderValidator for LeavesToRootValidator {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{LeavesToRootValidator, RootToLeavesValidator}; use super::{LeavesToRootValidator, RootToLeavesValidator};
use crate::directoryservice::order_validator::OrderValidator;
use crate::directoryservice::Directory; use crate::directoryservice::Directory;
use crate::directoryservice::order_validator::OrderValidator;
use crate::fixtures::{DIRECTORY_A, DIRECTORY_B, DIRECTORY_C}; use crate::fixtures::{DIRECTORY_A, DIRECTORY_B, DIRECTORY_C};
use rstest::rstest; use rstest::rstest;

View file

@ -6,12 +6,13 @@ use tonic::async_trait;
use tracing::{instrument, warn}; use tracing::{instrument, warn};
use super::{ use super::{
traverse_directory, Directory, DirectoryGraph, DirectoryPutter, DirectoryService, Directory, DirectoryGraph, DirectoryPutter, DirectoryService, LeavesToRootValidator,
LeavesToRootValidator, traverse_directory,
}; };
use crate::{ use crate::{
B3Digest, Error,
composition::{CompositionContext, ServiceBuilder}, composition::{CompositionContext, ServiceBuilder},
proto, B3Digest, Error, proto,
}; };
const DIRECTORY_TABLE: TableDefinition<[u8; B3Digest::LENGTH], Vec<u8>> = const DIRECTORY_TABLE: TableDefinition<[u8; B3Digest::LENGTH], Vec<u8>> =

View file

@ -1,6 +1,6 @@
use crate::directoryservice::{DirectoryService, GRPCDirectoryService}; use crate::directoryservice::{DirectoryService, GRPCDirectoryService};
use crate::proto::directory_service_client::DirectoryServiceClient;
use crate::proto::GRPCDirectoryServiceWrapper; use crate::proto::GRPCDirectoryServiceWrapper;
use crate::proto::directory_service_client::DirectoryServiceClient;
use crate::{ use crate::{
directoryservice::MemoryDirectoryService, directoryservice::MemoryDirectoryService,
proto::directory_service_server::DirectoryServiceServer, proto::directory_service_server::DirectoryServiceServer,

View file

@ -1,4 +1,4 @@
use crate::{directoryservice::DirectoryService, Error, Node, Path}; use crate::{Error, Node, Path, directoryservice::DirectoryService};
use tracing::{instrument, warn}; use tracing::{instrument, warn};
/// This descends from a (root) node to the given (sub)path, returning the Node /// This descends from a (root) node to the given (sub)path, returning the Node
@ -51,9 +51,8 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
directoryservice, Node, PathBuf, directoryservice,
fixtures::{DIRECTORY_COMPLICATED, DIRECTORY_WITH_KEEP, EMPTY_BLOB_DIGEST}, fixtures::{DIRECTORY_COMPLICATED, DIRECTORY_WITH_KEEP, EMPTY_BLOB_DIGEST},
Node, PathBuf,
}; };
use super::descend_to; use super::descend_to;

View file

@ -4,8 +4,8 @@ use tokio::task::JoinError;
use tonic::Status; use tonic::Status;
use crate::{ use crate::{
path::{PathComponent, PathComponentError},
SymlinkTargetError, SymlinkTargetError,
path::{PathComponent, PathComponentError},
}; };
/// Errors related to communication with the store. /// Errors related to communication with the store.

View file

@ -8,17 +8,18 @@ use std::{
sync::Arc, sync::Arc,
}; };
use tempfile::TempDir; use tempfile::TempDir;
use tokio_stream::{wrappers::ReadDirStream, StreamExt}; use tokio_stream::{StreamExt, wrappers::ReadDirStream};
use super::FuseDaemon; use super::FuseDaemon;
use crate::{ use crate::{
Node,
blobservice::{BlobService, MemoryBlobService}, blobservice::{BlobService, MemoryBlobService},
directoryservice::{DirectoryService, MemoryDirectoryService}, directoryservice::{DirectoryService, MemoryDirectoryService},
fixtures, Node, fixtures,
}; };
use crate::{ use crate::{
fs::{SnixStoreFs, XATTR_NAME_BLOB_DIGEST, XATTR_NAME_DIRECTORY_DIGEST},
PathComponent, PathComponent,
fs::{SnixStoreFs, XATTR_NAME_BLOB_DIGEST, XATTR_NAME_DIRECTORY_DIGEST},
}; };
const BLOB_A_NAME: &str = "00000000000000000000000000000000-test"; const BLOB_A_NAME: &str = "00000000000000000000000000000000-test";

View file

@ -2,7 +2,7 @@
//! about inodes, which present snix-castore nodes in a filesystem. //! about inodes, which present snix-castore nodes in a filesystem.
use std::time::Duration; use std::time::Duration;
use crate::{path::PathComponent, B3Digest, Node}; use crate::{B3Digest, Node, path::PathComponent};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum InodeData { pub enum InodeData {

View file

@ -16,13 +16,13 @@ use self::{
inodes::{DirectoryInodeData, InodeData}, inodes::{DirectoryInodeData, InodeData},
}; };
use crate::{ use crate::{
B3Digest, Node,
blobservice::{BlobReader, BlobService}, blobservice::{BlobReader, BlobService},
directoryservice::DirectoryService, directoryservice::DirectoryService,
path::PathComponent, path::PathComponent,
B3Digest, Node,
}; };
use bstr::ByteVec; 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::{ use fuse_backend_rs::api::filesystem::{
Context, FileSystem, FsOptions, GetxattrReply, ListxattrReply, ROOT_ID, Context, FileSystem, FsOptions, GetxattrReply, ListxattrReply, ROOT_ID,
}; };
@ -33,7 +33,7 @@ use std::{
collections::HashMap, collections::HashMap,
io, io,
sync::atomic::AtomicU64, sync::atomic::AtomicU64,
sync::{atomic::Ordering, Arc}, sync::{Arc, atomic::Ordering},
time::Duration, time::Duration,
}; };
use std::{ffi::CStr, io::Cursor}; use std::{ffi::CStr, io::Cursor};
@ -41,7 +41,7 @@ use tokio::{
io::{AsyncReadExt, AsyncSeekExt}, io::{AsyncReadExt, AsyncSeekExt},
sync::mpsc, 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 /// This implements a read-only FUSE filesystem for a snix-store
/// with the passed [BlobService], [DirectoryService] and [RootNodes]. /// with the passed [BlobService], [DirectoryService] and [RootNodes].

View file

@ -1,7 +1,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use crate::nodes::Directory; use crate::nodes::Directory;
use crate::{path::PathComponent, Error, Node}; use crate::{Error, Node, path::PathComponent};
use futures::stream::BoxStream; use futures::stream::BoxStream;
use tonic::async_trait; use tonic::async_trait;

View file

@ -2,18 +2,18 @@
use std::collections::HashMap; use std::collections::HashMap;
use petgraph::Direction;
use petgraph::graph::{DiGraph, NodeIndex}; use petgraph::graph::{DiGraph, NodeIndex};
use petgraph::visit::{DfsPostOrder, EdgeRef}; use petgraph::visit::{DfsPostOrder, EdgeRef};
use petgraph::Direction;
use tokio::io::AsyncRead; use tokio::io::AsyncRead;
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
use tokio_tar::Archive; use tokio_tar::Archive;
use tracing::{instrument, warn, Level}; use tracing::{Level, instrument, warn};
use crate::Node;
use crate::blobservice::BlobService; use crate::blobservice::BlobService;
use crate::directoryservice::DirectoryService; use crate::directoryservice::DirectoryService;
use crate::import::{ingest_entries, IngestionEntry, IngestionError}; use crate::import::{IngestionEntry, IngestionError, ingest_entries};
use crate::Node;
use super::blobs::{self, ConcurrentBlobUploader}; use super::blobs::{self, ConcurrentBlobUploader};
@ -295,8 +295,8 @@ mod test {
use std::sync::LazyLock; use std::sync::LazyLock;
use super::{Error, IngestionEntryGraph}; use super::{Error, IngestionEntryGraph};
use crate::import::IngestionEntry;
use crate::B3Digest; use crate::B3Digest;
use crate::import::IngestionEntry;
use rstest::rstest; use rstest::rstest;

View file

@ -9,9 +9,9 @@ use tokio::{
task::{JoinError, JoinSet}, task::{JoinError, JoinSet},
}; };
use tokio_util::io::InspectReader; 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 /// Files smaller than this threshold, in bytes, are uploaded to the [BlobService] in the
/// background. /// background.

View file

@ -1,17 +1,17 @@
//! Import from a real filesystem. //! Import from a real filesystem.
use futures::stream::BoxStream;
use futures::StreamExt; use futures::StreamExt;
use futures::stream::BoxStream;
use std::fs::FileType; use std::fs::FileType;
use std::os::unix::ffi::OsStringExt; use std::os::unix::ffi::OsStringExt;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
use tokio::io::BufReader; use tokio::io::BufReader;
use tokio_util::io::InspectReader; use tokio_util::io::InspectReader;
use tracing::info_span;
use tracing::instrument;
use tracing::Instrument; use tracing::Instrument;
use tracing::Span; use tracing::Span;
use tracing::info_span;
use tracing::instrument;
use tracing_indicatif::span_ext::IndicatifSpanExt; use tracing_indicatif::span_ext::IndicatifSpanExt;
use walkdir::DirEntry; use walkdir::DirEntry;
use walkdir::WalkDir; use walkdir::WalkDir;
@ -21,9 +21,9 @@ use crate::directoryservice::DirectoryService;
use crate::refscan::{ReferenceReader, ReferenceScanner}; use crate::refscan::{ReferenceReader, ReferenceScanner};
use crate::{B3Digest, Node}; use crate::{B3Digest, Node};
use super::ingest_entries;
use super::IngestionEntry; use super::IngestionEntry;
use super::IngestionError; use super::IngestionError;
use super::ingest_entries;
/// Ingests the contents at a given path into the snix store, interacting with a [BlobService] and /// 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. /// [DirectoryService]. It returns the root node or an error.

View file

@ -211,11 +211,11 @@ mod test {
use rstest::rstest; use rstest::rstest;
use crate::fixtures::{DIRECTORY_COMPLICATED, DIRECTORY_WITH_KEEP, EMPTY_BLOB_DIGEST}; use crate::fixtures::{DIRECTORY_COMPLICATED, DIRECTORY_WITH_KEEP, EMPTY_BLOB_DIGEST};
use crate::{directoryservice::MemoryDirectoryService, fixtures::DUMMY_DIGEST};
use crate::{Directory, Node}; use crate::{Directory, Node};
use crate::{directoryservice::MemoryDirectoryService, fixtures::DUMMY_DIGEST};
use super::ingest_entries;
use super::IngestionEntry; use super::IngestionEntry;
use super::ingest_entries;
#[rstest] #[rstest]
#[case::single_file(vec![IngestionEntry::Regular { #[case::single_file(vec![IngestionEntry::Regular {

View file

@ -1,6 +1,6 @@
use std::collections::btree_map::{self, BTreeMap}; 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. /// 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. /// It attaches names to these nodes, which is the basename in that directory.

View file

@ -152,7 +152,7 @@ mod tests {
use bytes::Bytes; use bytes::Bytes;
use rstest::rstest; use rstest::rstest;
use super::{validate_name, PathComponent, PathComponentError}; use super::{PathComponent, PathComponentError, validate_name};
#[rstest] #[rstest]
#[case::empty(b"", PathComponentError::Empty)] #[case::empty(b"", PathComponentError::Empty)]

View file

@ -1,14 +1,14 @@
use crate::{blobservice::BlobService, B3Digest}; use crate::{B3Digest, blobservice::BlobService};
use core::pin::pin; use core::pin::pin;
use futures::{stream::BoxStream, TryFutureExt}; use futures::{TryFutureExt, stream::BoxStream};
use std::{ use std::{
collections::VecDeque, collections::VecDeque,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
use tokio_util::io::ReaderStream; use tokio_util::io::ReaderStream;
use tonic::{async_trait, Request, Response, Status, Streaming}; use tonic::{Request, Response, Status, Streaming, async_trait};
use tracing::{instrument, warn, Span}; use tracing::{Span, instrument, warn};
pub struct GRPCBlobServiceWrapper<T> { pub struct GRPCBlobServiceWrapper<T> {
blob_service: T, blob_service: T,

View file

@ -1,10 +1,10 @@
use crate::directoryservice::{DirectoryGraph, DirectoryService, LeavesToRootValidator}; use crate::directoryservice::{DirectoryGraph, DirectoryService, LeavesToRootValidator};
use crate::{proto, B3Digest, DirectoryError}; use crate::{B3Digest, DirectoryError, proto};
use futures::stream::BoxStream;
use futures::TryStreamExt; use futures::TryStreamExt;
use futures::stream::BoxStream;
use std::ops::Deref; use std::ops::Deref;
use tokio_stream::once; use tokio_stream::once;
use tonic::{async_trait, Request, Response, Status, Streaming}; use tonic::{Request, Response, Status, Streaming, async_trait};
use tracing::{instrument, warn}; use tracing::{instrument, warn};
pub struct GRPCDirectoryServiceWrapper<T> { pub struct GRPCDirectoryServiceWrapper<T> {

View file

@ -5,7 +5,7 @@ use std::cmp::Ordering;
mod grpc_blobservice_wrapper; mod grpc_blobservice_wrapper;
mod grpc_directoryservice_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_blobservice_wrapper::GRPCBlobServiceWrapper;
pub use grpc_directoryservice_wrapper::GRPCDirectoryServiceWrapper; pub use grpc_directoryservice_wrapper::GRPCDirectoryServiceWrapper;

View file

@ -1,5 +1,5 @@
use crate::proto::{Directory, DirectoryEntry, DirectoryError, FileEntry, SymlinkEntry};
use crate::ValidateNodeError; use crate::ValidateNodeError;
use crate::proto::{Directory, DirectoryEntry, DirectoryError, FileEntry, SymlinkEntry};
use hex_literal::hex; use hex_literal::hex;

View file

@ -1,4 +1,4 @@
use super::{entry, Entry, SymlinkEntry}; use super::{Entry, SymlinkEntry, entry};
use crate::DirectoryError; use crate::DirectoryError;
mod directory; mod directory;

View file

@ -9,9 +9,9 @@
use pin_project::pin_project; use pin_project::pin_project;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::pin::Pin; use std::pin::Pin;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; 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 tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};
use wu_manber::TwoByteWM; use wu_manber::TwoByteWM;

View file

@ -1,8 +1,8 @@
use crate::Node;
use crate::blobservice::{self, BlobService}; use crate::blobservice::{self, BlobService};
use crate::directoryservice; use crate::directoryservice;
use crate::fixtures::*; use crate::fixtures::*;
use crate::import::fs::ingest_path; use crate::import::fs::ingest_path;
use crate::Node;
use tempfile::TempDir; use tempfile::TempDir;
@ -105,16 +105,20 @@ async fn complicated() {
); );
// ensure DIRECTORY_WITH_KEEP and DIRECTORY_COMPLICATED have been uploaded // ensure DIRECTORY_WITH_KEEP and DIRECTORY_COMPLICATED have been uploaded
assert!(directory_service assert!(
directory_service
.get(&DIRECTORY_WITH_KEEP.digest()) .get(&DIRECTORY_WITH_KEEP.digest())
.await .await
.unwrap() .unwrap()
.is_some()); .is_some()
assert!(directory_service );
assert!(
directory_service
.get(&DIRECTORY_COMPLICATED.digest()) .get(&DIRECTORY_COMPLICATED.digest())
.await .await
.unwrap() .unwrap()
.is_some()); .is_some()
);
// ensure EMPTY_BLOB_CONTENTS has been uploaded // ensure EMPTY_BLOB_CONTENTS has been uploaded
assert!(blob_service.has(&EMPTY_BLOB_DIGEST).await.unwrap()); assert!(blob_service.has(&EMPTY_BLOB_DIGEST).await.unwrap());

View file

@ -4,7 +4,7 @@ use url::Url;
use crate::blobservice::BlobService; use crate::blobservice::BlobService;
use crate::composition::{ use crate::composition::{
with_registry, Composition, DeserializeWithRegistry, ServiceBuilder, REG, Composition, DeserializeWithRegistry, REG, ServiceBuilder, with_registry,
}; };
use crate::directoryservice::DirectoryService; use crate::directoryservice::DirectoryService;

2
snix/store/rustfmt.toml Normal file
View file

@ -0,0 +1,2 @@
# FUTUREWORK: move to .. once all crates are migrated (#114)
edition = "2024"

View file

@ -20,16 +20,16 @@ use tonic::transport::Server;
use tower::ServiceBuilder; use tower::ServiceBuilder;
use tower_http::classify::{GrpcCode, GrpcErrorsAsFailures, SharedClassifier}; use tower_http::classify::{GrpcCode, GrpcErrorsAsFailures, SharedClassifier};
use tower_http::trace::{DefaultMakeSpan, TraceLayer}; 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 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::GRPCBlobServiceWrapper;
use snix_castore::proto::GRPCDirectoryServiceWrapper; 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::pathinfoservice::{PathInfo, PathInfoService};
use snix_store::proto::path_info_service_server::PathInfoServiceServer;
use snix_store::proto::GRPCPathInfoServiceWrapper; use snix_store::proto::GRPCPathInfoServiceWrapper;
use snix_store::proto::path_info_service_server::PathInfoServiceServer;
#[cfg(any(feature = "fuse", feature = "virtiofs"))] #[cfg(any(feature = "fuse", feature = "virtiofs"))]
use snix_store::pathinfoservice::make_fs; use snix_store::pathinfoservice::make_fs;

View file

@ -2,10 +2,10 @@ use crate::pathinfoservice::PathInfo;
use md5::Digest; use md5::Digest;
use nix_compat::nixhash::{CAHash, NixHash}; use nix_compat::nixhash::{CAHash, NixHash};
use nix_compat::store_path::StorePath; use nix_compat::store_path::StorePath;
use snix_castore::Node;
use snix_castore::fixtures::{ use snix_castore::fixtures::{
DIRECTORY_COMPLICATED, DUMMY_DIGEST, HELLOWORLD_BLOB_CONTENTS, HELLOWORLD_BLOB_DIGEST, DIRECTORY_COMPLICATED, DUMMY_DIGEST, HELLOWORLD_BLOB_CONTENTS, HELLOWORLD_BLOB_DIGEST,
}; };
use snix_castore::Node;
use std::sync::LazyLock; use std::sync::LazyLock;
pub const DUMMY_PATH_STR: &str = "00000000000000000000000000000000-dummy"; pub const DUMMY_PATH_STR: &str = "00000000000000000000000000000000-dummy";

View file

@ -1,6 +1,6 @@
use bstr::ByteSlice; use bstr::ByteSlice;
use snix_castore::{ 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 std::path::Path;
use tracing::{debug, instrument}; use tracing::{debug, instrument};

View file

@ -1,10 +1,10 @@
use std::{ use std::{
io::Result, io::Result,
pin::Pin, 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 nix_compat::nixhash::{HashAlgo, NixHash};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, ReadBuf}; use tokio::io::{AsyncRead, ReadBuf};

View file

@ -4,13 +4,14 @@ use nix_compat::{
}; };
use sha2::Digest; use sha2::Digest;
use snix_castore::{ use snix_castore::{
Node, PathBuf,
blobservice::BlobService, blobservice::BlobService,
directoryservice::DirectoryService, directoryservice::DirectoryService,
import::{ import::{
IngestionEntry, IngestionError,
blobs::{self, ConcurrentBlobUploader}, blobs::{self, ConcurrentBlobUploader},
ingest_entries, IngestionEntry, IngestionError, ingest_entries,
}, },
Node, PathBuf,
}; };
use tokio::{ use tokio::{
io::{AsyncBufRead, AsyncRead}, io::{AsyncBufRead, AsyncRead},
@ -232,7 +233,7 @@ mod test {
use crate::fixtures::{ use crate::fixtures::{
NAR_CONTENTS_COMPLICATED, NAR_CONTENTS_HELLOWORLD, NAR_CONTENTS_SYMLINK, 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::io::Cursor;
use std::sync::Arc; use std::sync::Arc;

View file

@ -5,10 +5,10 @@ mod hashing_reader;
mod import; mod import;
mod renderer; mod renderer;
pub mod seekable; 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::calculate_size_and_sha256;
pub use renderer::write_nar; pub use renderer::write_nar;
pub use renderer::SimpleRenderer;
use snix_castore::Node; use snix_castore::Node;
#[async_trait] #[async_trait]
@ -44,7 +44,9 @@ pub enum RenderError {
#[error("unable to find blob {0}, referred from {1:?}")] #[error("unable to find blob {0}, referred from {1:?}")]
BlobNotFound(B3Digest, bytes::Bytes), 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), UnexpectedBlobMeta(B3Digest, bytes::Bytes, u32, u32),
#[error("failure using the NAR writer: {0}")] #[error("failure using the NAR writer: {0}")]

View file

@ -4,7 +4,7 @@ use super::{NarCalculationService, RenderError};
use count_write::CountWrite; use count_write::CountWrite;
use nix_compat::nar::writer::r#async as nar_writer; use nix_compat::nar::writer::r#async as nar_writer;
use sha2::{Digest, Sha256}; 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 tokio::io::{self, AsyncWrite, BufReader};
use tonic::async_trait; use tonic::async_trait;
use tracing::instrument; use tracing::instrument;

View file

@ -11,16 +11,16 @@ use super::RenderError;
use bytes::{BufMut, Bytes}; use bytes::{BufMut, Bytes};
use nix_compat::nar::writer::sync as nar_writer; use nix_compat::nar::writer::sync as nar_writer;
use snix_castore::Directory;
use snix_castore::blobservice::{BlobReader, BlobService}; use snix_castore::blobservice::{BlobReader, BlobService};
use snix_castore::directoryservice::{ use snix_castore::directoryservice::{
DirectoryGraph, DirectoryService, RootToLeavesValidator, ValidatedDirectoryGraph, DirectoryGraph, DirectoryService, RootToLeavesValidator, ValidatedDirectoryGraph,
}; };
use snix_castore::Directory;
use snix_castore::{B3Digest, Node}; use snix_castore::{B3Digest, Node};
use futures::future::{BoxFuture, FusedFuture, TryMaybeDone};
use futures::FutureExt; use futures::FutureExt;
use futures::TryStreamExt; use futures::TryStreamExt;
use futures::future::{BoxFuture, FusedFuture, TryMaybeDone};
use tokio::io::AsyncSeekExt; 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( return Poll::Ready(Err(io::Error::new(
io::ErrorKind::UnexpectedEof, io::ErrorKind::UnexpectedEof,
"blob short read", "blob short read",
))) )));
} }
(false, true) => { (false, true) => {
buf.set_filled(prev_read_buf_pos); buf.set_filled(prev_read_buf_pos);

View file

@ -8,12 +8,12 @@ use futures::stream::BoxStream;
use nix_compat::nixbase32; use nix_compat::nixbase32;
use prost::Message; use prost::Message;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DurationSeconds}; use serde_with::{DurationSeconds, serde_as};
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use std::sync::Arc; use std::sync::Arc;
use tonic::async_trait; 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. /// There should not be more than 10 MiB in a single cell.
/// <https://cloud.google.com/bigtable/docs/schema-design#cells> /// <https://cloud.google.com/bigtable/docs/schema-design#cells>
@ -77,7 +77,7 @@ impl BigtablePathInfoService {
use async_process::{Command, Stdio}; use async_process::{Command, Stdio};
use tempfile::TempDir; use tempfile::TempDir;
use tokio_retry::{strategy::ExponentialBackoff, Retry}; use tokio_retry::{Retry, strategy::ExponentialBackoff};
let tmpdir = TempDir::new().unwrap(); let tmpdir = TempDir::new().unwrap();

View file

@ -2,8 +2,8 @@ use std::sync::Arc;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use nix_compat::nixbase32; use nix_compat::nixbase32;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use tonic::async_trait; use tonic::async_trait;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
@ -132,11 +132,12 @@ mod test {
let svc = create_pathinfoservice().await; let svc = create_pathinfoservice().await;
// query the PathInfo, things should not be there. // query the PathInfo, things should not be there.
assert!(svc assert!(
.get(*PATH_INFO.store_path.digest()) svc.get(*PATH_INFO.store_path.digest())
.await .await
.unwrap() .unwrap()
.is_none()); .is_none()
);
// insert it into the far one. // insert it into the far one.
svc.far.put(PATH_INFO.clone()).await.unwrap(); svc.far.put(PATH_INFO.clone()).await.unwrap();

View file

@ -1,10 +1,10 @@
use super::PathInfoService; use super::PathInfoService;
use crate::composition::REG; use crate::composition::REG;
use snix_castore::composition::{
with_registry, CompositionContext, DeserializeWithRegistry, ServiceBuilder,
};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::composition::{
CompositionContext, DeserializeWithRegistry, ServiceBuilder, with_registry,
};
use std::sync::Arc; use std::sync::Arc;
use url::Url; use url::Url;

View file

@ -1,9 +1,9 @@
use futures::stream::BoxStream;
use futures::StreamExt; use futures::StreamExt;
use futures::stream::BoxStream;
use nix_compat::store_path::StorePathRef; use nix_compat::store_path::StorePathRef;
use snix_castore::fs::{RootNodes, SnixStoreFs}; use snix_castore::fs::{RootNodes, SnixStoreFs};
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService};
use snix_castore::{Error, Node, PathComponent}; use snix_castore::{Error, Node, PathComponent};
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService};
use tonic::async_trait; use tonic::async_trait;
use super::PathInfoService; use super::PathInfoService;

View file

@ -6,12 +6,12 @@ use crate::{
use async_stream::try_stream; use async_stream::try_stream;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use nix_compat::nixbase32; use nix_compat::nixbase32;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::Node; use snix_castore::Node;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use std::sync::Arc; use std::sync::Arc;
use tonic::{async_trait, Code}; use tonic::{Code, async_trait};
use tracing::{instrument, warn, Span}; use tracing::{Span, instrument, warn};
use tracing_indicatif::span_ext::IndicatifSpanExt; use tracing_indicatif::span_ext::IndicatifSpanExt;
/// Connects to a (remote) snix-store PathInfoService over gRPC. /// Connects to a (remote) snix-store PathInfoService over gRPC.
@ -185,8 +185,8 @@ impl ServiceBuilder for GRPCPathInfoServiceConfig {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::pathinfoservice::tests::make_grpc_path_info_service_client;
use crate::pathinfoservice::PathInfoService; use crate::pathinfoservice::PathInfoService;
use crate::pathinfoservice::tests::make_grpc_path_info_service_client;
/// This ensures connecting via gRPC works as expected. /// This ensures connecting via gRPC works as expected.
#[tokio::test] #[tokio::test]

View file

@ -8,8 +8,8 @@ use tokio::sync::RwLock;
use tonic::async_trait; use tonic::async_trait;
use tracing::instrument; use tracing::instrument;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use super::{PathInfo, PathInfoService}; use super::{PathInfo, PathInfoService};
@ -111,11 +111,12 @@ mod test {
let svc = LruPathInfoService::with_capacity("test".into(), NonZeroUsize::new(1).unwrap()); let svc = LruPathInfoService::with_capacity("test".into(), NonZeroUsize::new(1).unwrap());
// pathinfo_1 should not be there // pathinfo_1 should not be there
assert!(svc assert!(
.get(*PATH_INFO.store_path.digest()) svc.get(*PATH_INFO.store_path.digest())
.await .await
.expect("no error") .expect("no error")
.is_none()); .is_none()
);
// insert it // insert it
svc.put(PATH_INFO.clone()).await.expect("no error"); svc.put(PATH_INFO.clone()).await.expect("no error");
@ -138,10 +139,11 @@ mod test {
); );
// … but pathinfo 1 not anymore. // … but pathinfo 1 not anymore.
assert!(svc assert!(
.get(*PATH_INFO.store_path.digest()) svc.get(*PATH_INFO.store_path.digest())
.await .await
.expect("no error") .expect("no error")
.is_none()); .is_none()
);
} }
} }

View file

@ -2,8 +2,8 @@ use super::{PathInfo, PathInfoService};
use async_stream::try_stream; use async_stream::try_stream;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use nix_compat::nixbase32; use nix_compat::nixbase32;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::composition::{CompositionContext, ServiceBuilder};
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tonic::async_trait; use tonic::async_trait;

View file

@ -15,8 +15,8 @@ mod tests;
use auto_impl::auto_impl; use auto_impl::auto_impl;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use snix_castore::composition::{Registry, ServiceBuilder};
use snix_castore::Error; use snix_castore::Error;
use snix_castore::composition::{Registry, ServiceBuilder};
use tonic::async_trait; use tonic::async_trait;
use crate::nar::NarCalculationService; use crate::nar::NarCalculationService;

View file

@ -1,6 +1,6 @@
use super::{PathInfo, PathInfoService}; use super::{PathInfo, PathInfoService};
use crate::nar::ingest_nar_and_hash; use crate::nar::ingest_nar_and_hash;
use futures::{stream::BoxStream, TryStreamExt}; use futures::{TryStreamExt, stream::BoxStream};
use nix_compat::{ use nix_compat::{
narinfo::{self, NarInfo, Signature}, narinfo::{self, NarInfo, Signature},
nixbase32, nixbase32,
@ -9,7 +9,7 @@ use nix_compat::{
}; };
use reqwest::StatusCode; use reqwest::StatusCode;
use snix_castore::composition::{CompositionContext, ServiceBuilder}; 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 std::sync::Arc;
use tokio::io::{self, AsyncRead}; use tokio::io::{self, AsyncRead};
use tonic::async_trait; use tonic::async_trait;

View file

@ -1,12 +1,12 @@
use super::{PathInfo, PathInfoService}; use super::{PathInfo, PathInfoService};
use crate::proto; use crate::proto;
use data_encoding::BASE64; use data_encoding::BASE64;
use futures::{stream::BoxStream, StreamExt}; use futures::{StreamExt, stream::BoxStream};
use prost::Message; use prost::Message;
use redb::{Database, ReadableTable, TableDefinition}; use redb::{Database, ReadableTable, TableDefinition};
use snix_castore::{ use snix_castore::{
composition::{CompositionContext, ServiceBuilder},
Error, Error,
composition::{CompositionContext, ServiceBuilder},
}; };
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};
use tokio_stream::wrappers::ReceiverStream; use tokio_stream::wrappers::ReceiverStream;

View file

@ -10,7 +10,7 @@ use snix_castore::composition::{CompositionContext, ServiceBuilder};
use snix_castore::Error; 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 nix_compat::nixbase32;
use tracing::instrument; use tracing::instrument;
@ -158,11 +158,12 @@ mod test {
); );
// Asking PathInfoService, it should not be there ... // Asking PathInfoService, it should not be there ...
assert!(svc assert!(
.get(*PATH_INFO.store_path.digest()) svc.get(*PATH_INFO.store_path.digest())
.await .await
.expect("no error") .expect("no error")
.is_none()); .is_none()
);
// insert it // insert it
svc.put(PATH_INFO.clone()).await.expect("no error"); svc.put(PATH_INFO.clone()).await.expect("no error");

View file

@ -8,9 +8,9 @@ use rstest_reuse::{self, *};
use super::{PathInfo, PathInfoService}; use super::{PathInfo, PathInfoService};
use crate::fixtures::{DUMMY_PATH_DIGEST, PATH_INFO}; use crate::fixtures::{DUMMY_PATH_DIGEST, PATH_INFO};
use crate::pathinfoservice::MemoryPathInfoService;
use crate::pathinfoservice::redb::RedbPathInfoService; use crate::pathinfoservice::redb::RedbPathInfoService;
use crate::pathinfoservice::test_signing_service; use crate::pathinfoservice::test_signing_service;
use crate::pathinfoservice::MemoryPathInfoService;
mod utils; mod utils;
pub use self::utils::make_grpc_path_info_service_client; 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)] #[apply(path_info_services)]
#[tokio::test] #[tokio::test]
async fn not_found(svc: impl PathInfoService) { async fn not_found(svc: impl PathInfoService) {
assert!(svc assert!(
.get(DUMMY_PATH_DIGEST) svc.get(DUMMY_PATH_DIGEST)
.await .await
.expect("must succeed") .expect("must succeed")
.is_none()); .is_none()
);
} }
/// Put a PathInfo into the store, get it back. /// Put a PathInfo into the store, get it back.

View file

@ -8,8 +8,8 @@ use crate::{
nar::{NarCalculationService, SimpleRenderer}, nar::{NarCalculationService, SimpleRenderer},
pathinfoservice::{GRPCPathInfoService, MemoryPathInfoService, PathInfoService}, pathinfoservice::{GRPCPathInfoService, MemoryPathInfoService, PathInfoService},
proto::{ proto::{
path_info_service_client::PathInfoServiceClient, GRPCPathInfoServiceWrapper, path_info_service_client::PathInfoServiceClient,
path_info_service_server::PathInfoServiceServer, GRPCPathInfoServiceWrapper, path_info_service_server::PathInfoServiceServer,
}, },
tests::fixtures::{blob_service, directory_service}, 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"))] #[cfg(all(feature = "cloud", feature = "integration"))]
pub(crate) async fn make_bigtable_path_info_service( pub(crate) async fn make_bigtable_path_info_service()
) -> crate::pathinfoservice::BigtablePathInfoService { -> crate::pathinfoservice::BigtablePathInfoService {
use crate::pathinfoservice::bigtable::BigtableParameters;
use crate::pathinfoservice::BigtablePathInfoService; use crate::pathinfoservice::BigtablePathInfoService;
use crate::pathinfoservice::bigtable::BigtableParameters;
BigtablePathInfoService::connect("test".into(), BigtableParameters::default_for_tests()) BigtablePathInfoService::connect("test".into(), BigtableParameters::default_for_tests())
.await .await

View file

@ -1,10 +1,10 @@
use crate::nar::{NarCalculationService, RenderError}; use crate::nar::{NarCalculationService, RenderError};
use crate::pathinfoservice::{PathInfo, PathInfoService}; use crate::pathinfoservice::{PathInfo, PathInfoService};
use crate::proto; use crate::proto;
use futures::{stream::BoxStream, TryStreamExt}; use futures::{TryStreamExt, stream::BoxStream};
use snix_castore::proto as castorepb; use snix_castore::proto as castorepb;
use std::ops::Deref; use std::ops::Deref;
use tonic::{async_trait, Request, Response, Result, Status}; use tonic::{Request, Response, Result, Status, async_trait};
use tracing::{instrument, warn}; use tracing::{instrument, warn};
pub struct GRPCPathInfoServiceWrapper<PS, NS> { pub struct GRPCPathInfoServiceWrapper<PS, NS> {

View file

@ -3,9 +3,9 @@ use crate::nar::write_nar;
use crate::tests::fixtures::*; use crate::tests::fixtures::*;
use rstest::*; use rstest::*;
use rstest_reuse::*; use rstest_reuse::*;
use snix_castore::Node;
use snix_castore::blobservice::BlobService; use snix_castore::blobservice::BlobService;
use snix_castore::directoryservice::DirectoryService; use snix_castore::directoryservice::DirectoryService;
use snix_castore::Node;
use std::io; use std::io;
use std::sync::Arc; use std::sync::Arc;
use tokio::io::sink; use tokio::io::sink;

View file

@ -4,9 +4,9 @@ use crate::tests::fixtures::directory_service_with_contents as directory_service
use crate::tests::fixtures::*; use crate::tests::fixtures::*;
use rstest::*; use rstest::*;
use rstest_reuse::*; use rstest_reuse::*;
use snix_castore::Node;
use snix_castore::blobservice::BlobService; use snix_castore::blobservice::BlobService;
use snix_castore::directoryservice::DirectoryService; use snix_castore::directoryservice::DirectoryService;
use snix_castore::Node;
use std::io; use std::io;
use std::pin::Pin; use std::pin::Pin;
use std::sync::Arc; use std::sync::Arc;

View file

@ -14,7 +14,7 @@ use crate::composition::REG;
use crate::nar::{NarCalculationService, SimpleRenderer}; use crate::nar::{NarCalculationService, SimpleRenderer};
use crate::pathinfoservice::PathInfoService; use crate::pathinfoservice::PathInfoService;
use snix_castore::composition::{ use snix_castore::composition::{
with_registry, Composition, DeserializeWithRegistry, ServiceBuilder, Composition, DeserializeWithRegistry, ServiceBuilder, with_registry,
}; };
#[derive(serde::Deserialize, Default)] #[derive(serde::Deserialize, Default)]