-
Notifications
You must be signed in to change notification settings - Fork 122
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
fix!: update consumer chain queries #2246
Conversation
@@ -685,6 +685,11 @@ func ConsumerIdToPhaseKey(consumerId string) []byte { | |||
return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPhaseKeyName), consumerId) | |||
} | |||
|
|||
// ConsumerIdToPhaseKeyPrefix returns the key prefix used to iterate over all the consumer ids and their phases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 685 (above) do return return StringIdWithLenKey(ConsumerIdToPhaseKeyPrefix(), consumerId)
instead of return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPhaseKeyName), consumerId)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConsumerMetadata metadata = 4 [ (gogoproto.nullable) = false ]; | ||
ConsumerInitializationParameters init_params = 5; | ||
PowerShapingParameters power_shaping_params = 6; | ||
string consumer_id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consumer_id
seems to be part of the QueryConsumerChainRequest
. If so, what's the point of returning it as part the response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that we can validate on the FE that we got the chain_id for the consumer_id we requested. But, more importantly so that we don't have to keep extra context (e.g coming from URL params) about which chain we're dealing with.
E.g. previously we had to read the URL param for consumer_id for any operation we were doing:
forge/consumer-id/123
So we had to "remember" the 123
. This way we look up an object and treat is as the source of truth and do all operations required by fetching the consumer_id from the returned object.
Does that make sense?
@@ -720,14 +722,19 @@ func TestQueryConsumerChains(t *testing.T) { | |||
tc.setup(ctx, pk) | |||
req := types.QueryConsumerChainsRequest{ | |||
Phase: tc.phase_filter, | |||
Limit: tc.limit, | |||
Pagination: &sdkquery.PageRequest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we test this, but would be nice to have a test that uses the PageResponse
to construct the new PageRequest
and verify that everything works as expected.
Fix gosec. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add consumer_id to single chain response.
Add pagination for consumer chains.