Skip to content

Commit

Permalink
Changing the timeout scale of get proposition from milliseconds to se…
Browse files Browse the repository at this point in the history
…conds
  • Loading branch information
siddique-adobe committed Nov 28, 2024
1 parent 2fb1623 commit eb6b34d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private Optimize() {}
* Experience Edge network.
*
* <p>The returned decision propositions are cached in-memory in the Optimize SDK extension and
* can be retrieved using {@link #getPropositions(List, long, AdobeCallback)} API.
* can be retrieved using {@link #getPropositions(List, AdobeCallback)} API.
*
* @param decisionScopes {@code List<DecisionScope>} containing scopes for which offers need to
* be updated.
Expand Down Expand Up @@ -99,7 +99,7 @@ public static void updatePropositions(
* Experience Edge network.
*
* <p>The returned decision propositions are cached in-memory in the Optimize SDK extension and
* can be retrieved using {@link #getPropositions(List, long, AdobeCallback)} API.
* can be retrieved using {@link #getPropositions(List, double, AdobeCallback)} API.
*
* @param decisionScopes {@code List<DecisionScope>} containing scopes for which offers need to
* be updated.
Expand Down Expand Up @@ -278,8 +278,8 @@ public void call(final Event event) {
public static void getPropositions(
@NonNull final List<DecisionScope> decisionScopes,
@NonNull final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
long defaultTimeout = OptimizeConstants.GET_RESPONSE_CALLBACK_TIMEOUT;
getPropositionsInternal(decisionScopes, defaultTimeout, callback);
final double defaultTimeoutSeconds = OptimizeConstants.GET_RESPONSE_CALLBACK_TIMEOUT;
getPropositionsInternal(decisionScopes, defaultTimeoutSeconds, callback);
}

/**
Expand All @@ -293,14 +293,14 @@ public static void getPropositions(
*/
public static void getPropositions(
@NonNull final List<DecisionScope> decisionScopes,
final long timeoutMillis,
final double timeoutSeconds,
@NonNull final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
getPropositionsInternal(decisionScopes, timeoutMillis, callback);
getPropositionsInternal(decisionScopes, timeoutSeconds, callback);
}

private static void getPropositionsInternal(
@NonNull final List<DecisionScope> decisionScopes,
final long timeoutMillis,
final double timeoutSeconds,
@NonNull final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
if (OptimizeUtils.isNullOrEmpty(decisionScopes)) {
Log.warning(
Expand Down Expand Up @@ -348,8 +348,8 @@ private static void getPropositionsInternal(
.setEventData(eventData)
.build();

// Increased default response callback timeout to 10s to ensure prior update propositions
// requests have enough time to complete.
long timeoutMillis = (long) (timeoutSeconds * 1000);

MobileCore.dispatchEventWithResponseCallback(
event,
timeoutMillis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class OptimizeConstants {
static final String EXTENSION_VERSION = "3.2.0";
static final String EXTENSION_NAME = "com.adobe.optimize";
static final String FRIENDLY_NAME = "Optimize";
static final long DEFAULT_RESPONSE_CALLBACK_TIMEOUT = 500L;
static final long GET_RESPONSE_CALLBACK_TIMEOUT = 10000L;
static final double GET_RESPONSE_CALLBACK_TIMEOUT = 10;
static final double EDGE_CONTENT_COMPLETE_RESPONSE_TIMEOUT = 10;

static final String ACTIVITY_ID = "activityId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fun OffersView(viewModel: MainViewModel) {

viewModel.getPropositions(
decisionScopes = decisionScopeList,
timeout = 200
timeoutSeconds = 0.2
)
}) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class MainViewModel: ViewModel() {
* Calls the Optimize SDK API to get the Propositions see [Optimize.getPropositions]
*
* @param [decisionScopes] a [List] of [DecisionScope]
* @param [timeout] a [Long] in milliseconds
* @param [timeoutSeconds] a [Double] in seconds
*/
fun getPropositions(decisionScopes: List<DecisionScope>, timeout: Long? = null) {
fun getPropositions(decisionScopes: List<DecisionScope>, timeoutSeconds: Double? = null) {
optimizePropositionStateMap.clear()
val callback = object : AdobeCallbackWithError<Map<DecisionScope, OptimizeProposition>> {
override fun call(propositions: Map<DecisionScope, OptimizeProposition>?) {
Expand All @@ -86,8 +86,8 @@ class MainViewModel: ViewModel() {
print("Error in getting Propositions.")
}
}
timeout?.let { milliseconds ->
Optimize.getPropositions(decisionScopes, milliseconds, callback)
timeoutSeconds?.let { seconds ->
Optimize.getPropositions(decisionScopes, seconds, callback)
} ?: Optimize.getPropositions(decisionScopes, callback)
}

Expand Down

0 comments on commit eb6b34d

Please sign in to comment.