Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::HttpBinaryCacheStore Class Reference
Inheritance diagram for nix::HttpBinaryCacheStore:
nix::BinaryCacheStore nix::Store nix::LogStore nix::StoreDirConfig nix::Store nix::StoreDirConfig nix::S3BinaryCacheStore nix::testing::TestHttpBinaryCacheStore

Public Types

using Config = HttpBinaryCacheStoreConfig
Public Types inherited from nix::BinaryCacheStore
using Config = BinaryCacheStoreConfig
Public Types inherited from nix::Store
using Config = StoreConfig
using PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>>

Public Member Functions

 HttpBinaryCacheStore (ref< Config > config, ref< FileTransfer > fileTransfer=getFileTransfer())
void init () override
StorePaths topoSortPaths (const StorePathSet &paths) override
Public Member Functions inherited from nix::BinaryCacheStore
void upsertFile (const std::string &path, std::string &&data, const std::string &mimeType, uint64_t sizeHint)
void upsertFile (const std::string &path, std::string &&data, const std::string &mimeType)
std::optional< std::string > getFile (const std::string &path)
bool isValidPathUncached (const StorePath &path) override
void queryPathInfoUncached (const StorePath &path, Callback< std::shared_ptr< const ValidPathInfo > > callback) noexcept override
std::optional< StorePath > queryPathFromHashPart (const std::string &hashPart) override
void addToStore (const ValidPathInfo &info, Source &narSource, RepairFlag repair, CheckSigsFlag checkSigs) override
void addMultipleToStore (PathsSource &&pathsToCopy, Activity &act, RepairFlag repair, CheckSigsFlag checkSigs) override
StorePath addToStoreFromDump (Source &dump, std::string_view name, FileSerialisationMethod dumpMethod, ContentAddressMethod hashMethod, HashAlgorithm hashAlgo, const StorePathSet &references, RepairFlag repair) override
StorePath addToStore (std::string_view name, const SourcePath &path, ContentAddressMethod method, HashAlgorithm hashAlgo, const StorePathSet &references, PathFilter &filter, RepairFlag repair) override
void registerDrvOutputUnchecked (const Realisation &info) override
void queryRealisationUncached (const DrvOutput &, Callback< std::shared_ptr< const UnkeyedRealisation > > callback) noexcept override
void narFromPath (const StorePath &path, Sink &sink) override
ref< SourceAccessor > getFSAccessor (bool requireValidPath=true) override
std::shared_ptr< SourceAccessor > getFSAccessor (const StorePath &, bool requireValidPath=true) override
void addSignatures (const StorePath &storePath, const std::set< Signature > &sigs) override
std::optional< std::string > getBuildLogExact (const StorePath &path) override
void addBuildLog (const StorePath &drvPath, std::string_view log) override
Public Member Functions inherited from nix::Store
 operator const Config & () const
virtual ref< Builder > getBuilder (std::shared_ptr< Store > evalStore=nullptr)
std::filesystem::path followLinksToStore (std::string_view path) const
StorePath followLinksToStorePath (std::string_view path) const
bool isValidPath (const StorePath &path)
void substitutePaths (const StorePathSet &paths)
virtual StorePathSet queryValidPaths (const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute)
virtual StorePathSet queryAllValidPaths ()
ref< const ValidPathInfo > queryPathInfo (const StorePath &path)
void queryPathInfo (const StorePath &path, Callback< ref< const ValidPathInfo > > callback) noexcept
std::optional< std::shared_ptr< const ValidPathInfo > > queryPathInfoFromClientCache (const StorePath &path)
std::shared_ptr< const UnkeyedRealisation > queryRealisation (const DrvOutput &)
void queryRealisation (const DrvOutput &, Callback< std::shared_ptr< const UnkeyedRealisation > > callback) noexcept
virtual bool pathInfoIsUntrusted (const ValidPathInfo &)
virtual bool realisationIsUntrusted (const Realisation &)
virtual void queryReferrers (const StorePath &path, StorePathSet &referrers)
virtual StorePathSet queryValidDerivers (const StorePath &path)
virtual StorePathSet queryDerivationOutputs (const StorePath &path)
virtual std::map< std::string, std::optional< StorePath > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
virtual std::map< std::string, std::optional< StorePath > > queryStaticPartialDerivationOutputMap (const StorePath &path)
virtual std::optional< StorePath > queryStaticPartialDerivationOutput (const StorePath &path, const std::string &outputName)
OutputPathMap queryDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
virtual StorePathSet querySubstitutablePaths (const StorePathSet &paths)
virtual void querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos)
ValidPathInfo addToStoreSlow (std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), std::optional< Hash > expectedCAHash={})
virtual void registerDrvOutput (const Realisation &output, CheckSigsFlag checkSigs)
virtual void addTempRoot (const StorePath &path)
virtual void addTempRoots (const StorePathSet &paths)
std::string makeValidityRegistration (const StorePathSet &paths, bool showDerivers, bool showHash)
virtual void optimiseStore ()
virtual bool verifyStore (bool checkContents, RepairFlag repair=NoRepair)
ref< SourceAccessor > requireStoreObjectAccessor (const StorePath &path, bool requireValidPath=true)
void signPathInfo (ValidPathInfo &info)
void signRealisation (Realisation &)
Derivation derivationFromPath (const StorePath &drvPath)
virtual StorePath writeDerivation (const Derivation &drv, RepairFlag repair=NoRepair)
virtual Derivation readDerivation (const StorePath &drvPath)
virtual Derivation readInvalidDerivation (const StorePath &drvPath)
virtual void computeFSClosure (const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
void computeFSClosure (const StorePath &path, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
virtual MissingPaths queryMissing (const std::vector< DerivedPath > &targets)
StorePathSet exportReferences (const StorePathSet &storePaths, const StorePathSet &inputPaths)
std::optional< StorePath > getBuildDerivationPath (const StorePath &)
void clearPathInfoCache ()
virtual void connect ()
virtual unsigned int getProtocol ()
virtual void setOptions ()
virtual std::optional< std::string > getVersion ()
Public Member Functions inherited from nix::StoreDirConfig
StorePath parseStorePath (std::string_view path) const
StorePath parseStorePathCanonical (std::string_view path) const
std::optional< StorePath > maybeParseStorePath (std::string_view path) const
std::string printStorePath (const StorePath &path) const
StringSet printStorePathSet (const StorePathSet &path) const
std::size_t maxCanonicalStorePathLen () const noexcept
bool isInStore (std::string_view path) const
bool isStorePath (std::string_view path) const
std::pair< StorePath, CanonPath > toStorePath (std::string_view path) const
StorePath makeStorePath (std::string_view type, std::string_view hash, std::string_view name) const
StorePath makeStorePath (std::string_view type, const Hash &hash, std::string_view name) const
StorePath makeOutputPath (std::string_view id, const Hash &hash, std::string_view name) const
StorePath makeFixedOutputPath (std::string_view name, const FixedOutputInfo &info) const
StorePath makeFixedOutputPathFromCA (std::string_view name, const ContentAddressWithReferences &ca) const
std::pair< StorePath, Hash > computeStorePath (std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references={}, PathFilter &filter=defaultPathFilter) const
Public Member Functions inherited from nix::LogStore
std::optional< std::string > getBuildLog (const StorePath &path)

Public Attributes

ref< Config > config
Public Attributes inherited from nix::BinaryCacheStore
Config & config
Public Attributes inherited from nix::Store
const Config & config
Public Attributes inherited from nix::StoreDirConfig
const std::string & storeDir

Protected Member Functions

std::optional< CompressionAlgo > getCompressionMethod (const std::string &path)
void disable (const Error &cause)
void checkEnabled ()
bool fileExists (const std::string &path) override
void upsertFile (const std::string &path, RestartableSource &source, const std::string &mimeType, uint64_t sizeHint) override
FileTransferRequest makeRequest (std::string_view path)
void upload (std::string_view path, RestartableSource &source, uint64_t sizeHint, std::string_view mimeType, std::optional< Headers > headers)
void getFile (const std::string &path, Sink &sink) override
void getFile (const std::string &path, Callback< std::optional< std::string > > callback) noexcept override
std::optional< std::string > getNixCacheInfo () override
std::optional< TrustedFlag > isTrustedClient () override
Protected Member Functions inherited from nix::BinaryCacheStore
 BinaryCacheStore (Config &)
std::string makeRealisationPath (const DrvOutput &id)
Protected Member Functions inherited from nix::Store
void invalidatePathInfoCacheFor (const StorePath &path)
 Store (const Store::Config &config)
void unsupported (const std::string &op)

Protected Attributes

ref< FileTransfer > fileTransfer
Protected Attributes inherited from nix::Store
std::shared_ptr< SharedSync< LRUCache< StorePath, PathInfoCacheValue > > > pathInfoCache
std::shared_ptr< NarInfoDiskCache > diskCache

Additional Inherited Members

Static Public Attributes inherited from nix::Store
static constexpr const char * MissingName = "x"
Static Public Attributes inherited from nix::LogStore
static std::string operationName = "Build log storage and retrieval"
Static Protected Attributes inherited from nix::BinaryCacheStore
static constexpr const std::string realisationsPrefix = "build-trace-v2"
static constexpr const std::string cacheInfoFile = "nix-cache-info"

Member Function Documentation

◆ disable()

void nix::HttpBinaryCacheStore::disable ( const Error & cause)
protected

Stop talking to this cache for a while, because a request to it just failed with cause.

◆ fileExists()

bool nix::HttpBinaryCacheStore::fileExists ( const std::string & path)
overrideprotectedvirtual

Implements nix::BinaryCacheStore.

◆ getFile() [1/2]

void nix::HttpBinaryCacheStore::getFile ( const std::string & path,
Callback< std::optional< std::string > > callback )
overrideprotectedvirtualnoexcept

Fetch the specified file and call the specified callback with the result. A subclass may implement this asynchronously.

Reimplemented from nix::BinaryCacheStore.

◆ getFile() [2/2]

void nix::HttpBinaryCacheStore::getFile ( const std::string & path,
Sink & sink )
overrideprotectedvirtual

Dump the contents of the specified file to a sink.

Reimplemented from nix::BinaryCacheStore.

◆ getNixCacheInfo()

std::optional< std::string > nix::HttpBinaryCacheStore::getNixCacheInfo ( )
overrideprotectedvirtual

Get the contents of /nix-cache-info. Return std::nullopt if it doesn't exist.

Reimplemented from nix::BinaryCacheStore.

◆ init()

void nix::HttpBinaryCacheStore::init ( )
overridevirtual

Perform any necessary effectful operation to make the store up and running

Reimplemented from nix::BinaryCacheStore.

Reimplemented in nix::testing::TestHttpBinaryCacheStore.

◆ isTrustedClient()

std::optional< TrustedFlag > nix::HttpBinaryCacheStore::isTrustedClient ( )
overrideprotectedvirtual

This isn't actually necessary read only. We support "upsert" now, so we have a notion of authentication via HTTP POST/PUT.

For now, we conservatively say we don't know.

Todo
try to expose our HTTP authentication status.

Implements nix::Store.

◆ topoSortPaths()

StorePaths nix::HttpBinaryCacheStore::topoSortPaths ( const StorePathSet & paths)
overridevirtual

Sort a set of paths topologically under the references relation. If p refers to q, then p precedes q in this list. Virtual to allow for more efficient implementations in derived classes.

Reimplemented from nix::Store.

◆ upload()

void nix::HttpBinaryCacheStore::upload ( std::string_view path,
RestartableSource & source,
uint64_t sizeHint,
std::string_view mimeType,
std::optional< Headers > headers )
protected

Uploads data to the binary cache.

This is a lower-level method that handles the actual upload after compression has been applied. It does not handle compression or error wrapping - those are the caller's responsibility.

Parameters
pathThe path in the binary cache to upload to
sourceThe data source (should already be compressed if needed)
sizeHintSize hint for the data
mimeTypeThe MIME type of the content
headersAdditional headers to include in the HTTP request.

◆ upsertFile()

void nix::HttpBinaryCacheStore::upsertFile ( const std::string & path,
RestartableSource & source,
const std::string & mimeType,
uint64_t sizeHint )
overrideprotectedvirtual

Implements nix::BinaryCacheStore.


The documentation for this class was generated from the following files: