@@ -62,6 +62,8 @@ use bookmarks::ArcBookmarks;
6262use bookmarks:: CachedBookmarks ;
6363use bookmarks:: bookmark_heads_fetcher;
6464use bookmarks_cache:: ArcBookmarksCache ;
65+ use bookmarks_cache:: ArcScopedBookmarksCache ;
66+ use bookmarks_cache:: CombinedBookmarksCache ;
6567use bookmarks_cache:: WarmerRequirement ;
6668use bundle_uri:: ArcGitBundleUri ;
6769use bundle_uri:: SqlGitBundleMetadataStorageBuilder ;
@@ -1687,6 +1689,28 @@ impl RepoFactory {
16871689 repo_event_publisher : & ArcRepoEventPublisher ,
16881690 phases : & ArcPhases ,
16891691 ) -> Result < ArcBookmarksCache > {
1692+ let cache = self
1693+ . build_bookmarks_cache_impl (
1694+ bookmarks,
1695+ bookmark_update_log,
1696+ repo_identity,
1697+ repo_derived_data,
1698+ repo_event_publisher,
1699+ phases,
1700+ )
1701+ . await ?;
1702+ Ok ( cache as ArcBookmarksCache )
1703+ }
1704+
1705+ async fn build_bookmarks_cache_impl (
1706+ & self ,
1707+ bookmarks : & ArcBookmarks ,
1708+ bookmark_update_log : & ArcBookmarkUpdateLog ,
1709+ repo_identity : & ArcRepoIdentity ,
1710+ repo_derived_data : & ArcRepoDerivedData ,
1711+ repo_event_publisher : & ArcRepoEventPublisher ,
1712+ phases : & ArcPhases ,
1713+ ) -> Result < Arc < dyn CombinedBookmarksCache + Send + Sync > > {
16901714 let warmer_requirement: WarmerRequirement =
16911715 ( & self . env . bookmark_cache_options . derived_data ) . into ( ) ;
16921716
@@ -1727,7 +1751,8 @@ impl RepoFactory {
17271751 BookmarkCacheDerivedData :: NoDerivation => { }
17281752 }
17291753
1730- Ok ( Arc :: new ( wbc_builder. build ( ) . watched ( ) . await ?) )
1754+ Ok ( Arc :: new ( wbc_builder. build ( ) . watched ( ) . await ?)
1755+ as Arc < dyn CombinedBookmarksCache + Send + Sync > )
17311756 }
17321757 #[ cfg( fbcode_build) ]
17331758 BookmarkCacheKind :: Remote ( address) => {
@@ -1759,18 +1784,41 @@ impl RepoFactory {
17591784 warmer_requirement,
17601785 ) ;
17611786
1762- Ok ( Arc :: new ( repo_client) )
1787+ Ok ( Arc :: new ( repo_client) as Arc < dyn CombinedBookmarksCache + Send + Sync > )
17631788 }
17641789 #[ cfg( not( fbcode_build) ) ]
17651790 BookmarkCacheKind :: Remote ( _addr) => {
17661791 return Err ( anyhow:: anyhow!(
17671792 "Remote bookmark cache not supported in non-fbcode builds"
17681793 ) ) ;
17691794 }
1770- BookmarkCacheKind :: Disabled => Ok ( Arc :: new ( NoopBookmarksCache :: new ( bookmarks. clone ( ) ) ) ) ,
1795+ BookmarkCacheKind :: Disabled => Ok ( Arc :: new ( NoopBookmarksCache :: new ( bookmarks. clone ( ) ) )
1796+ as Arc < dyn CombinedBookmarksCache + Send + Sync > ) ,
17711797 }
17721798 }
17731799
1800+ pub async fn scoped_bookmarks_cache (
1801+ & self ,
1802+ bookmarks : & ArcBookmarks ,
1803+ bookmark_update_log : & ArcBookmarkUpdateLog ,
1804+ repo_identity : & ArcRepoIdentity ,
1805+ repo_derived_data : & ArcRepoDerivedData ,
1806+ repo_event_publisher : & ArcRepoEventPublisher ,
1807+ phases : & ArcPhases ,
1808+ ) -> Result < ArcScopedBookmarksCache > {
1809+ let cache = self
1810+ . build_bookmarks_cache_impl (
1811+ bookmarks,
1812+ bookmark_update_log,
1813+ repo_identity,
1814+ repo_derived_data,
1815+ repo_event_publisher,
1816+ phases,
1817+ )
1818+ . await ?;
1819+ Ok ( cache as ArcScopedBookmarksCache )
1820+ }
1821+
17741822 pub async fn target_repo_dbs (
17751823 & self ,
17761824 bookmarks : & ArcBookmarks ,
0 commit comments