Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FUN-877] Persist subscriptions fetched from contracts #11573

Merged

Conversation

agparadiso
Copy link
Contributor

@agparadiso agparadiso commented Dec 14, 2023

Description

This PR introduces a cache layer that will persist the subscriptions fetched from contracts.

@agparadiso agparadiso self-assigned this Dec 14, 2023
Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch 2 times, most recently from a8d4add to 8718c46 Compare December 14, 2023 14:20
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch 2 times, most recently from 8613b6b to 2b4c9fb Compare December 19, 2023 15:45
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch 4 times, most recently from 2ab33de to d26839a Compare December 20, 2023 14:30
@agparadiso agparadiso changed the title [FUN-877] Persist data fetched from contracts [FUN-877] Persist subscriptions fetched from contracts Dec 20, 2023
@agparadiso agparadiso requested a review from bolekk December 20, 2023 15:37
@agparadiso agparadiso marked this pull request as ready for review December 20, 2023 16:27
@agparadiso agparadiso requested review from a team, samsondav and jmank88 as code owners December 20, 2023 16:27
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch 2 times, most recently from 4380e1b to 05a16d1 Compare December 21, 2023 16:38
@agparadiso agparadiso requested a review from bolekk December 21, 2023 17:02
Comment on lines 208 to 215
err = s.orm.UpsertSubscription(CachedSubscription{
SubscriptionID: subscriptionId,
RouterContractAddress: s.router.Address(),
IFunctionsSubscriptionsSubscription: subscription,
})
if err != nil {
s.lggr.Errorf("unexpected error updating subscription in the cache: %w", err)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

💭 We can persist this async if we think this might become a bottleneck

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call Upsert only when the value changed? That would save us a lot of unnecessary DB calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed the subscription implementation to return a true when an actual update was performed, now it should only update the db when a value changes.

Comment on lines 208 to 215
err = s.orm.UpsertSubscription(CachedSubscription{
SubscriptionID: subscriptionId,
RouterContractAddress: s.router.Address(),
IFunctionsSubscriptionsSubscription: subscription,
})
if err != nil {
s.lggr.Errorf("unexpected error updating subscription in the cache: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call Upsert only when the value changed? That would save us a lot of unnecessary DB calls.

core/services/gateway/handlers/functions/subscriptions.go Outdated Show resolved Hide resolved
core/services/gateway/handlers/functions/orm.go Outdated Show resolved Hide resolved
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch 2 times, most recently from 1825524 to b0d79cd Compare December 22, 2023 14:45
@agparadiso agparadiso requested a review from bolekk December 22, 2023 15:34
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch from b0d79cd to 3f45ccb Compare January 2, 2024 17:00
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts branch from 55ed335 to c52163d Compare January 4, 2024 11:36
@cl-sonarqube-production
Copy link

@agparadiso agparadiso requested a review from bolekk January 4, 2024 12:12
@agparadiso agparadiso added this pull request to the merge queue Jan 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 4, 2024
@agparadiso agparadiso added this pull request to the merge queue Jan 4, 2024
Merged via the queue into develop with commit 529d2cf Jan 4, 2024
78 checks passed
@agparadiso agparadiso deleted the feature/FUN-877_persist_data_fetched_from_contracts branch January 4, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants