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

Arrrr Me Hearty! Sailing the Seas of DRb in a Shoe

Arrrr Me Hearty! Sailing the Seas of DRb in a Shoe

You insouciant scalawags will share the experience of a lifetime as you play a game built atop DRb and Shoes based generally upon the phenomenon known as Spaceteam! Except with Pirates!!

Join us as we skirt the treacherous shoals of DRb, learning techniques that will allow you to navigate it like you were born on the high seas!

Dig for the buried treasure of Rinda to discover the mysterious secrets of the RingProvider and TupleSpace!

Storm the fortress of Shoes and learn about it’s secret trapdoors and avoid the dungeons!

Team up with your fellow attendees to plunder the high seas and avoid the Curse of the Live Demo! Yarrrr….☠

5f557a41fc286ddcc1ed6b869c6d04c3?s=128

Davy Stevenson

November 09, 2013
Tweet

Transcript

  1. ARRRR ME HEARTY! Sailing the Seas of DRb in a

    Shoe Davy Stevenson Eric Hodel Rein Henrichs @davystevenson @drbrain @reinh RubyConf 2013
  2. Spaceteam? Who has played? Pleiades by Jim Keller

  3. Spaceteam trailer

  4. Why DRb? Easy Interprocess Communication Send and Get Data Peer

    to Peer Red Beach by alphadesigner
  5. Why Rinda? Flexible Automatic discovery No explicit destination? Throw it

    in the tuplespace Farmhouse and Roosting Birds at Dusk by Trey Ratcliff
  6. Why Shoes? Needs some love and attention Perfect showcase for

    distributed code Support non-web Ruby development! Freestyle Converse by Daniele Margaroli
  7. Why Pirates? Yarrr! Mutiny by Shane Gorski

  8. Preparation Install jruby (1.7.4-6 all should work) Install shoes4 $

    git clone https://github.com/shoes/shoes4 $ git checkout 7d0a1ee $ gem build shoes.gemspec $ gem install shoes-4.0.0.pre1 $ alias shoes4='/path/to/shoes4/bin/shoes' Install pirate_game $ gem install pirate_game
  9. Preparation Also in pirate_game README! https://github.com/davy/pirate_game

  10. DRb RMI for Ruby Written by Masatoshi SEKI require ‘drb’

    Remote objects act like local objects It’s “Ruby Throated” Tuesday! by MrClean1982
  11. Remote Array Server array = [] # share the array

    DRb::DRbServer.new nil, array # print the URI (we let DRb pick) puts DRb.uri # wait for ^C DRb.thread.join
  12. Remote Array Peer # create remote array reference remote_array =

    DRbObject.new_with_uri ARGV.shift # append to remote array remote_array << "a" remote_array.push "b", "c"
  13. Remote Array Peer # create remote array reference remote_array =

    DRbObject.new_with_uri ARGV.shift puts remote_array.join ", " # => a, b, c
  14. Rinda Linda for Ruby Model for distributed programming require ‘rinda/

    tuple_space’ Stores tuples with arbitrary data write, take, read Quasicabinet by Aranda\Lasch
  15. Tuple Space # blocking operation with template @ts.take [:button, "Keel",

    (now...now + 30), nil] # writing a matching tuple unblocks @ts.write [:button, "Keel", Time.now.to_i, DRb.uri]
  16. Service Discovery Rinda::RingFinger, Rinda::RingServer TupleSpace for registry Broadcast, unicast, multicast

    (Ruby 2.1) Rinda::RingProvider Wrapper for advertisement
  17. Shoes Created by _why Simple cross- platform GUI toolkit for

    Ruby Shoes4 is an all- Ruby rewrite Still under active development Blue Power! by Éole Wind
  18. Shoes Manual Layout Input elements Drawing Animate / Move /

    Events http://shoesrb.com/manual/Hello.html
  19. Display Issues Not all movement methods have been implemented on

    all types of objects Can move, but not displace Width/height =( Show/hide/toggle missing =(
  20. Animations Animations run in parallel Need to manually manage them

    start, stop, remove PROTIP™: Separate drawing from animation
  21. Give Back Complicated Shoes app highlights regressions Use game to

    detect & fix issues
  22. Open Source Three Gems! github.com/davy/ pirate_command github.com/davy/ shuttlecraft github.com/davy/ pirate_game

    Coast Guard by Mike Baird
  23. pirate_command PirateCommand.generate => "Swab the Poop Deck" PirateCommand.action => "Batten"

    PirateCommand.thing => "Main Sail" PirateCommand.exclaim => "Ahoy" PirateCommand.exclaim! => "Shiver me Timbers!"
  24. pirate_command github.com/davy/pirate_command

  25. shuttlecraft Create distributed systems with Rinda Simplifies registration Keeps track

    of registered clients Easily send messages
  26. shuttlecraft github.com/davy/shuttlecraft

  27. pirate_game Play the game!

  28. pirate_game github.com/davy/pirate_game

  29. Game Architecture? Does exactly what the GM instructs Game Master

    Game Handles all logic Issue cmds to game, game sends response
  30. That’s no fun! Distributed services FTW Lightning by Fadzly Mubin

  31. Game Architecture Registration Layout generation Issuing actions & gathering responses

  32. Yay Diagrams! Game Game Master Rinda Tuplespace

  33. Registration

  34. Registration write [:name, ‘Foo’, uri’]

  35. Registration write write [:name, ‘Foo’, uri’] [:name, ‘Bar’, uri’]

  36. Registration write write write [:name, ‘Foo’, uri’] [:name, ‘Bar’, uri’]

    [:name, ‘Baz’, uri’]
  37. Registration write write write [:name, ‘Foo’, uri’] [:name, ‘Bar’, uri’]

    [:name, ‘Baz’, uri’] read_all
  38. Layout Generation GM sends each game their bridge and list

    of all bridge items my_items all_items my_items all_items direct DRb
  39. Action & Response

  40. Action & Response watch for actions take (blocks)

  41. Action & Response ‘Haul the Keel’ watch for actions take

    (blocks)
  42. Action & Response watch for button click take (blocks) watch

    for actions take (blocks)
  43. Action & Response watch for button click on button click

    [:button, ‘Keel’, timestamp, from] write take (blocks) watch for actions take (blocks)
  44. Action & Response watch for button click [:button, ‘Keel’, timestamp,

    from] take (blocks) watch for actions take (blocks)
  45. Action & Response watch for button click watch for actions

    take (blocks) write [:action, ‘Keel’, timestamp, from]
  46. Action & Response watch for button click watch for actions

    take (blocks) [:action, ‘Keel’, timestamp, from]
  47. Action & Response watch for button click watch for actions

  48. Architecture Diagram mothership game_master client client_app master_app shuttlecraft

  49. Enough Jibber Jabber Let’s get to the important parts GAME

    TIME Shut up you fool! by Andre Vandal
  50. Preparation (again) Install jruby (1.7.4-6 all should work) Install shoes4

    $ git clone https://github.com/shoes/shoes4 $ git checkout 7d0a1ee $ gem build shoes.gemspec $ gem install shoes-4.0.0.pre1 $ alias shoes4='/path/to/shoes4/bin/shoes'
  51. Install Install pirate_game $ gem install pirate_game

  52. Networking Theoretically this should work on conference wifi *But* for

    best results use a personal access point
  53. RingServer Someone needs to run a ringserver $ ring_server But

    not too many Try not to screw it up We are working on it
  54. Game Master Only one needed per game Pick a good

    name If GM crashes, game is stranded =(
  55. Pirate Game! 1* to 4 players *Totally a ‘feature’ not

    a bug
  56. Find Your Game GMs are found by Rinda service discovery

  57. Find Your Game ISSUE: If join fails you will not

    receive an error message and will enter empty disconnected pub =(
  58. Pirate Pub Chat with your friends in the Pirate Pub*

    *Yes, you have to click the ‘Send’ button. No keybindings?!? =(
  59. Pirate Pub ISSUE: At the moment the GM needs to

    trigger each stage. Future development should switch over to Spaceteam-like mechanism where each player indicates that they are ready to proceed
  60. Sail the High Seas Keep the ship afloat! Work together

    to man the ship Beware of bad weather!
  61. Security DRb Priorities: Transparency Easy of use … Security Pirates

    by Adrien Sifre
  62. Full Access Clients can do anything Get remote nil instance_eval

    github.com/drbrain/drb-worm
  63. Message-level Security DRb::DRbServer::INSECURE_METHOD Opt-out $SAFE Relies on tainting

  64. DRb over UNIX Socket Restricted to one host Filesystem permissions

    control access No network access
  65. Access Control List Deny or allow by IP address and

    range Difficult to manage No privacy
  66. DRb over SSL X509 certificate Full privacy Difficult to manage

  67. chroot Filesystem sandbox Can’t write outside Can still consume CPU,

    create processes
  68. Best Practices Verify your peers Limit accessibility Use a private

    network
  69. drbdump tcpdump for DRb Message sends Message latency Message allocations

    Colorful toy trucks parked together in rows by Horia Varlan
  70. Problems Out-of-order TCP mDNS Ruby 2.1 No filtering IPv6 (bug)

  71. Running Basic drbdump Summary of 10,000 messages drbdump -q -n

    -c 10000 Listen only on loopback drbdump -i lo0
  72. Timestamp 17:34:49.546074 "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913", 70180390657240). respond_to?(:update, false)

  73. Source 17:34:49.546074 "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913", 70180390657240). respond_to?(:update, false)

  74. Message-send 17:34:49.546074 "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913", 70180390657240). respond_to?(:update, false)

  75. Receiver 17:34:49.546074 "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913", 70180390657240). respond_to?(:update, false)

  76. Message Name 17:34:49.546074 "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913", 70180390657240). respond_to?(:update, false)

  77. Arguments 17:34:49.546074 "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913", 70180390657240). respond_to?(:update, false)

  78. Timestamp 17:34:49.546531 "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" success: true

  79. Destination 17:34:49.546531 "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" success: true

  80. Message-result 17:34:49.546531 "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" success: true

  81. Source 17:34:49.546531 "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" success: true

  82. Status 17:34:49.546531 "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" success: true

  83. Result Object 17:34:49.546531 "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" success: true

  84. Exception 17:34:49.563440 "druby://192.0.2.1:60929" ⤂ "druby://192.0.2.1:60920" exception: #<LocalJumpError: break from proc-closure>

  85. Exception Object 17:34:49.563440 "druby://192.0.2.1:60929" ⤂ "druby://192.0.2.1:60920" exception: #<LocalJumpError: break from

    proc-closure>
  86. Easy to Match "druby://192.0.2.1:60919" 㱺 ("druby://192.0.2.1:60913" "druby://192.0.2.1:60919" ⾨ "druby://192.0.2.1:60913" "druby://192.0.2.1:60929"

    㱺 ("druby://192.0.2.1:60920" "druby://192.0.2.1:60929" ⤂ "druby://192.0.2.1:60920"
  87. Statistics Output Basic statistics Packets, messages, results Message statistics Allocations,

    latency Peer statistics Latency
  88. Basic Statistics 1508 total packets captured 0 Rinda packets captured

    56 DRb packets captured 30 messages sent 26 results received 2 exceptions raised
  89. Message Statistics Messages sent min, avg, max, stddev: call (1

    args) 10 sent; 3.0, 6.2, 19.0, 6.7 allocations; 0.285, 1.479, 7.258, 2.171 ms
  90. drbdump Diagnostics Find message spam Find hanging calls Verify expected

    behavior
  91. Future Want to pitch in? Wilma was here by zanzibar

  92. Group Activities Raid a ship? Survive a hurricane? Steer ship

    with the wheel
  93. Character Generation Build a pirate? Select: Beard Parrot Eyepatch Hair

  94. Infrastructure Improvement Automatic Integrated Game Master Better Error Handling Easy

    Game Restart
  95. Play! Contribute! Thanks! =D The Flying Dutchman by Scott Smith