8000 feat: Config updater for the base provider by davidterpay · Pull Request #117 · skip-mev/connect · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

feat: Config updater for the base provider #117

Merged
merged 7 commits into from
Feb 13, 2024
Merged

Conversation

davidterpay
Copy link
Contributor
@davidterpay davidterpay commented Feb 12, 2024

closes BLO-901

This PR introduces a ConfigUpdater interface that allows the base provider to be updated asynchronously. Anytime a configuration update is received, this will trigger the provider to restart with the new configurations.

Copy link
codecov bot commented Feb 12, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (f1b58a0) 75.00% compared to head (5a29e00) 75.30%.

Files Patch % Lines
providers/base/options.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #117      +/-   ##
==========================================
+ Coverage   75.00%   75.30%   +0.30%     
==========================================
  Files         135      137       +2     
  Lines        5548     5608      +60     
==========================================
+ Hits         4161     4223      +62     
+ Misses       1042     1039       -3     
- Partials      345      346       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidterpay davidterpay marked this pull request as ready for review February 12, 2024 19:41
@@ -80,7 +76,8 @@ func (p *Provider[K, V]) startAPI(ctx context.Context, responseCh chan<- provide
// attemptAPIDataUpdate tries to update data by fetching and parsing API data.
// It logs any errors encountered during the process.
func (p *Provider[K, V]) attemptAPIDataUpdate(ctx context.Context, responseCh chan<- providertypes.GetResponse[K, V]) {
if len(p.ids) == 0 {
ids := p.GetIDs()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear what p.GetIDs() is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDs are effectively currency pairs, the base provider just calls them IDs to have some generality.

// for a given provider. This allows the provider to be updated asynchronously.
ConfigUpdater[K providertypes.ResponseKey] interface {
// GetIDs is the channel that is used to update the set of IDs that the provider
// will fetch data for. This blocks until there is a viable update.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to choose a channel v. a RWMutex here? Don't you want all Providers to read the updated ids concurrently? Do we expect a ConfigUpdater per Provider?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this is being done per provider

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea the interface that the config client, which is the client that is responsible for updating all providers, will use is the ConfigUpdater - which is specific per provider.

return err
case <-ctx.Done():
return <-errCh
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to kill the providers if there is a config update? Don't we j need to update the set of IDs it's fetching for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works cleanly for that with REST providers, but for websockets, things get more complicated. We would need to do unsubscribe/subscribe logic based on the diff we get in providers.

This just simplifies things, creating a new connection so we have a fresh set of subscriptions.

@davidterpay davidterpay merged commit cd0e34b into main Feb 13, 2024
@zrbecker zrbecker deleted the terpay/config-updater branch November 5, 2024 21:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0