Hexaville - The Serverless Framework using AWS Lambda + ApiGateway etc as a back end.
Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to develop more, faster.
It’s the greatest motivation to help many Swift and mobile application developers with rapid server side development and low cost operation.
The script clones the hexaville repository to ~/.hexaville and adds the source line to your profile (~/.zshrc, or ~/.bashrc).
export PATH="$PATH:$HOME/.hexaville"
source your profile and then, type hexaville
source ~/.bashrc
hexaville
Install Hexaville from Source
git clone https://github.com/noppoMan/Hexaville.git
cd Hexaville
swift build
and then, should link Hexaville executable path to /usr/local/bin or something like that.
Create a Project
Usage: hexaville generate <projectName>
hexaville generate Hello --dest /path/to/your/app
swift-tools-version
You can specify swift-tools-version for the new project with --swift-tools-version option.
Current default tool version is 5.1
If the tool version is higher than 3.1, layouts and definiations of Package.swift are refined.
e.g.
# swift.version will be 5.1
hexaville generate Hello
# swift.version will be 5.0
hexaville generate Hello --swift-tools-version 5.0
# swift.version will be swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a
hexaville generate Hello --swift-tools-version swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a
build a swift application on the docker(Ubuntu14.04) to create the ELF that is executed on servrless environment.
zip ELF, swift standard libraries, runtime program and assets
cd /path/to/your/app
hexaville package
Deploying to the cloud
serverless deploy --stage staging
Default serverless.yml that is created by hexaville generate has only staging and production environment.
If you’d like to add other environments, please edit severless.yml manually.
Troubleshooting
1. What is executableTarget in Hexavillefile.yml?
executableTarget is a name that specified in products(name: 'executableTarget') on Package.swift. In following case, it’s a my-app not MyApp.
You can also upload static assets.
Just put your assets into the assets directory in your project root.
Loading Static Assets in Application
You can load static assets from local filesystem with AssetLoader
import HexavilleFramework
let data = try AssetLoader.shared.load(fileInAssets: "/html/index.html")
Against for the Severless weak points
Too many connections will created between Serveless functions and RDB, Cache Server
Almost Web develoeprs access RDB, Cache Server through connection pooling from your applications. It’s a one of the best practice for reducing connection for them. But Functions that are called on Serverless is like a Pre-Folk. It means can not have connection pooling and the number of connection of Database is same as number of functions that are executed in parallel.
All developers should feel welcome and encouraged to contribute to Hexaville, see our getting started document here to get involved.
To contribute a feature or idea to Hexaville, submit an issue and fill in the template. If the request is approved, you or one of the members of the community can start working on it.
If you find a bug, please submit a pull request with a failing test case displaying the bug or create an issue.
If you find a security vulnerability, please contact yuki@miketokyo.com as soon as possible. We take these matters seriously.
Hexaville
Hexaville - The Serverless Framework using AWS Lambda + ApiGateway etc as a back end. Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to develop more, faster.
It’s the greatest motivation to help many Swift and mobile application developers with rapid server side development and low cost operation.
Supported Cloud Servises
Pre-Required
Deployment Engine
Plugins
Recommended Database Clients
Example Application for Hexaville
HexavilleTODOExample has following practical examples for Hexaville application.
Quick Start
Install Docker for mac
Install Docker for mac from here, If you haven’t installed yet.
Install Hexaville from Script(Highly recommended)
The script clones the hexaville repository to
~/.hexaville
and adds the source line to your profile (~/.zshrc, or ~/.bashrc).source
your profile and then, typehexaville
Install Hexaville from Source
and then, should link Hexaville executable path to /usr/local/bin or something like that.
Create a Project
Usage: hexaville generate <projectName>
swift-tools-version
You can specify swift-tools-version for the new project with
--swift-tools-version
option. Current default tool version is5.1
If the tool version is higher than 3.1, layouts and definiations of
Package.swift
are refined.e.g.
Open your project with Xcode
The created codes in the project is example snippet of https://github.com/noppoMan/HexavilleFramework
HexavilleFramework is an express like micro framework for Hexaville.
The syntax is following.
Deploy Your Project
Hexaville depends on serverless at deployment.
See Install Guide: https://serverless.com/framework/docs/getting-started/
Packaging hexaville application
hexaville package
command does the following.Deploying to the cloud
Default serverless.yml that is created by
hexaville generate
has only staging and production environment. If you’d like to add other environments, please edit severless.yml manually.Troubleshooting
1. What is executableTarget in Hexavillefile.yml?
executableTarget
is a name that specified inproducts(name: 'executableTarget')
on Package.swift. In following case, it’s amy-app
notMyApp
.Access to your api resources
or access the endpoint from Browser.
Binary Media Types
Currenty Hexaville supports following binary media types
How to get binary content?
Threr are two rules to respond to the binary content in the routing handler.
"Content-Type": "{BinaryMediaType}"
to the response headersGetting binary content from Hexaville, need to send request that includes
Content-Type: {BinaryMediaType}
andAccept: {BinaryMediaType}
headersHow to debug?
You can debug your application with the HexavilleFramework’s builtin web server with serve command.
Advanced Settings
Environment Variables
See: https://serverless.com/framework/docs/providers/aws/guide/variables/
VPC and Security Groups
See: https://serverless.com/framework/docs/providers/aws/guide/functions#vpc-configuration
Swift Versioning and Build Configuration
You can configure swift versioning and build configuration in
swift
directive5.1
debug
Use SWIFT DEVELOPMENT-SNAPSHOT
You can also specify SWIFT DEVELOPMENT-SNAPSHOT as internal using swift version.
The format is same as swiftenv version
e.g.
Static Assets
You can also upload static assets. Just put your assets into the
assets
directory in your project root.Loading Static Assets in Application
You can load static assets from local filesystem with
AssetLoader
Against for the Severless weak points
Too many connections will created between Serveless functions and RDB, Cache Server
Almost Web develoeprs access RDB, Cache Server through connection pooling from your applications. It’s a one of the best practice for reducing connection for them. But Functions that are called on Serverless is like a Pre-Folk. It means can not have connection pooling and the number of connection of Database is same as number of functions that are executed in parallel.
In that case, Hexaville provides you to connection pooling mechanism with hexaville-tcp-proxy-server.
hexaville-tcp-proxy-server is not only a Proxy Sever But Connection Pooling Server. See the detail to see README.
Cold Start
There are several third parties’s libraries to againt cold start on github.
The major one is serverless-plugin-warmup
How to update Hexaville CLI Version?
Contributing
All developers should feel welcome and encouraged to contribute to Hexaville, see our getting started document here to get involved.
To contribute a feature or idea to Hexaville, submit an issue and fill in the template. If the request is approved, you or one of the members of the community can start working on it.
If you find a bug, please submit a pull request with a failing test case displaying the bug or create an issue.
If you find a security vulnerability, please contact yuki@miketokyo.com as soon as possible. We take these matters seriously.
Related Articles
License
Hexaville is released under the MIT license. See LICENSE for details.