|
Haio 0.2.X
Homebrew Asset IO/CDN
|
Namespaces | |
| namespace | Bucket |
| namespace | Detail |
Classes | |
| struct | BucketConfig |
| class | Cache |
| struct | CacheConfig |
| struct | CacheEntry |
| class | CacheStore |
| struct | Config |
| struct | SecurityConfig |
Functions | |
| std::string | cacheKey (std::string_view bucket, std::string_view path, std::string_view query) |
| std::vector< uint8_t > | encodeEntry (const CacheEntry &entry) |
| std::optional< CacheEntry > | decodeEntry (std::span< const uint8_t > raw) |
| std::unique_ptr< CacheStore > | makeMemoryStore (size_t maxUsage, std::chrono::seconds ttl) |
| std::unique_ptr< CacheStore > | makeFileStore (std::filesystem::path root, std::chrono::seconds ttl, size_t maxUsage) |
| std::unique_ptr< CacheStore > | makeRedisStore (std::string url, std::chrono::seconds ttl, size_t maxUsage, boost::asio::any_io_executor executor) |
| Config | parseConfig (std::string_view text) |
| Config | loadConfig (const std::filesystem::path &path) |
| boost::asio::awaitable< Result< Blob > > | fetchBucket (const Config &config, Bucket::ZipArchives &archives, std::string bucket, std::string path) |
| boost::asio::awaitable< void > | runServer (Config config) |
| std::unique_ptr< CacheStore > | makeRedisStore (std::string url, std::chrono::seconds ttl, size_t maxUsage, asio::any_io_executor executor) |
| struct Haio::Cdn::BucketConfig |
a bucket is described entirely by the scheme of its url:
file://relative/dir file:///absolute/dir http://host/prefix https://host/prefix s3://host/bucket https://* open, the request names the host //* open, the request names the scheme and the host
Definition at line 201 of file haio_cdn.hpp.
| struct Haio::Cdn::CacheConfig |
Definition at line 28 of file haio_cache.hpp.
| Class Members | ||
|---|---|---|
| size_t | maxUsage = 64u << 20 | |
| seconds | ttl {0} | |
| string | url | |
| struct Haio::Cdn::CacheEntry |
what the cache holds is a finished response, not an image: the work being saved is the fetch and the whole conversion behind it, so replaying an entry costs a copy.
Definition at line 22 of file haio_cache.hpp.
| Class Members | ||
|---|---|---|
| string | contentType | |
| vector< uint8_t > | data | |
| string | filename | |
| struct Haio::Cdn::Config |
Definition at line 261 of file haio_cdn.hpp.

| Class Members | ||
|---|---|---|
| map< string, BucketConfig > | buckets | |
| CacheConfig | cache | |
| set< string > | declared |
the keys the file actually spelled out, as "max_size" or "cache.max_ip". the safety limits all have a default, so leaving one out is safe rather than open; this is what lets the server say which ones it chose for itself instead of letting an operator believe they had configured something. |
| string | host = "0.0.0.0" | |
| unsigned short | port = 8080 | |
| SecurityConfig | security | |
| struct Haio::Cdn::SecurityConfig |
every limit the server has, in one table, so that reviewing what protects this deployment is reading one page of the config rather than hunting for it.
each one is safe when left out, and the server says at startup which ones it chose for itself; see Security.
Definition at line 229 of file haio_cdn.hpp.
| std::string Haio::Cdn::cacheKey | ( | std::string_view | bucket, |
| std::string_view | path, | ||
| std::string_view | query ) |
the md5 of the bucket, the path and the query, in the order they were written.
the query is not sorted, and must not be: it spells out a pipeline, so crop before resize is a different picture from resize before crop. sorting would collide two different requests onto one entry and serve the wrong image, which is a worse fault than keeping two entries for one answer. the method is left out so a HEAD finds what a GET stored.
Definition at line 34 of file key.cpp.

| std::optional< CacheEntry > Haio::Cdn::decodeEntry | ( | std::span< const uint8_t > | raw | ) |
| std::vector< uint8_t > Haio::Cdn::encodeEntry | ( | const CacheEntry & | entry | ) |
| boost::asio::awaitable< Result< Blob > > Haio::Cdn::fetchBucket | ( | const Config & | config, |
| Bucket::ZipArchives & | archives, | ||
| std::string | bucketName, | ||
| std::string | path ) |
picks a fetcher by the scheme the config already parsed, and turns whatever it throws into a Result, so nothing above this line has to catch anything.
Definition at line 15 of file bucket.cpp.

| Config Haio::Cdn::loadConfig | ( | const std::filesystem::path & | path | ) |
the file may hold an s3 secret, so anybody who can read it can sign as this server. the check is a warning rather than a refusal: whose machine this is, and who else is on it, is not haio's call to make.
Definition at line 287 of file config.cpp.

| std::unique_ptr< CacheStore > Haio::Cdn::makeFileStore | ( | std::filesystem::path | root, |
| std::chrono::seconds | ttl, | ||
| size_t | maxUsage ) |
| std::unique_ptr< CacheStore > Haio::Cdn::makeMemoryStore | ( | size_t | maxUsage, |
| std::chrono::seconds | ttl ) |
| std::unique_ptr< CacheStore > Haio::Cdn::makeRedisStore | ( | std::string | url, |
| std::chrono::seconds | ttl, | ||
| size_t | maxUsage, | ||
| asio::any_io_executor | executor ) |
| std::unique_ptr< CacheStore > Haio::Cdn::makeRedisStore | ( | std::string | url, |
| std::chrono::seconds | ttl, | ||
| size_t | maxUsage, | ||
| boost::asio::any_io_executor | executor ) |

| Config Haio::Cdn::parseConfig | ( | std::string_view | text | ) |
| asio::awaitable< void > Haio::Cdn::runServer | ( | Config | config | ) |