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

Add subscribe account statuses endpoint #762

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

Conversation

illia-malachyn
Copy link
Contributor

Closes: #747

@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 59.29204% with 46 lines in your changes missing coverage. Please review.

Project coverage is 54.44%. Comparing base (7b58582) to head (3aeee13).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
access/grpc/convert/convert.go 0.00% 23 Missing ⚠️
access/grpc/grpc.go 79.76% 11 Missing and 6 partials ⚠️
access/grpc/client.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #762      +/-   ##
==========================================
+ Coverage   52.92%   54.44%   +1.52%     
==========================================
  Files          35       35              
  Lines        5580     5780     +200     
==========================================
+ Hits         2953     3147     +194     
+ Misses       2231     2194      -37     
- Partials      396      439      +43     
Flag Coverage Δ
unittests 54.44% <59.29%> (+1.52%) ⬆️

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.

}
}

func checkAndIncrementMessageIndex(previousMessageIndex *atomic.Uint64, currentMessageIndex uint64) error {
Copy link
Contributor Author

@illia-malachyn illia-malachyn Oct 2, 2024

Choose a reason for hiding this comment

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

@peterargue is this implementation good enough? It might be good to add more tests for different msg indexes. However, I'm not sure what cases to cover. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can simply it a bit by tracking "next" instead of the current.
e.g.

next := 0 // since we start at 0, the first expected should be 0
for {
	if msg.MessageIndex != next {
		return err
	}
	next = msg.MessageIndex + 1
}

return accountStatutesChan, errChan, nil
}

func receiveAccountStatusesFromClient[Client interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

using Client as the name is a little confusing, especially within a client library. how about breaking this out to a stand along type since it's used in a bunch of places, and renaming it to Stream?

client Client,
accountStatutesChan chan<- flow.AccountStatus,
errChan chan<- error,
previousMsgIndex *atomic.Uint64,
Copy link
Contributor

Choose a reason for hiding this comment

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

message index is specific to a stream. So when you start a new stream, the responses start with message index 0 (or 1, I don't remember how it started), then increment.

I think it's fine to track it only within this function as a regular uint64 value. There should not be any concurrent access.

}
}

func checkAndIncrementMessageIndex(previousMessageIndex *atomic.Uint64, currentMessageIndex uint64) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can simply it a bit by tracking "next" instead of the current.
e.g.

next := 0 // since we start at 0, the first expected should be 0
for {
	if msg.MessageIndex != next {
		return err
	}
	next = msg.MessageIndex + 1
}

}

type AccountStatusResult struct {
Address Identifier
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be an address?

Suggested change
Address Identifier
Address Address

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.

Add SubscribeAccountStatuses* endpoints
4 participants