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

[Access] Change SendAndSubscribe endpoint's MessageIndex to start at 0 #6598

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AndriiDiachuk
Copy link
Contributor

Closes: #6575
Related PR: onflow/flow#1520

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 7.69231% with 12 lines in your changes missing coverage. Please review.

Project coverage is 41.19%. Comparing base (681dd9a) to head (f9e3f2c).

Files with missing lines Patch % Lines
engine/access/state_stream/backend/handler.go 12.50% 6 Missing and 1 partial ⚠️
access/handler.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6598      +/-   ##
==========================================
- Coverage   41.19%   41.19%   -0.01%     
==========================================
  Files        2052     2052              
  Lines      182191   182200       +9     
==========================================
+ Hits        75062    75065       +3     
+ Misses     100839   100838       -1     
- Partials     6290     6297       +7     
Flag Coverage Δ
unittests 41.19% <7.69%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@Guitarheroua Guitarheroua self-requested a review October 29, 2024 10:58
Copy link
Collaborator

@Guitarheroua Guitarheroua left a comment

Choose a reason for hiding this comment

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

This also fixed the same issue for Accounts and Events. I know this is out of scope, but could you please also check MessageIndex for blocks to see if the implementation in all subscriptions is consistent?

Other than that, looks good to me.

…-send-and-subscribe-endoints-msg-index-start-with-zero
…-zero' of github.com:AndriiDiachuk/flow-go into change-send-and-subscribe-endoints-msg-index-start-with-zero
@@ -381,7 +381,7 @@ func (h *Handler) handleEventsResponse(send sendSubscribeEventsResponseFunc, hea
return status.Errorf(codes.Internal, "could not convert events to entity: %v", err)
}

index := messageIndex.Increment()
index := messageIndex.Value()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: keep the get and set together so the stream fails quickly if there's an issue

Suggested change
index := messageIndex.Value()
index := messageIndex.Value()
if ok := messageIndex.Set(index + 1); !ok {
return status.Errorf(codes.Internal, "message index already incremented to %d", messageIndex.Value())
}

@@ -495,7 +499,7 @@ func (h *Handler) handleAccountStatusesResponse(
return err
}

index := messageIndex.Increment()
index := messageIndex.Value()
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -1435,15 +1435,19 @@ func (h *Handler) SendAndSubscribeTransactionStatuses(
messageIndex := counters.NewMonotonousCounter(0)
return subscription.HandleSubscription(sub, func(txResults []*TransactionResult) error {
for i := range txResults {
value := messageIndex.Increment()
index := messageIndex.Value()
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

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.

4 participants