From 9d3f5ee1c27464577faa4ba2b8e49514bf6b2c49 Mon Sep 17 00:00:00 2001 From: John Elliott Date: Wed, 6 Nov 2024 11:53:23 -0800 Subject: [PATCH] Initial Thrift definitions to support EdenFS filesystem notifications Summary: # Context We are introducing EdenFS notifications to support scalable and ergonomic file system notifications for EdenFS mounts. # This Diff This diff introduces the initial Thrift definitions to support EdenFS filesystem notifications. It defines several new data structures and a single method `streamChangesSinceV2`. # Technical Details Simple-ish Thrift definitions that generate code, but are not used yet. # Discussion Points * There are two existing, simlar methods. One that has never been used as it was a hack-a-month project that was put on hold. The other is in use. The hack-a-month API, `streamSelectedChangesSince` could be removed now. The used method, `streamChangesSince` will need to remain until such time was we remove support for EdenFS mounts from Watchman. Reviewed By: MichaelCuevas Differential Revision: D65305161 fbshipit-source-id: 15a4b7cf89b37ebd1427193bfc06360006fa6bca --- eden/fs/service/streamingeden.thrift | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/eden/fs/service/streamingeden.thrift b/eden/fs/service/streamingeden.thrift index ac968f2d27ed..7ee67f8439a7 100644 --- a/eden/fs/service/streamingeden.thrift +++ b/eden/fs/service/streamingeden.thrift @@ -62,6 +62,54 @@ const i64 FS_EVENT_READ = 1; const i64 FS_EVENT_WRITE = 2; const i64 FS_EVENT_OTHER = 4; +struct CommitTransition { + 1: eden.ThriftRootId from; + 2: eden.ThriftRootId to; +} + +struct DirectoryRenamed { + 1: eden.PathString from; + 2: eden.PathString to; +} + +struct Renamed { + 1: eden.Dtype fileType; + 2: eden.PathString from; + 3: eden.PathString to; +} + +struct Added { + 1: eden.Dtype fileType; + 3: eden.PathString path; +} + +struct Deleted { + 1: eden.Dtype fileType; + 3: eden.PathString path; +} + +struct Modified { + 1: eden.Dtype fileType; + 3: eden.PathString path; +} + +union SmallChangeNotification { + 1: Renamed renamed; + 2: Added added; + 3: Deleted deleted; + 4: Modified modified; +} + +union LargeChangeNotification { + 1: DirectoryRenamed directoryRenamed; + 2: CommitTransition commitTransition; +} + +union ChangeNotification { + 1: SmallChangeNotification smallChange; + 2: LargeChangeNotification largeChange; +} + /** * The value of a stream item. * @@ -82,6 +130,23 @@ struct ChangesSinceResult { 1: eden.JournalPosition toPosition; } +/** + * The value of a stream item in a streamChangedSinceV2 result stream. + * + * Each stream item refers to a single change notification + * since the notification clock provided. + */ +struct ChangeNotificationResult { + 1: ChangeNotification change; +} + +/** + * Return value of the streamChangedSinceV2 API + */ +struct ChangesSinceV2Result { + 1: eden.JournalPosition toPosition; +} + /** * Argument to streamChangesSince API. */ @@ -98,6 +163,14 @@ struct StreamSelectedChangesSinceParams { 2: list globs; } +/** + * Argument to streamChangedSinceV2 API + */ +struct StreamChangesSinceV2Params { + 1: eden.PathString mountPoint; + 2: eden.JournalPosition fromPosition; +} + struct TraceTaskEventsRequest {} typedef binary EdenStartStatusUpdate @@ -196,6 +269,18 @@ service StreamingEdenService extends eden.EdenService { 1: eden.EdenError ex, ); + /** + * Returns a stream of change notifications for a given path since a specific point in time. + * + * This does not resolve expensive operations like moving a directory or changing + * commits. Callers must query Sapling to evaluate those potentially expensive operations. + */ + ChangesSinceV2Result, stream< + ChangeNotificationResult throws (1: eden.EdenError ex) + > streamChangesSinceV2(1: StreamChangesSinceV2Params params) throws ( + 1: eden.EdenError ex, + ); + /** * Same as the API above but only returns files that match the globs in filter. * This API is intend to replace the above API but it's currently under development.