Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS Lambda Swift Runtime

giginet
December 15, 2018

AWS Lambda Swift Runtime

giginet

December 15, 2018
Tweet

More Decks by giginet

Other Decks in Programming

Transcript

  1. AWSͷओͳϞόΠϧ޲͚αʔϏε • Pinpoint: FCMΈ͍ͨͳ΍ͭ • Device Farm: Firebase TestLabΈ͍ͨͳ΍ͭ •

    AppSync • DynamoDBͱ͔LambdaͷGraphQLΠϯλʔϑΣΠεఏڙ͢Δ ΍ͭ • Mobile Hub: ͳΜ͔͍Ζ͍ΖͰ͖Δ΍ͭ
  2. import Foundation import AWSLambdaRuntime struct User: Decodable { let firstName:

    String } enum GreetingError: String, LambdaError { var message: String { switch self { case .invalidPayload: return "Payload is invalid" } } case invalidPayload } run { context -> Result<GreetingError> in guard let data = context.payload, let user = try? JSONDecoder().decode(User.self, from: data) else { return .failure(error: .invalidPayload) } let payload = try! JSONSerialization.data(withJSONObject: ["message": "Hello \(user.firstName)"]) return .success(payload: payload, contentType: "application/json") }
  3. • libdispatch͕Sta-c LinkͰ͖ͳͯ͘ࢮ͵ Compile Swift Module 'Example' (1 sources) Linking

    ./.build/x86_64-unknown-linux/debug/Example /usr/bin/ld.gold: error: cannot find -ldispatch
  4. • docker-swi,Λforkͯ͠ɺ࠷৽ͷToolchainΛؚΜͩDockerίϯ ςφͰϏϧυ͢ΔΑ͏ʹͯ͠Έͨ • ͕ɺͦΕͰ΋͏·͘ߦ͔ͳͯ͘ϋϚͬͨʢ๨Εͨʣ $ swift build -c release

    -Xswiftc -static-stdlib $ /usr/bin/swift-build: error while loading shared libraries: libBlocksRuntime.so.0: cannot open shared object file: No such file or directory