Skip to content

Commit

Permalink
Fix fail over for Pulse API
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubuid committed Mar 5, 2024
1 parent 7187544 commit 5062618
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,
shouldFallbackRelay(host) -> chain.proceed(request.newBuilder().url(get<String>(named(AndroidCommonDITags.RELAY_URL))).build())
shouldFallbackPush(host) -> chain.proceed(request.newBuilder().url(getFallbackPushUrl(request.url.toString())).build())
shouldFallbackVerify(host) -> chain.proceed(request.newBuilder().url(getFallbackVerifyUrl(request.url.toString())).build())
shouldFallbackPulse(host) -> chain.proceed(request.newBuilder().url(getFallbackPulseUrl(request.url.toString())).build())
shouldFallbackPulse(host) -> chain.proceed(request.newBuilder().url(getFallbackPulseUrl()).build())
else -> chain.proceed(request)
}
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal fun getFallbackPushUrl(url: String): String = with(Uri.parse(url)) {

internal fun getFallbackVerifyUrl(url: String): String = "$FAIL_OVER_VERIFY_URL/attestation/${Uri.parse(url).lastPathSegment}"

internal fun getFallbackPulseUrl(url: String): String = FAIL_OVER_PULSE_URL
internal fun getFallbackPulseUrl(): String = "$FAIL_OVER_PULSE_URL/e"

internal fun isFailOverException(e: Exception) = (e is SocketException || e is IOException)
internal val String.host: String? get() = Uri.parse(this).host
Expand All @@ -66,5 +66,5 @@ internal fun Scope.fallbackRelay(request: Request, chain: Interceptor.Chain): Re
internal fun fallbackPulse(request: Request, chain: Interceptor.Chain): Response {
PULSE_URL = FAIL_OVER_PULSE_URL
wasPulseFailOvered = true
return chain.proceed(request.newBuilder().url(getFallbackPulseUrl(request.url.toString())).build())
return chain.proceed(request.newBuilder().url(getFallbackPulseUrl()).build())
}

0 comments on commit 5062618

Please sign in to comment.