Reputation: 519
I'm trying out some OpenWhisk actions in Swift. For better or worse, almost all of the OpenWhisk documentation is about javascript. When writing actions in javascript, it looks like you can package up code as an npm module and require/import it into any action. With Swift, there's no indication that there's any way to share code. I found one sample project (https://github.com/SwiftOnTheServer/DrinkChooser by the inestimable @rob-allen) which uses the clever trick of pre-processing the source code files before building them:
cat actions/_common.swift actions/myaction.swift > build/myaction.swift
Is there an official way to share code across actions?
Many thanks.
Upvotes: 0
Views: 97
Reputation: 4339
Building Swift binaries locally and creating actions from those binaries will allow you to do this. Swift's package manager will generate multiple executables if you have the correct directory layout.
This example project which uses The Serverless Framework to build and deploy multiple binaries as OpenWhisk actions.
Creating actions from Swift sources files does not support providing multiple sources files for code sharing.
Upvotes: 1