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

Server Side Framework Slimaneの紹介

Server Side Framework Slimaneの紹介

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

9ebab3d4f66a62a859ad238e7e97597f?s=128

Yuki Takei

June 23, 2016
Tweet

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. ๻ͷൃද͸ɺiOSͰ΋AndroidͰ΋͋Γ·ͤΜɺɺ ͝༰͍ࣻͩ͘͞

  3. n o p p o M a n ͜ ͱ

    ɺ ෢ Ҫ ༏ ݾ ͱ ਃ ͠ · ͢ɻ
  4. 6೥ؒԿ΋ͯ͠ͳ͔ͬͨTwitterΛ࠷ۙ෮׆ͤ͞·ͨ͠ʢস͍ʣ @noppoMan722 ΛੋඇϑΥϩʔ͓ئ͍க͠·͢m(_ _)m

  5. None
  6. Tokyo Server Side Swift Meetup΍ͬͯ·͢ʂʂ

  7. None
  8. None
  9. Slimaneͱ͸……

  10. ๻ ͕ ։ ൃ ͯ͠ ͍ Δ 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ʹґଘ͠ͳ͍
  11. 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
  12. 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 ΞϓϦέʔγϣϯͷىಈίʔυ
  13. ίϚϯυϥΠϯΠϯλʔϑΣʔε ͔ΒϓϩδΣΫτΛ࡞੒Մೳ

  14. $ n p m i - g s l i

    m a n e - c l i
  15. One more thing…..

  16. S l i m a n e ͸ F W

    ࣗ ମ ͸ খ ͞ ͍Ͱ ͢ ͕ɺ ༷ ʑ ͳ Ϟ δϡ ʔϧ Λ ૊ Έ ߹ Θ ͤ ͯ Ξ ϓ Ϧ έ ʔ γ ϣ ϯ Λ ߏ ங Ͱ ͖ · ͢ɻ
  17. 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
  18. 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ͷύʔζػೳΛఏڙ
  19. R e n d e r https://github.com/slimane-swift/Render ςϯϓϨʔτͷϨϯμϦϯάػೳΛఏڙɻ ݱࡏ͸MustacheΛαϙʔτ https://github.com/slimane-swift/MustacheViewEngine

  20. W S https://github.com/slimane-swift/WS Websocketαʔόʔ/ΫϥΠΞϯτ࣮૷ɻ Slimaneͷmiddlwareͱͯ͠ಈ࡞͠·͢ɻ

  21. T h r u s h https://github.com/noppoMan/Thrush ES6ϥΠΫͳPromiseΛఏڙɻ ίʔϧόοΫ஍ࠈͷٹࡁࡦͷͻͱͭʹ…..

  22. Q W F u t u re https://github.com/slimane-swift/QWFuture IOΛϒϩοΫ͢Δؔ਺΍ɺΠϕϯτϧʔϓΛࢭΊͯ͠·͏Α͏ ͳॏ͍ॲཧΛ͢ΔࡍʹɺผεϨουͰॲཧΛ࣮ߦͯ͠ऴΘͬͨ

    ΒϝΠϯϧʔϓʹ໭͢ͱ͍ͬͨॲཧΛߦ͏ࡍʹར༻ɻ ʢGCDͷdispatch_asyncΈ͍ͨͳ΋ͷΛFutureΛѻ͏Α͏ͳΠ ϯλʔϑΣʔεͰఏڙ͍ͯ͠Δ΋ͷʣ
  23. $ slimane new MySlimaneApp -f -fΦϓγϣϯΛ෇͚Δ͜ͱͰɺFullStackͳSlimaneΛָ͓͠Έ௖͚·͢ɻ

  24. sampleίʔυ΋͋Γ·͢ʂ

  25. ί ϯ τ Ϧ Ϗ ϡ ʔ λ ʔ ื

    ू ͠ ͯ ͓ Γ · ͢ ʂ ʂ ʂ https://slimane-swift-slackin.herokuapp.com/ Slack channel͸ͪ͜Β
  26. ͝ ੩ ௌ ͋ Γ ͕ ͱ ͏ ͝ ͟

    ͍ · ͠ ͨ