【问题标题】:Calling an AWS Lambda function via APIGateway synchronously in Swift在 Swift 中通过 APIGateway 同步调用 AWS Lambda 函数
【发布时间】:2017-08-08 23:18:07
【问题描述】:

我可以在我的代码中异步调用 AWS lambda 函数,如下所示:

var r = IPInputToResourceGetSpots()
r.latitude = 37.8050638 //destination.latitude
r.longitude = -122.2972835 //destination.longitude
r.radius = 1000

let client = IPIOSAppAPIClient.defaultClient()

var results:IPOutputToResourceGetSpots = IPOutputToResourceGetSpots()
client.resourcegetspotsPost(r).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: { (task: AWSTask!) -> AnyObject! in

//Deal with return of AWS function
return task
})

但我想要的是同步调用代码并在调用 AWS 函数时暂停代码,直到调用完成。我试过改变这一行:

client.resourcegetspotsPost(r).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: { (task: AWSTask!) -> AnyObject! in

与:

client.resourcegetspotsPost(r).continueWithBlock({ (task: AWSTask!) -> AWSTask! in

但两者似乎都是异步的......

【问题讨论】:

    标签: swift amazon-web-services aws-lambda aws-sdk aws-api-gateway


    【解决方案1】:

    看看下面的帖子,并结合 waitUntilFinished()

    AWSTask Synchronous

    【讨论】:

      猜你喜欢
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-04
      • 2018-02-03
      • 2017-07-13
      • 1970-01-01
      • 2020-04-04
      相关资源
      最近更新 更多