rewrite config & context, support tokio::main & tokio::test #2937
Conversation
|
We should also start adding some benchmarks as I think it's becoming more and more important. |
3e2baf7 to
2fe1d24
Compare
2fe1d24 to
0679ed7
Compare
for which parts? in my mind, most of the time is still spent in the S3 fetch, so low-level speed doesn't really matter that much. My focus is more around code-quality, readability, ... ( also I want to work on the subdomain/XSS part when it's easier to add :) ) |
0679ed7 to
2c5c6ca
Compare
|
All parts I guess? That would allow us to keep track of which part is taking how much time. Not sure how important it is though.
Yeah I guess too. But having actual numbers to see if our changes start to take a bigger % would be useful on the long run.
On that we both agree. Code quality comes before performance as long as performance is not problematic (and performance is not a problem currently).
Oh nice. :) |
we already see performance tracing numbers in sentry for that. |
2c5c6ca to
b4a5fad
Compare
|
It gives details on what took time in a query or just tells how much time it took? |
b4a5fad to
d4f302d
Compare
d4f302d to
f4116a4
Compare
This is a bigger refactor and I have to apologize in advance for the size of it. I have ~8 WIP branches where I tried to do only parts of the rewrite, but all failed and now I ended up doing many things at once.
The initial motivation of this is coming from wanting to make progress on the sync/async migration in our codebase. Plenty of things were and still are not in the state I want them to be.
For some parts I took inspiration from the crates.io codebase and how they do it, which I like.
To wrap it up, this PR:
Configstruct to include a builder.Contexttrait to astructthat just includes everything. This made much of the migration much easier, less lifetime errors.tokio::runtime::Runtimedirectly, now work with atokio::runtime::Handle. This enables us to usetokio::testand also later migrate ourmainfunction totokio::main.TestEnvironmentin your test, and the cleanup happens in theDropimpl.some detail notes about the implementation:
bonbecause I like its design more, and crates.io uses it too, but since I wanted to "stack" the builder calls it was too annoying to work with.wrapperusage with the "new way".override_configfor now, some some selected ones. The rest follows later.known limitations for now:
tokio::testdoesn't work, it only works withflavor = multi_thread. This is because I want to useblock_in_placeto be able to teardown the test env inDrop. I took this from crates.io.after this PR I imagine:
async_wrapper