Skip to content

Commit

Permalink
feat(predictions): Added region handling for creating correct streami…
Browse files Browse the repository at this point in the history
…ng endpoint from region (#2923)
  • Loading branch information
ppraja22 authored Sep 24, 2024
1 parent aa6e1ff commit 2485058
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal class RunFaceLivenessSession(
onError: Consumer<PredictionsException>
) {

private val livenessEndpoint = "wss://streaming-rekognition.${sessionInformation.region}.amazonaws.com:443"
private val livenessEndpoint = getStreamingEndpointForRegion(sessionInformation.region)

private val livenessWebSocket = LivenessWebSocket(
credentialsProvider = credentialsProvider,
Expand Down Expand Up @@ -183,4 +183,17 @@ internal class RunFaceLivenessSession(
livenessWebSocket.clientStoppedSession = true
reasonCode?.let { livenessWebSocket.destroy(it) } ?: livenessWebSocket.destroy()
}

private fun getStreamingEndpointForRegion(region: String): String {
val baseDomain = when {
region.startsWith("us-isof", ignoreCase = true) -> ISO_PARTITION_BASE_DOMAIN
else -> DEFAULT_BASE_DOMAIN
}
return "wss://streaming-rekognition.$region.$baseDomain:443"
}

companion object {
private const val ISO_PARTITION_BASE_DOMAIN = "csp.hci.ic.gov"
private const val DEFAULT_BASE_DOMAIN = "amazonaws.com"
}
}

0 comments on commit 2485058

Please sign in to comment.