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

fix supplemental context being built in EDT #4765

Merged
merged 32 commits into from
Aug 19, 2024
Merged

fix supplemental context being built in EDT #4765

merged 32 commits into from
Aug 19, 2024

Conversation

Will-ShaoHua
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua commented Aug 5, 2024

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

#4764

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Will-ShaoHua Will-ShaoHua requested a review from a team as a code owner August 5, 2024 19:49
@Will-ShaoHua Will-ShaoHua marked this pull request as draft August 5, 2024 19:54
@Will-ShaoHua Will-ShaoHua marked this pull request as ready for review August 6, 2024 18:02
@Will-ShaoHua Will-ShaoHua requested a review from rli August 8, 2024 17:47
@Will-ShaoHua Will-ShaoHua mentioned this pull request Aug 13, 2024
6 tasks
Comment on lines 58 to 61
val contentLength: Int
get() = contents.fold(0) { acc, chunk ->
acc + chunk.content.length
}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe lazy so we dont have to calculate it multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

fun supplementalContext(): SupplementalContextResult = if (supplementalContext != null) {
supplementalContext as SupplementalContextResult
} else {
runBlocking {
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 should keep it as a Deferred, because the user-facing invocation is also under a coroutine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okk,that makes sense to me. I think I do it this way because we log the sup context early or on failure. But will update this part

Copy link
Contributor Author

@Will-ShaoHua Will-ShaoHua Aug 15, 2024

Choose a reason for hiding this comment

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

just think of even after awaiting and getting the real sup context response within a coroutine, we still need a data class to store pure SupplemetalContextResult instead of its deferred?

Copy link
Contributor Author

@Will-ShaoHua Will-ShaoHua Aug 15, 2024

Choose a reason for hiding this comment

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

to solve that, should we use 2 different data class of RequestContext, one with Defer<SupplementalContext> and the other with real SupplementalConext ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh richard i tried to restruct the flow and feel this should work
0a29d95

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should polish it a bit tho, wanna make getRequestContext fun signature still returns a regular object instead of defer but modify the call site

@Will-ShaoHua Will-ShaoHua mentioned this pull request Aug 15, 2024
6 tasks
@Will-ShaoHua Will-ShaoHua marked this pull request as draft August 15, 2024 21:41
@Will-ShaoHua Will-ShaoHua marked this pull request as ready for review August 18, 2024 12:34
@Will-ShaoHua
Copy link
Contributor Author

move unrelated refactor changes to #4806

@Will-ShaoHua Will-ShaoHua requested a review from a team as a code owner August 18, 2024 12:40
@Will-ShaoHua Will-ShaoHua requested a review from rli August 19, 2024 21:17
@rli rli merged commit b342ff9 into aws:main Aug 19, 2024
9 of 10 checks passed
@Will-ShaoHua Will-ShaoHua deleted the slow branch August 20, 2024 07:02
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.

3 participants