Skip to content

Conversation

@samgst-amazon
Copy link
Contributor

Implement custom RemoteResourceResolver for notification logic to handle ETag fetching and providing the path to the local resource.

Types of changes

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

Description

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.

@samgst-amazon samgst-amazon marked this pull request as ready for review December 5, 2024 01:21
@samgst-amazon samgst-amazon requested a review from a team as a code owner December 5, 2024 01:21
@github-actions
Copy link

github-actions bot commented Dec 5, 2024

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@samgst-amazon samgst-amazon marked this pull request as draft December 5, 2024 16:56
@samgst-amazon samgst-amazon marked this pull request as ready for review December 5, 2024 20:10

private fun getEndpointETag(): String =
try {
HttpRequests.request(NotificationEndpoint.getEndpoint())
Copy link
Contributor

Choose a reason for hiding this comment

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

use a HEAD request if all you are interested in is the headers of GET

data object FirstPollCheck : UpdateCheckResult()
}

class NotificationResourceResolver(
Copy link
Contributor

Choose a reason for hiding this comment

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

lets fold this into DefaultRemoteResourceResolver because there is nothing special about etag handling

private fun getEndpointETag(endpoint: String): String =
try {
val url = URI(endpoint).toURL()
(url.openConnection() as HttpURLConnection).let { connection ->
Copy link
Contributor

Choose a reason for hiding this comment

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

java 11 has a newer way of doing this, but let's actually use the HttpRequests util you were using in a previous PR

complete(file)
}

// following two methods are not used in this test, make compiler happy
Copy link
Contributor

Choose a reason for hiding this comment

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

you can simply just define a default implementation in the interface if this is the generic no-op implementation


override fun checkForUpdates(endpoint: String, eTagProvider: ETagProvider): UpdateCheckResult {
val hasETagUpdate = updateETags(eTagProvider, endpoint)
// for when we need to notify on first poll even when there's no new ETag
Copy link
Contributor

Choose a reason for hiding this comment

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

it would make more sense to see if ETagProvider has a value set to determine if this were the first request

@samgst-amazon samgst-amazon enabled auto-merge (squash) December 10, 2024 23:43
@samgst-amazon samgst-amazon merged commit 3841778 into main Dec 11, 2024
15 checks passed
@samgst-amazon samgst-amazon deleted the samgst/NotificationResourceResolver branch December 11, 2024 22:28
laileni-aws pushed a commit to laileni-aws/aws-toolkit-jetbrains that referenced this pull request Dec 12, 2024
…handling (aws#5165)

* always fetch from endpoint during poll

* notification resource resolver

* ResourceResolver etag handling

* codescan

* remove redundant modifier

* move functionality to DefaultRemoteResourceResolver

* implement defaultRemoteResourceResolverProvider instead

* url deprecated

* detekt

* detektTest fix mock functions

* detekt

* default function in interface

* re-implement HTTPRequest

* re-implement HTTPRequest

* ETag fix

* LazyLogRule
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 17, 2025
…handling (aws#5165)

* always fetch from endpoint during poll

* notification resource resolver

* ResourceResolver etag handling

* codescan

* remove redundant modifier

* move functionality to DefaultRemoteResourceResolver

* implement defaultRemoteResourceResolverProvider instead

* url deprecated

* detekt

* detektTest fix mock functions

* detekt

* default function in interface

* re-implement HTTPRequest

* re-implement HTTPRequest

* ETag fix

* LazyLogRule
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 22, 2025
…handling (aws#5165)

* always fetch from endpoint during poll

* notification resource resolver

* ResourceResolver etag handling

* codescan

* remove redundant modifier

* move functionality to DefaultRemoteResourceResolver

* implement defaultRemoteResourceResolverProvider instead

* url deprecated

* detekt

* detektTest fix mock functions

* detekt

* default function in interface

* re-implement HTTPRequest

* re-implement HTTPRequest

* ETag fix

* LazyLogRule
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