Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Server-Side Swift @ Devoxx FR
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Simone Civetta
April 07, 2017
Programming
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Server-Side Swift @ Devoxx FR
Simone Civetta
April 07, 2017
More Decks by Simone Civetta
See All by Simone Civetta
2021: CI for Mobile: State of The Art
viteinfinite
0
390
MVI : une architecture robuste et moderne pour vos applications mobiles
viteinfinite
2
550
Cross-Platform Modules with Kotlin/Native (v. 2018.10)
viteinfinite
0
120
Face Recognition with Vision & Core ML
viteinfinite
1
1.1k
Shared Cross-Platform Modules with Kotlin/Native
viteinfinite
1
350
Swift on the Raspberry PI
viteinfinite
0
140
Server-Side Swift
viteinfinite
0
100
Be the Quality You Want to See in Your App [Swift Edition]
viteinfinite
1
440
Swift : Nouvelles du front
viteinfinite
0
120
Other Decks in Programming
See All in Programming
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
170
継続モナドとリアクティブプログラミング
yukikurage
3
500
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
310
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
260
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
480
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
210
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
610
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.3k
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
170
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
3.5k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
Featured
See All Featured
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
370
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.9k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
340
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
260
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
My Coaching Mixtape
mlcsv
0
170
The Mindset for Success: Future Career Progression
greggifford
PRO
0
410
Building an army of robots
kneath
306
46k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.7k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Transcript
Swi! Côté Serveur 1
Salut 2
Simone Cive!a 3
Je suis un développeur iOS 4
7 ans 5
6
4 ans 7
8
9
10
11
12
13
Enfin... 14
Plan 1. Les Origines 2. État de l'art 3. Pourquoi
l'utiliser ? 4. Swift Server dans la vraie vie 5. Évolutions 15
1. Les origines 16
17
18
Pourquoi Open Source ? 19
20
21
22
23
24
2. État de l'art 25
Swi! 3.1 26
1.0 27
1.1 28
1.2 29
2.0 30
2.1 31
2.2 32
2.3 33
3.0 34
Swi! 3.1 35
En 2015-16 1 version tous les 2 mois 36
Un langage (presque) finalisé 37
Un langage complet 38
39
40
41
42
43
bibliothèques tierces 44
Beaucoup de bibliothèques tierces stables 45
46
47
48
Bibliothèques C 49
Frameworks Web 50
51
52
53
54
55
Swi! Package Manager 56
SPM swift package init swift package fetch swift package update
swift package generate-xcodeproj 57
Swi! Package Catalog 58
59
60
61
Quelques images Docker — swiftdocker/swift/ — ibmcom/kitura-ubuntu/ — zewo/todobackend/ 62
Qualité du code 63
64
65
66
67
Metriques de qualité Pour en savoir plus... speakerdeck.com/viteinfinite/be-the-quality-you-want- to-see-in-your-app-swift-edition 68
69
70
nuclide.io/docs/languages/swift/ 71
! 72
Enfin... 73
3. Pourquoi l'utiliser ? 74
Développement actif 75
76
77
78
79
80
81
Performance 82
Performance 83
Performance 84
Mémoire Source: http://benchmarksgame.alioth.debian.org 85
Applications isomorphes 86
GCD 87
4. Dans la vraie vie 88
89
90
L'application Serveur 1. Routing 2. Fichiers statiques 3. Proxy YouTube
4. Caching 91
Package.swi! import PackageDescription let package = Package( name: "XebiaTV", dependencies:
[ .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 5), .Package(url: "https://github.com/vapor/redis-provider.git", majorVersion: 1) ] ) 92
Router import Foundation import Vapor let drop = Droplet() let
categoryController = CategoryController() let youtubeController = YouTubeController() drop.get("/categories", handler: categoryController.categories) drop.get("/playlistItems", handler: youtubeController.playlistItems) drop.get("/search", handler: youtubeController.search) drop.get("/live", handler: youtubeController.live) drop.get("/video", String.self, handler: youtubeController.video) drop.run() 93
Fichiers statiques import Foundation import Vapor import Core import HTTP
final class CategoryController { private let dataLoader = DataFile() func categories(_ req: Request) throws -> ResponseRepresentable { let fileBody = try dataLoader.load(path: drop.workDir + "Data/categories.json") return Response(body: .data(fileBody)) } } 94
Proxy YouTube public final class YouTubeController { // ... func
search(_ req: Request) throws -> ResponseRepresentable { let query = "\(googleApisBaseUrl)/search?key=\(apiKey)&channelId=\(channelId)" return try drop.client.get(query) } } 95
// ... public func video(_ req: Request, videoId: String) throws
-> ResponseRepresentable { let cacheKey = "video-\(videoId)" guard let cached = try cacheService.load(for: cacheKey) else { let urls = try videoUrls(for: videoId) try cacheService.save(node: urls, with: cacheKey, expiration: cacheExpiration) return try JSON(node: urls) } return try JSON(node: cached) } private func videoUrls(for videoId: String) throws -> Node { guard let urls = try LiveStreamerReader.read(videoId: videoId) else { throw Error.noVideo } return Node(["urls": Node.array(urls)]) } 96
Intégration avec LiveStreamer static func launch(_ command: String, args: [String]
= []) throws -> Data { #if os(Linux) let task = Task() #else let task = Process() #endif let pipe = Pipe() task.launchPath = command task.arguments = args task.standardOutput = pipe task.launch() let data = pipe.fileHandleForReading.readDataToEndOfFile() task.waitUntilExit() return data } 97
Cache avec Redis public protocol CacheService { func load(for key:
String) throws -> Node? func save(node: Node, with key: String, expiration: TimeInterval) throws } public class RedisService : CacheService { private let drop: Droplet public init(drop: Droplet) throws { try drop.addProvider(VaporRedis.Provider(config: drop.config)) self.drop = drop } public func load(for key: String) throws -> Node? { return try drop.cache.get(key) } public func save(node: Node, with key: String, expiration: TimeInterval) throws { try drop.cache.set(key, node) if let redisCache = drop.cache as? RedisCache { try redisCache.redbird.command("EXPIRE", params: [key, "\(Int(expiration))"]) } } } 98
Build $ swift build Compile CLibreSSL xts128.c Compile CLibreSSL x_x509a.c
Compile CLibreSSL xcbc_enc.c Compile CLibreSSL x_spki.c .... Compile Swift Module 'libc' (1 sources) Compile Swift Module 'SocksCore' (15 sources) Compile Swift Module 'Jay' (21 sources) Linking CLibreSSL Compile Swift Module 'Core' (28 sources) Compile Swift Module 'Routing' (11 sources) Compile Swift Module 'HTTPRouting' (5 sources) Compile Swift Module 'TypeSafeRouting' (3 sources) Compile Swift Module 'Cache' (3 sources) Compile Swift Module 'Auth' (15 sources) Compile Swift Module 'Vapor' (92 sources) Compile Swift Module 'VaporRedis' (2 sources) Compile Swift Module 'App' (6 sources) 99
Tests class AppTests: XCTestCase { // ... Create a StubCategoryController
func testCategoryRoute() throws { let drop = try makeTestDroplet(categoryController: StubCategoryController()) let request = try Request(method: .get, uri: "/categories") let response = try drop.respond(to: request) let jsonBody = try JSON(bytes: response.body.bytes!) XCTAssertEqual(jsonBody["categories"]?.string, "someCategory") } } 100
101
Tout s'est bien passé™ 102
Enfin... 103
104
105
Cross platform #if os(Linux) import Glibc #else import Darwin #endif
106
Swift Build 107
Swi! Package Manager Mess swift package generate-xcodeproj 108
Tester c'est linker (?) Undefined symbols for architecture x86_64: "test2.test2.init
() -> test2.test2", referenced from: test2Tests.test2Tests.(testExample () -> ()). (implicit closure #1) in test2Tests.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 109
5. Évolutions 110
Encore plus de Frameworks 111
Encore plus de APIs Swi! 112
113
114
Peut-on le déployer en prod ? 115
Oui ! 116
Enfin... 117
Merci ! 118
Simone Cive!a 119
Je suis un développeur iOS 120
Je suis un développeur Back 121
Enfin... 122
123
Be a Be!er Developer beabe!er.ninja 124
125