Dynamically load tasks; sync target improvements; StopIteration fix#963
Merged
rgalanakis merged 10 commits intomainfrom Jun 8, 2025
Merged
Dynamically load tasks; sync target improvements; StopIteration fix#963rgalanakis merged 10 commits intomainfrom
rgalanakis merged 10 commits intomainfrom
Conversation
Allow other modules to define tasks.
So that replicators can convert a column into a hash value for partitioning, add a converter. This is useful when a 'parent' (like a calendar) needs to store the hash used for children (events), so clients can easily query.
Track full call duration, not just remote calls, to find slow queries. Better cursor page name. Use better summary names and calculations.
No idea why this just started.
The StopIteration problem with `down` and `httpx` turned into a giant can of worms that I wasn't able to fix. There was no way to tell the difference between redirects and 304s, since we'd get a StopIteration for both. To fix this, I decided to rip out Down, since it wasn't providing useful abstraction over anything. I also needed to rip out HTTPX, since its streaming implementation was busted and wasn't easy to patch or replace. Instead, we use the more mature, and in my opinion clearer, `HTTP` gem. We wrap it more thoroughly with `chunked_download`. This required some small changes to `Webhookdb::Http` to make it more flexible for the `HTTP` responses (not just HTTParty). It included a much more annoying change to handle the content type and charset detection fixes we made on top of HTTPX and Down, to handle the bad HTTP servers we deal with. These are small and subtle things, so it's good they were tested! Unfortunately the Webhook HTTP lib wrapper makes too many assumptions, and we can't use it to unit test these charset changes. So we use `thin` to start a webserver we can use for better http testing. Overall I think this code is much simpler and will be easier to fix and modify. Look at all the exception types we had to handle, for example- we'll need to add more, almost for sure, but it's much more clear.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #963 +/- ##
==========================================
+ Coverage 97.06% 97.07% +0.01%
==========================================
Files 487 487
Lines 30867 30994 +127
==========================================
+ Hits 29960 30088 +128
+ Misses 907 906 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve sync target stat tracking
Track full call duration, not just remote calls,
to find slow queries.
Better cursor page name.
Use better summary names and calculations.
Support disabling sync targets
Expose str2inthash method and converter
So that replicators can convert a column into a hash value
for partitioning, add a converter.
This is useful when a 'parent' (like a calendar) needs to
store the hash used for children (events),
so clients can easily query.
Dynamically load tasks
Allow other modules to define tasks.
Replace httpx and down to fix
StopIterationbugsThe StopIteration problem with
downandhttpxturnedinto a giant can of worms that I wasn't able to fix.
There was no way to tell the difference between redirects and 304s,
since we'd get a StopIteration for both.
To fix this, I decided to rip out Down, since it wasn't providing
useful abstraction over anything.
I also needed to rip out HTTPX, since its streaming implementation
was busted and wasn't easy to patch or replace.
Instead, we use the more mature, and in my opinion clearer,
HTTPgem. We wrap it more thoroughly withchunked_download.This required some small changes to
Webhookdb::Httpto makeit more flexible for the
HTTPresponses (not just HTTParty).It included a much more annoying change to handle the content type
and charset detection fixes we made on top of HTTPX and Down,
to handle the bad HTTP servers we deal with. These are small and
subtle things, so it's good they were tested!
Unfortunately the Webhook HTTP lib wrapper makes too many
assumptions, and we can't use it to unit test these charset changes.
So we use
thinto start a webserver we can usefor better http testing.
Overall I think this code is much simpler and will be easier
to fix and modify. Look at all the exception types we had to
handle, for example- we'll need to add more, almost for sure,
but it's much more clear.