def updateForIndex()

in app/services/DynamoCapacityActor.scala [89:122]


  def updateForIndex(rq:UpdateCapacityIndex, desc:TableDescription):Try[Option[GlobalSecondaryIndexUpdate]] = {
    val indexDesc = desc.globalSecondaryIndexes().asScala.find(_.indexName()==rq.indexName) match {
      case None=>
        return Failure(new RuntimeException(s"Could not find index ${rq.indexName} on table ${desc.tableName()}"))
      case Some(idx)=>idx
    }
    val currentThroughput = indexDesc.provisionedThroughput()

    val actualReadTarget = rq.readTarget match {
      case None=>currentThroughput.readCapacityUnits().toLong
      case Some(tgt)=>tgt.toLong
    }

    val actualWriteTarget = rq.writeTarget match {
      case None=>currentThroughput.writeCapacityUnits().toLong
      case Some(tgt)=>tgt.toLong
    }

    if(currentThroughput.readCapacityUnits()==actualReadTarget && currentThroughput.writeCapacityUnits()==actualWriteTarget){
      Success(None)
    } else {
      Success(Some(GlobalSecondaryIndexUpdate.builder().update(
        UpdateGlobalSecondaryIndexAction.builder()
          .indexName(rq.indexName)
          .provisionedThroughput(ProvisionedThroughput.builder()
            .readCapacityUnits(actualReadTarget)
            .writeCapacityUnits(actualWriteTarget)
            .build()
          )
          .build()
        ).build()
      ))
    }
  }