Skip to content

Commit

Permalink
Refactored Thrift types for eden CLI
Browse files Browse the repository at this point in the history
Summary:
# Context

We are introducing EdenFS notifications to support scalable and ergonomic file system notifications for EdenFS mounts.

# This Diff

This diff creates local types (as opposed to Thrift types) to make it possible to add various traits. It also implements Display and From for these types and then updates changes-since and get-postion to use the new types

# Next Steps

* Collapsing journal entries
* .t tests, Python integration tests, C++ unit tests

# Discussion Points

None

Differential Revision: D66045966

fbshipit-source-id: 999b27c47877c2e1ced3febe983be5fee9ca1e36
  • Loading branch information
jdelliot authored and facebook-github-bot committed Nov 18, 2024
1 parent 8978657 commit 0137b47
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 164 deletions.
1 change: 1 addition & 0 deletions eden/fs/cli_rs/edenfs-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ edenfs-utils = { version = "0.1.0", path = "../edenfs-utils" }
fbinit = { version = "0.2.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
fbthrift_socket = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
futures = { version = "0.3.30", features = ["async-await", "compat"] }
hex = "0.4.3"
pathdiff = "0.2"
regex = "1.9.2"
sapling-atomicfile = { version = "0.1.0", path = "../../../scm/lib/atomicfile" }
Expand Down
1 change: 1 addition & 0 deletions eden/fs/cli_rs/edenfs-client/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rust_library(
"fbsource//third-party/rust:dirs",
"fbsource//third-party/rust:dunce",
"fbsource//third-party/rust:futures",
"fbsource//third-party/rust:hex",
"fbsource//third-party/rust:pathdiff",
"fbsource//third-party/rust:regex",
"fbsource//third-party/rust:serde",
Expand Down
18 changes: 10 additions & 8 deletions eden/fs/cli_rs/edenfs-client/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ use thrift_streaming_clients::errors::StreamStartStatusError;
use thrift_streaming_thriftclients::build_StreamingEdenService_client;
#[cfg(fbcode_build)]
use thrift_types::edenfs::ChangesSinceV2Params;
#[cfg(fbcode_build)]
use thrift_types::edenfs::ChangesSinceV2Result;
use thrift_types::edenfs::DaemonInfo;
use thrift_types::edenfs::JournalPosition;
use thrift_types::edenfs_clients::EdenService;
use thrift_types::fb303_core::fb303_status;
use thrift_types::fbthrift::binary_protocol::BinaryProtocol;
Expand Down Expand Up @@ -254,7 +251,7 @@ impl EdenFsInstance {
&self,
mount_point: &Option<PathBuf>,
timeout: Option<Duration>,
) -> Result<JournalPosition> {
) -> Result<crate::types::JournalPosition> {
let client = self
.connect(timeout)
.await
Expand All @@ -264,26 +261,31 @@ impl EdenFsInstance {
client
.getCurrentJournalPosition(&mount_point)
.await
.map(|p| p.into())
.from_err()
}

#[cfg(fbcode_build)]
pub async fn get_changes_since(
&self,
mount_point: &Option<PathBuf>,
from_position: &JournalPosition,
from_position: &crate::types::JournalPosition,
timeout: Option<Duration>,
) -> Result<ChangesSinceV2Result> {
) -> Result<crate::types::ChangesSinceV2Result> {
let client = self
.connect(timeout)
.await
.context("Unable to connect to EdenFS daemon")?;
let params = ChangesSinceV2Params {
mountPoint: bytes_from_path(get_mount_point(mount_point)?)?,
fromPosition: from_position.clone(),
fromPosition: from_position.clone().into(),
..Default::default()
};
client.changesSinceV2(&params).await.from_err()
client
.changesSinceV2(&params)
.await
.map(|r| r.into())
.from_err()
}

/// Returns a map of mount paths to mount names
Expand Down
7 changes: 1 addition & 6 deletions eden/fs/cli_rs/edenfs-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@ use thrift_streaming::EdenStartStatusUpdate;
use thrift_streaming_clients::errors::StreamStartStatusStreamError;
#[cfg(fbcode_build)]
use thrift_streaming_clients::StreamingEdenService;
#[cfg(fbcode_build)]
pub use thrift_types::edenfs::ChangeNotification;
#[cfg(fbcode_build)]
pub use thrift_types::edenfs::LargeChangeNotification;
#[cfg(fbcode_build)]
pub use thrift_types::edenfs::SmallChangeNotification;
use thrift_types::edenfs_clients::EdenService;

pub mod checkout;
pub mod fsutil;
pub mod instance;
mod mounttable;
pub mod redirect;
pub mod types;
pub mod utils;

pub use instance::DaemonHealthy;
Expand Down
Loading

0 comments on commit 0137b47

Please sign in to comment.