$30 off During Our Annual Pro Sale. View Details »

Tochigi Ruby Kaigi 08 Keynote

Tochigi Ruby Kaigi 08 Keynote

分散オブジェクトとはアレですか?

seki at druby.org

June 29, 2019
Tweet

More Decks by seki at druby.org

Other Decks in Programming

Transcript

  1. 分散オブジェクトとは
    アレですか?
    SSID: toruby pass: toruby08
    Tochigi RubyKaigi 08
    Masatoshi SEKI / @m_seki

    View Slide

  2. http://www.druby.org/drb20_tork08.pdf
    ֎ʹग़Εͳ͍࣮श༻ͷωοτϫʔΫ
    SSID: toruby
    pass: toruby08
    SSID: toruby pass: toruby08

    View Slide

  3. Agenda

    Workshop
    SSID: toruby pass: toruby08

    View Slide

  4. ࡞Γͳ͕Βߟ͑Δͷ͕޷͖
    dRuby
    SSID: toruby pass: toruby08

    View Slide

  5. OOPͷϑΝϯλδʔ
    SSID: toruby pass: toruby08

    View Slide

  6. ෼ࢄOOPͷϑΝϯλδʔ
    SSID: toruby pass: toruby08

    View Slide

  7. dRubyͰ࡞ͬͨ΋ͷ
    SSID: toruby pass: toruby08

    View Slide

  8. ઌ૆ฦΓ
    OOP
    SSID: toruby pass: toruby08

    View Slide

  9. Ͱ͖͔ͯΒߟ͑ͨ͜ͱ
    SSID: toruby pass: toruby08

    View Slide

  10. ϓϩηεΛ෼͚Δҙຯ
    SSID: toruby pass: toruby08

    View Slide

  11. dRuby 20th anniversary hands-on workshop
    @m_seki / [email protected]

    View Slide

  12. ॏཁ
    2005
    !
    SSID: toruby pass: toruby08
    dRuby
    ʹΑΔ
    ؔকढ़ஶ
    ෼ࢄ
    ɾ
    Web
    ϓϩάϥϛϯά

    View Slide

  13. The dRuby Book
    2012
    Out of print
    SSID: toruby pass: toruby08

    View Slide

  14. HTML൛ެ։த
    http://www.druby.org/sidruby/
    SSID: toruby pass: toruby08

    View Slide

  15. Rubyͱࢲ
    1999
    ERB, dRuby, ....
    2000 Perl/RubyConference
    SSID: toruby pass: toruby08

    View Slide

  16. ERB
    Ruby
    SSID: toruby pass: toruby08

    View Slide

  17. dRuby
    SSID: toruby pass: toruby08

    View Slide

  18. ࠓ೔͸
    dRuby 頃
    SSID: toruby pass: toruby08

    View Slide

  19. ࠓ೔͸
    SSID: toruby pass: toruby08

    View Slide

  20. RMI
    Remote Method Invocation
    SSID: toruby pass: toruby08

    View Slide

  21. αʔό
    Web
    SSID: toruby pass: toruby08

    View Slide

  22. dRuby͸
    SSID: toruby pass: toruby08

    View Slide

  23. Ruby෩
    Web
    dRuby Ruby
    Ruby
    SSID: toruby pass: toruby08

    View Slide

  24. ԋश1
    Hello, World.
    SSID: toruby pass: toruby08

    View Slide

  25. ԋश1
    SSID: toruby pass: toruby08
    hello_server.rb hello_client.rb
    hello()
    "Hello, World."

    View Slide

  26. hello_server.rb
    require 'drb/drb'
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    DRb.start_service('druby://localhost:54000', Hello.new)
    while true
    sleep 1
    end

    View Slide

  27. require
    require 'drb/drb'
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    DRb.start_service('druby://localhost:54000', Hello.new)
    sleep

    View Slide

  28. DRb.start_service
    require 'drb/drb'
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    DRb.start_service('druby://localhost:54000', Hello.new)
    sleep

    View Slide

  29. URI
    require 'drb/drb'
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    DRb.start_service('druby://localhost:54000', Hello.new)
    sleep

    View Slide

  30. ऴྃͤ͞ͳ͍
    require 'drb/drb'
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    DRb.start_service('druby://localhost:54000', Hello.new)
    sleep

    View Slide

  31. ໿ଋࣄ
    require 'drb/drb'
    DRb.start_service
    URI
    SSID: toruby pass: toruby08

    View Slide

  32. hello_client.rb
    require 'drb/drb'
    DRb.start_service
    ro = DRbObject.new_with_uri('druby://localhost:54000')
    ro.hello

    View Slide

  33. hello_client.rb
    require 'drb/drb'
    DRb.start_service
    ro = DRbObject.new_with_uri('druby://localhost:54000')
    ro.hello

    View Slide

  34. hello_client.rb
    require 'drb/drb'
    DRb.start_service
    ro = DRbObject.new_with_uri('druby://localhost:54000')
    ro.hello

    View Slide

  35. hello_client.rb
    require 'drb/drb'
    DRb.start_service
    ro = DRbObject.new_with_uri('druby://localhost:54000')
    ro.hello

    View Slide

  36. ໿ଋࣄ
    require 'drb/drb'
    DRb.start_service
    DRbObject.new_with_uri
    SSID: toruby pass: toruby08

    View Slide

  37. ݩ͸͜Ε
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    ro = Hello.new
    ro.hello

    View Slide

  38. require 'drb/drb'
    DRb.start_service
    ro = DRbObject.new_with_uri('druby://localhost:54000')
    ro.hello
    require 'drb/drb'
    class Hello
    def hello
    puts('Hello, World.')
    end
    end
    DRb.start_service('druby://localhost:54000', Hello.new)
    sleep

    View Slide

  39. ԋश1
    hello_client.rb
    hello_server.rb hello_client.rb
    SSID: toruby pass: toruby08

    View Slide

  40. ԋश2
    (Hash)
    SSID: toruby pass: toruby08

    View Slide

  41. Hash
    ( )
    Array
    ( )
    SSID: toruby pass: toruby08

    View Slide

  42. hash_server.rb
    require 'drb/drb'
    require 'pp'
    front = Hash.new
    DRb.start_service('druby://localhost:54300', front)
    while true
    sleep 10
    pp front
    end

    View Slide

  43. ԋश2
    SSID: toruby pass: toruby08
    hash_server.rb
    irb
    irb

    View Slide

  44. ԋश2
    "String"
    2012
    Time.now
    $stdout
    SSID: toruby pass: toruby08

    View Slide

  45. CGIͷྫ
    SSID: toruby pass: toruby08
    CGI
    Web App
    CGI
    CGI
    CGI
    long lifetime
    short lifetime

    View Slide

  46. WEBrickʹΑΔΞϓϦ
    WEBrick HTTP
    CGI
    SSID: toruby pass: toruby08

    View Slide

  47. WEBrick::CGI
    require 'webrick/cgi'
    class MyCGI < WEBrick::CGI
    def do_GET(req, res)
    res["content-type"] = "text/plain"
    ret = "hoge\n"
    res.body = ret
    end
    end
    MyCGI.new.start()

    View Slide

  48. start
    WEBrick::CGI#start(env = ENV,
    stdin = $stdin,
    stdout = $stdout)

    View Slide

  49. startϝιου
    $stdin, $stdout
    SSID: toruby pass: toruby08

    View Slide

  50. m_seki's cgi
    require 'drb/drb'
    DRb.start_service('druby://localhost:0')
    ro = DRbObject.new_with_uri('druby://localhost:50830')
    ro.start(ENV.to_hash, $stdin, $stdout)

    View Slide

  51. startͷΑ͏͢
    SSID: toruby pass: toruby08
    CGI Web App
    $stdin.read
    $stdout.write
    start(env, $stdin, $stdout)

    View Slide

  52. Δͼ·40߸
    SSID: toruby pass: toruby08

    View Slide

  53. ԋश6
    Shi-ri-to-ri
    SSID: toruby pass: toruby08

    View Slide

  54. ·ͱΊ
    dRuby
    SSID: toruby pass: toruby08

    View Slide

  55. ;Γ͔͑Γ
    SSID: toruby pass: toruby08

    View Slide