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

FaaStRuby

 FaaStRuby

FaaStRuby + Inesita♥

さっちゃん

March 28, 2019
Tweet

More Decks by さっちゃん

Other Decks in Programming

Transcript

  1. FaaStRuby
    https://faastruby.io/

    View full-size slide

  2. .。oO(さっちゃんですよヾ(〃l _ l)ノ゙ ☆)
    .。oO(Ruby をもっと dynamic に使ひたい(〃l _ l)☆)

    View full-size slide

  3. FaaStRuby とは、Ruby で作れる FaaS framework です。

    View full-size slide

  4. FaaS って何?
    Serverless Framework を本番環境に投入するために
    https://speakerdeck.com/ne_sachirou/serverless‑frameworkwoben‑fan‑huan‑jing‑nitou‑
    ru‑surutameni

    View full-size slide

  5. FaaS って何?
    Function を第一級市民として扱ふインフラ設計。

    View full-size slide

  6. Serverless
    https://serverless.com/
    老舗。Polyglot。複數の cloud FaaS を扱へる。樣々な serverless resource を扱へる。

    View full-size slide

  7. Ruby on Jets
    http://rubyonjets.com/
    Ruby on Rails on FaaS
    cf. Meguro.rb#24 serverless ruby with jets ‑ Speaker Deck
    https://speakerdeck.com/ohr486/serverless‑ruby‑with‑jets

    View full-size slide

  8. FaaStRuby
    https://faastruby.io/
    Easy, easy, easy
    独自 infrastructure。Heroku のように實行 service までをそなへる。

    View full-size slide

  9. FaaStRuby tutorial

    View full-size slide

  10. faastruby new-project example
    + d ./example
    + f ./example/project.yml
    + f ./example/secrets.yml
    + d ./example/functions/root
    + f ./example/functions/root/index.html.erb
    + f ./example/functions/root/template.rb
    + f ./example/functions/root/handler.rb
    + f ./example/functions/root/faastruby.yml
    + d ./example/functions/catch-all
    + f ./example/functions/catch-all/404.html
    + f ./example/functions/catch-all/handler.rb
    + f ./example/functions/catch-all/faastruby.yml
    + f ./example/public/faastruby.yml
    + f ./example/.gitignore
    Initialized empty Git repository in /Users/inoue_sachiro/dev/example/.git/
    Project 'example' initialized.
    Now run:
    $ cd example
    $ faastruby local
    Then visit http://localhost:3000

    View full-size slide

  11. .
    ├── functions/
    │ ├── catch-all/
    │ │ ├── 404.html
    │ │ ├── faastruby.yml
    │ │ └── handler.rb
    │ └── root/
    │ ├── faastruby.yml
    │ ├── handler.rb
    │ ├── index.html.erb
    │ └── template.rb
    ├── project.yml
    ├── public/
    │ ├── assets/
    │ │ ├── images/
    │ │ │ ├── favicon-150x150.png
    │ │ │ ├── favicon.png
    │ │ │ └── logo-positive.png
    │ │ ├── javascripts/
    │ │ │ └── main.js
    │ │ └── stylesheets/
    │ │ └── main.css
    │ ├── faastruby.yml
    │ └── favicon.ico
    └── secrets.yml

    View full-size slide

  12. faastruby signup
    Welcome to FaaStRuby! Please enter your email address:
    Email:

    Now type in a password. It must contain 8 to 50 characters and have at least one uppercase letter, one lowercase letter, one number and one special character @ $ ! % * ? &
    Password:
    Your password must contain 8 to 50 characters and have at least one uppercase letter, one lowercase letter, one number and one special character @ $ ! % \* ? &
    Please try again:
    ✔ Creating your account...
    You should have received an email with a confirmation token.
    If you didn't receive an email:
    - Make sure you sign up with the correct email address
    - The system won't send an email if you account status is already 'confirmed'
    Confirmation Token:

    ✔ Confirming your account...
    Login successful!

    View full-size slide

  13. 左が http://localhost:3000/

    View full-size slide

  14. handler に渡される event
    #@body=nil,
    @context="{}",
    @headers=
    {"Version"=>"HTTP/1.1",
    "Host"=>"localhost:3000",
    "Connection"=>"keep-alive",
    "Cache-Control"=>"max-age=0",
    "Upgrade-Insecure-Requests"=>"1",
    "User-Agent"=>
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.88 Safari/537.36 Vivaldi/2.5.1497.4",
    "Accept"=>
    "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding"=>"gzip, deflate, br",
    "Accept-Language"=>"ja,en-US;q=0.9,en;q=0.8",
    "Content-Type"=>nil,
    "Request-Method"=>"GET",
    "Content-Length"=>nil,
    "Remote-Addr"=>"127.0.0.1",
    "X-Request-Id"=>"31494a89-5b1d-4de9-a1e2-be14e44cbe35"},
    @query_params={}>

    View full-size slide

  15. FaaStRuby で簡單に serverless backend を作れます。
    ERB を書けば frontend も載せられます。

    View full-size slide

  16. frontend も Ruby で書きたくありませんか?

    View full-size slide

  17. Opal ですよね。
    https://opalrb.com/

    View full-size slide

  18. Inesita
    https://inesita.fazibear.me/
    virtual‑dom を Ruby (Opal) で實現する。

    View full-size slide

  19. Inesita tutorial

    View full-size slide

  20. inesita new example
    create example
    create example/.gitignore
    create example/.sprockets.rb
    create example/Gemfile
    create example/README.md
    create example/app/application.rb
    create example/app/components/counter.rb
    create example/app/components/description.rb
    create example/app/components/home.rb
    create example/app/components/navbar.rb
    create example/app/index.html.slim
    create example/app/router.rb
    create example/app/store.rb
    create example/app/stylesheet.css.sass
    create example/config.ru
    create example/static/inesita-rb.png
    run bundle install from "./example"

    View full-size slide

  21. .
    ├── Gemfile
    ├── README.md
    ├── app/
    │ ├── application.rb
    │ ├── components/
    │ │ ├── counter.rb
    │ │ ├── description.rb
    │ │ ├── home.rb
    │ │ └── navbar.rb
    │ ├── index.html.slim
    │ ├── router.rb
    │ ├── store.rb
    │ └── stylesheet.css.sass
    ├── config.ru
    └── static/
    └── inesita-rb.png

    View full-size slide

  22. bundle exec inesita build

    View full-size slide

  23. Crystal
    https://crystal‑lang.org/
    HyperStack (a.k.a. HyperLoop) https://hyperstack.org/ : React の wrapper。「Crystal
    を support したい」とか言ってる。
    FaaStRuby : Crystal を support してゐる。
    Ruby と Crystal は仲良くしたいですね(〃l _ l) (小並感

    View full-size slide