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

chore: remove all mutexes and store in subscription struct #133

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

im-adithya
Copy link
Member

This removes the need of mutexes as the suibscription struct is carried everywhere, so it's best to add the relaySubscription to the subscription itself instead of adding those to svc.subscriptions


if (!exists && !subscription.Open) {
if (!subscription.Open) {
Copy link

Choose a reason for hiding this comment

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

just curious, why is this check not at the start of the method?

Copy link

Choose a reason for hiding this comment

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

is it because it only applies for .e.g subscribing to notifications?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes ✅

@im-adithya
Copy link
Member Author

im-adithya commented Dec 20, 2024

⚠️ THIS WILL NOT WORK WITH STOPPING CONTINUOUS SUBSCRIPTIONS, SINCE THE relaySubscription can't be fetched from the DB in StopSubscriptionHandler

@@ -804,7 +792,7 @@ func (svc *Service) publishRequestEvent(ctx context.Context, subscription *Subsc
"client_pubkey": clientPubkey,
}).Error("Failed to publish to relay")
subscription.RequestEvent.State = REQUEST_EVENT_PUBLISH_FAILED
sub.Unsub()
relaySubscription.Unsub()
Copy link

Choose a reason for hiding this comment

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

should stopSubscription be called here? or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

Did that because it's directly available, but good to keep it consistent 👍 will change to stopSubscription

Copy link

@rolznz rolznz left a comment

Choose a reason for hiding this comment

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

utACK, good simplification

@im-adithya im-adithya merged commit 0aec5b8 into task-eos Dec 20, 2024
1 check passed
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