如何访问 doIf 块中的会话属性?

How to access session attributes in doIf block?

我正在尝试编写 gatling 测试步骤,它将根据一些已保存的会话值进行重试。我如何访问以下 doIf 链步骤中的值?

val step = asLongAs(session => !session.contains("status") || session("status").as[Int] == 123) {
  exec(http("post")
   .post("/test")
   .check(status.saveAs("status"))
   .check(
     checkIf(session => session("status").as[Int] == 123) {
       jsonPath("$.data1").saveAs("data1")
       jsonPath("$.data2").saveAs("data2")
     }))
 .doIf(session => session("status").as[Int] == 123) {
    pause(data1, data2) // <------- use data here HERE
 }
}
.doIf(session => session("status").as[Int] == 123) {
  pause(
    session => {
      val data = session("data").as[String] // data is a String, not a FiniteDuration
      ??? // your job to return a FiniteDuration based on the data String
    },
    session => {
      val data = session("data").as[String] // data is a String, not a FiniteDuration
      ??? // your job to return a FiniteDuration based on the data String
    }
  )
}