Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package app.cash.backfila.client.dynamodb.internal
import app.cash.backfila.client.dynamodb.ForDynamoDbBackend
import app.cash.backfila.protos.clientservice.KeyRange
import com.amazonaws.services.dynamodbv2.model.AttributeValue
import com.google.inject.util.Types
import com.squareup.moshi.FromJson
import com.squareup.moshi.Moshi
import com.squareup.moshi.ToJson
import javax.inject.Inject
import javax.inject.Singleton
import okio.Buffer
import okio.ByteString
import okio.ByteString.Companion.toByteString
/**
* With DynamoDB each run selects the number of segments so we need begin, end, and count to
* uniquely identify a range.
*/
internal data class DynamoDbKeyRange(
val start: Int,
val end: Int,
val count: Int,
val lastEvaluatedKey: Map? = null,
) {
init {
// Only allow lastEvaluatedKey to be non-null if the range includes a single segment.
if (lastEvaluatedKey != null) {
require(end == start + 1)
}
}
}
/**
* It encodes the key range in utf8 for better cursor visibility in backfila.
* It's form:
* start = "v2:/:"
* end = "v2:/"
*/
@Singleton
class DynamoDbKeyRangeCodec @Inject constructor(
@ForDynamoDbBackend moshi: Moshi,
) {
private val adapter = moshi.adapter