sapling/eden/fs/store/BackingStore.h
Katie Mancini a0b05b4bf0 thread ObjectFetchContext to backing store
Summary:
This passes ObjectFetchContext into the backing store to prepare for adding
logging for the cause of server fetches.

In following changes I will add logging in the HgQueuedBackingStore.
Ultimately we will want to move this logging to be closer to the data fetching
(in HgDatapackStore and HgImporter), but I plan to temporarily add logging to
the HgQueuedBackingStore to simplify so that we can more quickly roll out.

Reviewed By: chadaustin

Differential Revision: D22022992

fbshipit-source-id: ccb428458cbf7a1e33aaf9be9d0d766c45acedb3
2020-06-23 10:02:40 -07:00

70 lines
1.8 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/futures/Future.h>
#include <memory>
#include "eden/fs/store/ImportPriority.h"
#include "eden/fs/store/ObjectFetchContext.h"
namespace folly {
template <typename T>
class Future;
}
namespace facebook {
namespace eden {
class Blob;
class Hash;
class Tree;
/**
* Abstract interface for a BackingStore.
*
* A BackingStore fetches tree and blob information from an external
* authoritative data source.
*
* BackingStore implementations must be thread-safe, and perform their own
* internal locking.
*/
class BackingStore {
public:
BackingStore() {}
virtual ~BackingStore() {}
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTree(
const Hash& id,
ObjectFetchContext& context,
ImportPriority priority = ImportPriority::kNormal()) = 0;
virtual folly::SemiFuture<std::unique_ptr<Blob>> getBlob(
const Hash& id,
ObjectFetchContext& context,
ImportPriority priority = ImportPriority::kNormal()) = 0;
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
const Hash& commitID) = 0;
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
const Hash& commitID,
const Hash& manifestID) = 0;
FOLLY_NODISCARD virtual folly::SemiFuture<folly::Unit> prefetchBlobs(
const std::vector<Hash>& /*ids*/) {
return folly::unit;
}
virtual void periodicManagementTask() {}
private:
// Forbidden copy constructor and assignment operator
BackingStore(BackingStore const&) = delete;
BackingStore& operator=(BackingStore const&) = delete;
};
} // namespace eden
} // namespace facebook