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

Server Side Framework Slimaneの紹介

Server Side Framework Slimaneの紹介

ポテトチップス#30で発表した資料です。

Yuki Takei

June 23, 2016
Tweet

More Decks by Yuki Takei

Other Decks in Technology

Transcript

  1. S e r v e r S i d e

    S w i f t F r a m e S l i m a n e ͷ ঺ հ 2 0 1 6 J u n 2 3 p o t a t o t i p s 3 0 Yu k i Ta k e i
  2. n o p p o M a n ͜ ͱ

    ɺ ෢ Ҫ ༏ ݾ ͱ ਃ ͠ · ͢ɻ
  3. ๻ ͕ ։ ൃ ͯ͠ ͍ Δ S w i

    f t 3 ͷ WA F / H T T P S e r v e r h t t p s : / / g i t h u b . c o m / n o p p o M a n / S l i m a n e • 100%ඇಉظ(libuvϕʔεͷϥϯλΠϜɻlibuv͸node.jsͷ৺ଁ) • ExpressΛΠϯεύΠΞ(Ϟδϡʔϧࢦ޲) • Stand alone HTTP Server • ߴ଎ (node.jsͷ5ഒɺRevel(GO)ͷ2ഒ) • Open-SwiftʹଌͬͨAPIσβΠϯ • Ϛϧνϓϩηε؀ڥʹ΋ରԠ(Cluster/WorkerɻipcͰࢠϓϩηεͱ௨৴) • CoreFoundationʹґଘ͠ͳ͍
  4. S w i f t y - L i b

    u v S U V S K E LT O N S L I M A N E SlimaneͷϨΠϠʔ OS App libuvͷSwiftόΠϯσΟϯά ඇಉظωοτϫʔΫϓϥοτϑΥʔϜ TCPɺUDPɺProcessɺ FIleSystemɺDNS etc… SuvϕʔεͷHTTPαʔόʔ HTTPϓϩτίϧͷύʔζ ΞϓϦέʔγϣϯϑϨʔϜϫʔΫ system callɺevent loop
  5. import Slimane let app = Slimane() // Register a middleware

    app.use { req, next, completion in print("[pid:\(Process.pid)]\t\(Time())\t\(req.path ?? "/")") next(to: req, result: completion) } // Routing app.get("/") { req, responder in responder { Response(body: "Welcome Slimane!") } } try! app.listen(port: 3000) // Server is listening at 0.0.0.0:3000 ΞϓϦέʔγϣϯͷىಈίʔυ
  6. $ n p m i - g s l i

    m a n e - c l i
  7. S l i m a n e ͸ F W

    ࣗ ମ ͸ খ ͞ ͍Ͱ ͢ ͕ɺ ༷ ʑ ͳ Ϟ δϡ ʔϧ Λ ૊ Έ ߹ Θ ͤ ͯ Ξ ϓ Ϧ έ ʔ γ ϣ ϯ Λ ߏ ங Ͱ ͖ · ͢ɻ
  8. S e s s i o n M i d

    d l e w a re https://github.com/slimane-swift/SessionMiddleware ηογϣϯػೳΛఏڙɻ RedisΛSessionσʔλͷετΞઌʹઃఆՄೳ https://github.com/slimane-swift/SessionRedisStore
  9. B o d y P a r s e r

    ( m i d d l e w a re ) https://github.com/slimane-swift/BodyParser JSONɺFormDataͷύʔζػೳΛఏڙ
  10. Q W F u t u re https://github.com/slimane-swift/QWFuture IOΛϒϩοΫ͢Δؔ਺΍ɺΠϕϯτϧʔϓΛࢭΊͯ͠·͏Α͏ ͳॏ͍ॲཧΛ͢ΔࡍʹɺผεϨουͰॲཧΛ࣮ߦͯ͠ऴΘͬͨ

    ΒϝΠϯϧʔϓʹ໭͢ͱ͍ͬͨॲཧΛߦ͏ࡍʹར༻ɻ ʢGCDͷdispatch_asyncΈ͍ͨͳ΋ͷΛFutureΛѻ͏Α͏ͳΠ ϯλʔϑΣʔεͰఏڙ͍ͯ͠Δ΋ͷʣ
  11. ί ϯ τ Ϧ Ϗ ϡ ʔ λ ʔ ื

    ू ͠ ͯ ͓ Γ · ͢ ʂ ʂ ʂ https://slimane-swift-slackin.herokuapp.com/ Slack channel͸ͪ͜Β