| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
| |
Typos found with codespell
|
| |
|
|
| |
This code is still WIP, no need to address the lint yet.
|
| |
|
|
|
|
|
|
|
|
|
| |
This commit removes FromStr for DocumentId because it was only used in
testing anyways.
Instead, it replaces it with a simple From<[u8; 32]> only enabled in
test builds, which is sufficient for what we are trying to do.
An alternative would be to make the inner field pub, but this seems to
aggressive for a testing only thing.
|
| |
|
|
|
| |
Because we went with `docid` in the database (due to `rowid`), it is
only natural to call the code variables `docid` too.
|
| |
|
|
|
|
| |
This commit renames the sha256 column to docid for the reason that we
agreed upon making the schema visible to all modules, so if we were to
encapsulate docid properly, this change is only natural.
|
| |
|
|
|
|
| |
This commit introduces a new type in the database module named
`DocumentId` for abstracting the underlying content-addressable hash
algorithm we are using.
|
| |
|
|
|
|
| |
This commit moves the ContentEncoding enum from the http module to the
database module, primarily because the content encoding is more of a
matter to the database, as this is where the data actually resides.
|
| |
|
|
|
|
|
|
| |
This commit implements support for adding arbitrary documents into the
store table.
It is non-trivial because the relevant data has to be compressed into
various formats, so it can be retrieved without delays.
|
| |
|
|
| |
Run maint/add_warning
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
This commit applies the recent changes to the database module into the
http and http::cache module.
Notably, this includes the use of the database::sql! macro as well as
the use of database::read_tx and database::rw_tx for creation
transaction and saving, as well as retrying, although the latter one is
subject to SQLite's own busy handler
|
| |
|
|
|
|
|
|
|
|
| |
This commit makes the entire database operations synchronous, thereby
replacing deadpool with r2d2.
The full motivation is outlined in a rustdoc comment at the top of the
`database` module, but it can be summarized to the fact that SQLite is
by design inherently synchronous due to directly interfacing with the
file system.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit does a large overhaul in the overall way on how we interact
with SQLite.
Although SQLite is a fairly straightforward tool, it has one large
caveat, namely the handling of the infamous `SQLITE_BUSY` error.
In WAL mode, the journaling mode we are using, the respective error may
occur if there is an existing write transaction while another thread is
trying to either upgrade an existing read transaction or create an
exclusive transaction at the same time. In this case, SQLite will fail
at the statement that either requires the write operation or at the
creation of the transaction respectively.
In order to tackle this problem, SQLite provides the `busy_timeout`
pragma, which allows specifying a timeout in milliseconds during which
SQLite will retry to obtain a write transaction or fail immediately.
This only works in the latter case, that is, creating a write
transaction from the beginning.
To solve this issue, we introduce two new functions:
1. `database::read_tx`
2. `database::rw_tx`
Both functions accept a database pool alongside a closure accepting a
`Transaction` and returning an arbitrary return value.
The first function creates a deferred transaction that gets rolled-back
in the end, making it suitable for read-only connections.
The latter function creates an exclusive transaction that gets committed
in the end, making it suitable for read-write connections. This also
honors the `busy_timeout`, i.e. the function retries for up to 1s to
acquire a write transaction before failing ultimately.
|
| |
|
|
|
|
| |
This commit introduces the no-op sql macro used to mark string literals
as SQL statements. It is purely semantical and serves the purpose to
quickly identify string literals as SQL statements.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
This commit allows `#[allow(clippy::cognitive_complexity)]` in
`HttpServer::serve` and `HttpServer::handler_tx`. Allowing this might
be controversial but both functions, especially the latter one, are well
documented.
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
This commit uses `tor_error::Bug` for indicating thread poisoning.
|
| | |
|
| | |
|
| |
|
|
|
| |
This commit renames `cb` to `endpoint_fn` everywhere, including internal
implementations.
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit refactors a large part of the HTTP module, namely it
refactors the `Callback` type to a new type called `EndpointFn` which
now works in a transaction based approach and no longer gives access to
the `StoreCache`. The type itself is also no longer a trait but a
concrete type using `fn`.
Another very notable change that became necessary during this commit was
to make large parts of the codebase synchronous instead of async, namely
because it is non-trivial to `Send` a `Transaction` created inside an
async context to a synchronous function. Besides, this change has been
deemed necessary for other reasons to.
The refactoring to more synchronous code has lead to some interesting
changes in `StoreCache` too, namely that in no longer uses async mutex,
but a synchronous mutex instead.
|
| | |
|
|
|
This commit implements the initial draft for the HTTP module.
It is fairly complicated but well documented within the source code,
please refer to that instead.
|