def putPathItemAndAwaitIndexUpdate()

in path-manager/app/services/PathStore.scala [269:295]


  def putPathItemAndAwaitIndexUpdate(record: PathRecord): Unit = {

    Dynamo.pathsTable.putItem(record.asDynamoItem)

    def waitForIndexUpdate(attempts: Int = 0): Boolean = {

      if (attempts > 20) {
        logger.warn(s"update to path [${record.path}] for id [${record.identifier}] has not propagated to secondary index after 20 checks")
        false
      } else {
        val pathRecordsFromIndex = Dynamo.pathsTable.getIndex("id-index").query(new KeyAttribute("identifier", record.identifier), RangeKeyMatches.rangeKeyMatches("type", record.`type`)).asScala

        val pathRecordFromIndex = pathRecordsFromIndex.map {
          PathRecord(_)
        }.headOption

        pathRecordFromIndex match {
          case Some(i) if (i.path == record.path) => true
          case _ => {
            Thread.sleep(50)
            waitForIndexUpdate(attempts + 1)
          }
        }
      }
    }

  }