Update EngageWorker snippet to use V2 isServiceAvailable API#980
Update EngageWorker snippet to use V2 isServiceAvailable API#980amulyagaur wants to merge 4 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates EngageWorker.kt to perform service availability checks based on specific cluster types rather than a general check. However, the introduction of an else block that returns Result.failure() for unknown cluster types will break publishing for other valid types, such as user account management cards. It is recommended to remove this else block to prevent these failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (intendedClusterType != ClusterType.TYPE_UNKNOWN) { | ||
| val request = ServiceAvailabilityRequest.Builder() | ||
| .addIntendedClusterType(intendedClusterType) | ||
| .build() | ||
| val availabilityMap = client.isServiceAvailable(request).await() | ||
| if (availabilityMap[intendedClusterType] != true) { | ||
| Log.e("EngageWorker", "Service not available for cluster type: $intendedClusterType") | ||
| return Result.failure() | ||
| } | ||
| } else { | ||
| return Result.failure() | ||
| } |
There was a problem hiding this comment.
This else block causes the worker to immediately return Result.failure() for any publish type that does not map to a standard ClusterType (such as Constants.PUBLISH_TYPE_USER_ACCOUNT_MANAGEMENT). This completely breaks the publishing of user account management cards.
Since any invalid or unsupported publish types are already handled and rejected with Result.failure() in the final when (publishType) block at the end of doWork(), we can safely remove this else block entirely.
if (intendedClusterType != ClusterType.TYPE_UNKNOWN) {
val request = ServiceAvailabilityRequest.Builder()
.addIntendedClusterType(intendedClusterType)
.build()
val availabilityMap = client.isServiceAvailable(request).await()
if (availabilityMap[intendedClusterType] != true) {
Log.e("EngageWorker", "Service not available for cluster type: $intendedClusterType")
return Result.failure()
}
}|
Hi @amulyagaur, Shouldn't we update the dependency version, as well? (1.5.2 > 1.6.0). Every code in the snippet should be compilable without error and warning. So, please double check it. Thanks. |
Updates the EngageWorker.kt snippet to use the new V2 version of isServiceAvailable API supporting ClusterType filtering.