BuildCache
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
bcache::http_cache_provider_t Class Reference
Inheritance diagram for bcache::http_cache_provider_t:
bcache::remote_cache_provider_t bcache::s3_cache_provider_t

Public Member Functions

bool connect (const std::string &host_description) override
 Connect to the remote cache. More...
 
bool is_connected () const override
 Check if we have a connection to the remote cache. More...
 
cache_entry_t lookup (const std::string &hash) override
 Check if an entry exists in the cache. More...
 
void add (const std::string &hash, const cache_entry_t &entry, const std::map< std::string, expected_file_t > &expected_files) override
 Adds a set of files to the cache. More...
 
void get_file (const std::string &hash, const std::string &source_id, const std::string &target_path, const bool is_compressed) override
 Copy a cached file to the local file system. More...
 
- Public Member Functions inherited from bcache::remote_cache_provider_t
virtual ~remote_cache_provider_t ()
 De-initialzie the remote cache object.
 

Protected Member Functions

std::string get_path () const
 Get the path of the destination URL. More...
 

Private Member Functions

virtual std::vector< std::string > get_header (const std::string &method, const std::string &key) const
 Get the headers for the HTTP request. More...
 
void disconnect ()
 Disconnect (usually as a result of an error).
 
std::string get_object_url (const std::string &key)
 Get the full URL for a given object. More...
 
std::string get_data (const std::string &key)
 Get a binary data blob from the remote cache. More...
 
void set_data (const std::string &key, const std::string &data)
 Set a binary data blob in the remote cache. More...
 

Private Attributes

std::string m_host
 
std::string m_path
 
int m_port
 
bool m_ready_for_action = false
 

Additional Inherited Members

- Static Protected Member Functions inherited from bcache::remote_cache_provider_t
static bool parse_host_description (const std::string &host_description, std::string &host, int &port, std::string &path)
 Parse a host description string. More...
 
static int connection_timeout_ms ()
 Get the timeout for remote connections. More...
 
static int transfer_timeout_ms ()
 Get the timeout for remote transfers. More...
 

Member Function Documentation

◆ add()

void bcache::http_cache_provider_t::add ( const std::string &  hash,
const cache_entry_t entry,
const std::map< std::string, expected_file_t > &  expected_files 
)
overridevirtual

Adds a set of files to the cache.

Parameters
hashThe cache entry identifier.
entryThe cache entry data (files, stdout, etc).
expected_filesPaths to the actual files in the local file system (map from file ID to an expected file descriptor).

Implements bcache::remote_cache_provider_t.

◆ connect()

bool bcache::http_cache_provider_t::connect ( const std::string &  host_description)
overridevirtual

Connect to the remote cache.

Parameters
host_descriptionA string describing the host to connect to (excluding protocol).
Returns
true if the connection was successful.

Implements bcache::remote_cache_provider_t.

Reimplemented in bcache::s3_cache_provider_t.

◆ get_data()

std::string bcache::http_cache_provider_t::get_data ( const std::string &  key)
private

Get a binary data blob from the remote cache.

Parameters
keyThe unique key that identifies the data.
Returns
the data as a string object.
Exceptions
runtime_errorif the data could not be retrieved (e.g. the key does not exist in the remote cache).

◆ get_file()

void bcache::http_cache_provider_t::get_file ( const std::string &  hash,
const std::string &  source_id,
const std::string &  target_path,
const bool  is_compressed 
)
overridevirtual

Copy a cached file to the local file system.

Parameters
hashThe cache entry identifier.
source_idThe ID of the remote file to copy.
target_pathThe path to the local file.
is_compressedTrue if the remote data is compressed.

Implements bcache::remote_cache_provider_t.

◆ get_header()

std::vector< std::string > bcache::http_cache_provider_t::get_header ( const std::string &  method,
const std::string &  key 
) const
privatevirtual

Get the headers for the HTTP request.

Parameters
methodThe HTTP method.
keyThe full name of the object.
Returns
a list of headers.

Reimplemented in bcache::s3_cache_provider_t.

◆ get_object_url()

std::string bcache::http_cache_provider_t::get_object_url ( const std::string &  key)
private

Get the full URL for a given object.

Parameters
keyThe full name of the object.
Returns
the full URL for the object.

◆ get_path()

std::string bcache::http_cache_provider_t::get_path ( ) const
protected

Get the path of the destination URL.

Returns
the path of the destination.

◆ is_connected()

bool bcache::http_cache_provider_t::is_connected ( ) const
overridevirtual

Check if we have a connection to the remote cache.

Returns
true if we have a connection to the remote cache.

Implements bcache::remote_cache_provider_t.

◆ lookup()

cache_entry_t bcache::http_cache_provider_t::lookup ( const std::string &  hash)
overridevirtual

Check if an entry exists in the cache.

Parameters
hashThe cache entry identifier.
Returns
A cache entry struct. If there was no cache hit the entry will be empty.

Implements bcache::remote_cache_provider_t.

◆ set_data()

void bcache::http_cache_provider_t::set_data ( const std::string &  key,
const std::string &  data 
)
private

Set a binary data blob in the remote cache.

Parameters
keyThe unique key that identifies the data.
dataThe data as a string object.
Exceptions
runtime_errorif the data could not be retrieved (e.g. the key does not exist in the remote cache).

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