docs(tvix/castore): rename traverse_to -> descend_to

With the move of this code out into castore it has become apparent this
is a general descent inside the castore. Concerns like making sure the
whole Directory closure has been fetched/is fetched initially is nothing
this layer needs to worry about. We can handle this during substitution
of a new PathInfo, once there's store composition.

Closes b/270.

Change-Id: I661ed08e54bc81478e032cfb9abeb23e5b337fbe
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9373
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
Florian Klink 2023-09-22 01:08:13 +03:00 committed by clbot
parent 7c9a52e3ee
commit d8ef0cfb4a
3 changed files with 14 additions and 18 deletions

View file

@ -90,7 +90,7 @@ impl TvixStoreIO {
let directory_service = self.directory_service.clone();
let sub_path = sub_path.to_owned();
let task = self.tokio_handle.spawn(async move {
directoryservice::traverse_to(directory_service, root_node, &sub_path).await
directoryservice::descend_to(directory_service, root_node, &sub_path).await
});
Ok(self.tokio_handle.block_on(task).unwrap()?)

View file

@ -14,7 +14,7 @@ pub use self::from_addr::from_addr;
pub use self::grpc::GRPCDirectoryService;
pub use self::memory::MemoryDirectoryService;
pub use self::sled::SledDirectoryService;
pub use self::traverse::traverse_to;
pub use self::traverse::descend_to;
/// The base trait all Directory services need to implement.
/// This is a simple get and put of [crate::proto::Directory], returning their

View file

@ -3,14 +3,10 @@ use crate::{proto::NamedNode, B3Digest, Error};
use std::{os::unix::ffi::OsStrExt, sync::Arc};
use tracing::{instrument, warn};
/// This traverses 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
/// at that path, or none, if there's nothing at that path.
/// TODO: Do we want to use [DirectoryService.get_recursive] to do less lookups?
/// Or do we consider this to be a non-issue due to store composition and local caching?
/// TODO: the name of this function (and mod) is a bit bad, because it doesn't
/// clearly distinguish it from the BFS traversers.
#[instrument(skip(directory_service))]
pub async fn traverse_to(
pub async fn descend_to(
directory_service: Arc<dyn DirectoryService>,
root_node: crate::proto::node::Node,
path: &std::path::Path,
@ -93,10 +89,10 @@ mod tests {
utils::gen_directory_service,
};
use super::traverse_to;
use super::descend_to;
#[tokio::test]
async fn test_traverse_to() {
async fn test_descend_to() {
let directory_service = gen_directory_service();
let mut handle = directory_service.put_multiple_start();
@ -128,7 +124,7 @@ mod tests {
// traversal to an empty subpath should return the root node.
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from(""),
@ -141,7 +137,7 @@ mod tests {
// traversal to `keep` should return the node for DIRECTORY_WITH_KEEP
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("keep"),
@ -154,7 +150,7 @@ mod tests {
// traversal to `keep/.keep` should return the node for the .keep file
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("keep/.keep"),
@ -167,7 +163,7 @@ mod tests {
// traversal to `keep/.keep` should return the node for the .keep file
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("/keep/.keep"),
@ -180,7 +176,7 @@ mod tests {
// traversal to `void` should return None (doesn't exist)
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("void"),
@ -193,7 +189,7 @@ mod tests {
// traversal to `void` should return None (doesn't exist)
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("//v/oid"),
@ -207,7 +203,7 @@ mod tests {
// traversal to `keep/.keep/404` should return None (the path can't be
// reached, as keep/.keep already is a file)
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("keep/.keep/foo"),
@ -220,7 +216,7 @@ mod tests {
// traversal to a subpath of '/' should return the root node.
{
let resp = traverse_to(
let resp = descend_to(
directory_service.clone(),
node_directory_complicated.clone(),
&PathBuf::from("/"),