Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ import com.ecwid.apiclient.v3.httptransport.HttpBody
import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.util.buildEndpointPath
import com.ecwid.apiclient.v3.util.buildQueryString
import java.util.UUID

data class CreateBatchRequestWithIds(
val requests: Map<String, ApiRequest> = emptyMap(),
val stopOnFirstFailure: Boolean = true,
val extraParams: Map<String, String> = emptyMap()
val allowParallelMode: Boolean = false,
val deduplicationKey: UUID = UUID.randomUUID(),
) : ApiRequest {

override fun toRequestInfo() = RequestInfo.createPostRequest(
pathSegments = listOf(
"batch"
),
params = extraParams + mapOf(
"stopOnFirstFailure" to stopOnFirstFailure.toString()
params = mapOf(
"stopOnFirstFailure" to stopOnFirstFailure.toString(),
"allowParallelMode" to allowParallelMode.toString(),
"deduplicationKey" to deduplicationKey.toString(),
),
httpBody = HttpBody.JsonBody(
obj = requests.map { (id, request) ->
Expand All @@ -31,15 +35,18 @@ data class CreateBatchRequestWithIds(
data class CreateBatchRequest(
val requests: List<ApiRequest> = emptyList(),
val stopOnFirstFailure: Boolean = true,
val extraParams: Map<String, String> = emptyMap()
val allowParallelMode: Boolean = false,
val deduplicationKey: UUID = UUID.randomUUID(),
) : ApiRequest {

override fun toRequestInfo() = RequestInfo.createPostRequest(
pathSegments = listOf(
"batch"
),
params = extraParams + mapOf(
"stopOnFirstFailure" to stopOnFirstFailure.toString()
params = mapOf(
"stopOnFirstFailure" to stopOnFirstFailure.toString(),
"allowParallelMode" to allowParallelMode.toString(),
"deduplicationKey" to deduplicationKey.toString(),
),
httpBody = HttpBody.JsonBody(
obj = requests.map(SingleBatchRequest.Companion::create)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import org.apache.http.client.methods.HttpUriRequest
import java.io.IOException

class SleepForRetryAfterRateLimitRetryStrategy(
private val defaultRateLimitRetryInterval: Long = MAX_RATE_LIMIT_RETRY_INTERVAL_SECONDS,
private val maxRateLimitRetryInterval: Long = DEFAULT_RATE_LIMIT_RETRY_INTERVAL_SECONDS,
private val defaultRateLimitRetryInterval: Long = DEFAULT_RATE_LIMIT_RETRY_INTERVAL_SECONDS,
private val maxRateLimitRetryInterval: Long = MAX_RATE_LIMIT_RETRY_INTERVAL_SECONDS,
private val defaultRateLimitAttempts: Int = DEFAULT_RATE_LIMIT_ATTEMPTS,
private val onEverySecondOfWaiting: (Long) -> Unit = EMPTY_WAITING_REACTION,
private val beforeEachRequestAttempt: () -> Unit = EMPTY_BEFORE_REQUEST_ACTION,
Expand Down