To Protect & To Serve

Preview:

Citation preview

To Protect & To ServeJorge D. Ortiz-Fuentes

@jdortiz

A Canonical Examples

production

#Swift3Arch

Agenda

★Swift Backend

★DIY

★The Test App

Swift Backend

Disclaimer

Not a backend developer

Then, Why?

– Gustavo Adolfo Bécquer

“What is poetry? you ask, while fixing your blue pupil on mine.

What is poetry! And you are asking me? Poetry... is you.”

And you are asking me?

No Refactoring

Compiler Segmentation Fault

Migrations

Moving targetNo examples

No reflection&introspection

Xcode

Always Look at the Bright Side of Life

★Opportunity to learn

★ Linux

★Backend

★Swift Package Manager

Does it mean that…

NO

Not ready for production yet

Not ready for production yetSome Scenarios

Just an Experiment?

Kinda

Useful Scenarios

★Training

★Prototyping

★Embedded devices

★Private servers

Server Side Swift is an IDE

Immature Development Environment

Swift Package Manager

★Promising… but not finished

★Not fully integrated with Xcode

★May not find a way to satisfy the dependencies

I couldn’t make libdistpatch

😢

I couldn’t make LLDB work

😢😢😢

Illegal instruction (core dumped)

But there is hope

https://swift.org/server-apis/Saint Chris, Chapter 42 verse FF

DIY

The Tools

★Emacs (https://emacsformacosx.com/)

• Tramp (SSH)

• Swift-mode (2.2)

★ iTerm + tmux

★Google Chrome

Frameworks

★Kitura

★Perfect

★Vapor

★Zewo

Kitura

★Comes with everything and the kitchen sink

★Compiles flawlessly

★Good documentation and tutorials

★Failed to make libdispatch

for the Raspberry Pi

Perfect★Also quite complete

★Excellent documentation & tutorials

★Doesn’t fully compile in Raspberry Pi 3: NetTCP.swift & NetTCPSSL.swift (solved)

★Slack channel

★Need more time

for the Raspberry Pi

Vapor

★Worked without problems

★Abundant documentation and tutorials (vapor.university)

★ Less modular (HTTP server & router provided by Application class)

for the Raspberry Pi

Zewo★More modular, from independent pieces

★Uses libmill/co-routines

★ Failed at compiling OpenSSL (Int size)

★Really helpful Slack channel (shares members with Swift-arm channel)

★Nice todo app example

★My choice for this experiment

for the Raspberry Pi

The Pieces

Server Middleware Controller PersistenceRouter

Views

That Sounds Familiar!

Clean Architecture: iOS

App Delegate

View (VC) Presenter InteractorEntity

Gateway

Connector

The Pieces

Server Middleware Controller PersistenceRouter

Views

Interactor

Clean Architecture

The Test App

Conclusions★Swift code in Raspberry Pi has some glitches

★ The domain logic can be in a package:

• Fully tested

• Independent of the rest

★Use cases can be shared

• No asynchrony

• Some logic may be different

★Worth the investment

Things I Would Like

★ JSON home page / JSONAPI

★Better (Some) debugging

★Better support for Raspberry Pi

Thank you!

@jdortiz #Swift3Arch

Recommended