From 207a42974b4d3f0e8a189f609512608cce51d63d Mon Sep 17 00:00:00 2001 From: Chris Dinh Date: Fri, 17 Jan 2025 10:59:07 -0800 Subject: [PATCH] Add call+fallback for streamJournalChanged to watchman Summary: # Context SubscribeStreamTemporary is a function that allows users to recieve notifications whenever there is a change to the edenFS journal. Despite intended to be a temporary function, it's been named as such for about 6 years. # This Diff This diff replaces the call for watchman to subscribeStreamTemporary with a call for streamJournalChanged. It adds a fallback call for older versions without streamJournalChanged Reviewed By: jdelliot Differential Revision: D68240121 fbshipit-source-id: 0c3f9e98060bf80c1e0e78b06d8ac102a8a19060 --- watchman/watcher/eden.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/watchman/watcher/eden.cpp b/watchman/watcher/eden.cpp index e4209a4881cf..772285fbd76e 100644 --- a/watchman/watcher/eden.cpp +++ b/watchman/watcher/eden.cpp @@ -1068,8 +1068,19 @@ class EdenView final : public QueryableView { GetJournalPositionCallback& getJournalPositionCallback, std::chrono::milliseconds settleTimeout) { auto client = getEdenClient(thriftChannel_); - auto stream = client->sync_subscribeStreamTemporary( - std::string(root->root_path.data(), root->root_path.size())); + apache::thrift::ClientBufferedStream<::facebook::eden::JournalPosition> + stream; + try { + stream = client->sync_streamJournalChanged( + std::string(root->root_path.data(), root->root_path.size())); + } catch (const apache::thrift::TApplicationException& exc) { + log(DBG, + "running eden version does not have streamJournalChanged, falling back to subscribeStreamTemporary: ", + exc.what(), + "\n"); + stream = client->sync_subscribeStreamTemporary( + std::string(root->root_path.data(), root->root_path.size())); + } return std::move(stream).subscribeExTry( &subscriberEventBase_, [&settleCallback,