Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
dRuby 入門者によるあなたの身近にあるdRuby 入門
Search
makicamel
August 24, 2024
Programming
4
810
dRuby 入門者によるあなたの身近にあるdRuby 入門
dRuby 入門者によるあなたの身近にあるdRuby 入門
2024.08.24. 大阪 Ruby 会議 04
makicamel
August 24, 2024
Tweet
Share
More Decks by makicamel
See All by makicamel
Rails アプリ地図考 Flush Cut
makicamel
1
120
ErdMap: Thinking about a map for Rails applications
makicamel
1
1.6k
BulletmarkRepairer: auto corrector for N+1 queries
makicamel
10
6.9k
How to say goodbye to technical debt
makicamel
8
2.9k
circuit_switch: small start to create gem
makicamel
3
2.6k
Ganbaranai wo ganbaru
makicamel
5
4.5k
Automate the boring staff with Ruby
makicamel
1
970
Lets enjoy creating gems
makicamel
3
1.9k
Play with Rubys AST
makicamel
0
1.9k
Other Decks in Programming
See All in Programming
Spring gRPC について / About Spring gRPC
mackey0225
0
220
CI改善もDatadogとともに
taumu
0
120
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
560
ソフトウェアエンジニアの成長
masuda220
PRO
10
1.1k
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
160
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
320
DROBEの生成AI活用事例 with AWS
ippey
0
130
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
370
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
10
3.6k
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
190
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
560
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
511
110k
KATA
mclloyd
29
14k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Done Done
chrislema
182
16k
Designing for Performance
lara
604
68k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
Gamification - CAS2011
davidbonilla
80
5.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Building Adaptive Systems
keathley
40
2.4k
Transcript
dRuby 入門者による あなたの身近にある dRuby 入門 @makicamel 大阪 Ruby 会議 04
2024.08.24
自己紹介 @makicamel / 川原万季 Ruby とビール とお酒が好き 好きな VR ゲームは
BeatSaber ㈱アンドパッド
dRuby
dRuby distributed ruby 分散 Ruby 分散オブジェクトシステムを実現するライブラリ 1999 年初出 関将俊さん作
dRuby 1999 年初出 https://gist.github.com/seki/5713863
dRuby ( *1) ( *1) dRubyによる分散・Webプログラミング / 関将俊 https://www.ohmsha.co.jp/book/9784274066092/
dRuby distributed ruby 分散 Ruby 分散オブジェクトシステムを実現するライブラリ 1999 年初出 関将俊さん作
分散オブジェクトシステム とは?
分散オブジェクトシステム プロセスやネットワークを超えてメッセージを送る 他のプロセスのオブジェクトのメソッドを呼び出せる
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム
分散オブジェクトシステム プロセスやネットワークを超えてメッセージを送る 他のプロセスのオブジェクトのメソッドを呼び出せる かんたんにサーバが作れる
分散オブジェクトシステム # terminal $ irb -r drb rabbit = DRbObject.new_with_uri
'druby://127.0.0.1:10101' # rabbitのdRubyサーバのuri rabbit.title # => "dRuby 入門者による\nあなたの身近にある\ndRuby 入門" %w[Rabbit最高 dRubyすごい 大阪たのしい ].each { rabbit.append_comment _1 } z # => [...] rabbit.toggle_fullscreen スタブを介してメッセージを送ることで Rabbit を操作できる
分散オブジェクトシステム デモ
分散オブジェクトシステム リアルワールド dRuby 活用例
分散オブジェクトシステム ( *2) ( *2) 岡山天体物理観測所広視野赤外カメラの製作 / 柳澤 顕史 https://www.astr.tohoku.ac.jp/~akiyama/astroinst2015/20151207_yanagisawa.pdf
Rinda in the real-world embedded systems. / 関将俊 https://rubykaigi.org/2020-takeout/presentations/m_seki.html
分散オブジェクトシステム ( *3) ( *3) dRuby in the real-world embedded
systems. / 関将俊 園川龍也 https://www.druby.org/seki-RK2021.pdf https://rubykaigi.org/2021-takeout/presentations/m_seki.html
分散オブジェクトシステム ( *4) ( *4) Scaling Twitter / Blaine Cook
https://www.slideshare.net/slideshow/scaling-twitter/41197
分散オブジェクトシステム すごすぎる
dRuby 入門者によるあなたの身近にある dRuby 入門
わたしたちの身近にある dRuby RSpec ActiveSupport Rabbit るりま
わたしたちの身近にある dRuby RSpec ActiveSupport Rabbit るりま
RSpec drb オプション $ rspec --help -X, --[no-]drb Run examples
via DRb. --drb-port PORT Port to connect to the DRb server.
RSpec アプリケーションを dRuby プロセスに読み込んでテストサーバにする rspec 実行時にテストサーバでテスト実行する
RSpec
RSpec
RSpec
RSpec
RSpec
RSpec
RSpec テストサーバ プリローダ アプリケーション起動時間を省略 e.g. spork( *5) A DRb server
for testing frameworks ※ 最終コミットは 2014 年 2024 年現在はあまり使われていないかも ( *5) spork https://github.com/sporkrb/spork
わたしたちの身近にある dRuby RSpec ActiveSupport Rabbit るりま
ActiveSupport ActiveSupport::TestCase#parallelize( *6) テストの並列化 使用マシンのコア数分プロセスをフォーク ( *6) ActiveSupport::TestCase https://api.rubyonrails.org/classes/ActiveSupport/TestCase.html#method-c-parallelize
ActiveSupport rails new で test_helper.rb を生成 デフォルトで parallelize が記述されている 何も意識しなくてもテストが並列実行される(
*7) # test/test_helper.rb module ActiveSupport class TestCase parallelize(workers: :number_of_processors) fixtures :all end end ( *7) ※ Minitest のみ対応
ActiveSupport ActiveSupport::TestCase#parallelize の並列実行のしくみ
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport
ActiveSupport 並列実行のしくみ アサーションの管理を dRuby に任せる( *8) フォークしたプロセスが各個アサーションを引き出しテスト実行 ( *8) テスト結果の管理は親プロセスの仕事
わたしたちの身近にある dRuby RSpec ActiveSupport Rabbit るりま
Rabbit ( *9) ( *9) Contribute to Ruby - Yukihiro
"Matz" Matsumoto https://speakerdeck.com/matz/contribute-to-ruby-rubykaigi-2022?slide=25 https://rubykaigi.org/2022/presentations/yukihiro_matz.html
Rabbit Rubyist 御用達プレゼンテーションツール( *10) うさぎとかめでお馴染み 須藤功平さん作 ( *10) Rabbit https://rabbit-shocker.org/ja/
https://github.com/rabbit-shocker/rabbit
Rabbit デフォルトで dRuby サーバを立ち上げる class Rabbit::Command::Rabbit def do_display # ...
front = make_front(canvas) setup_druby(front) if @options.use_druby # ... end def setup_druby(front) require "drb/drb" begin DRb.start_service(@options.druby_uri, front) # ... end end end
Rabbit # terminal $ irb -r drb rabbit = DRbObject.new_with_uri
'druby://127.0.0.1:10101' # rabbitのdRubyサーバのuri rabbit.title # => "dRuby 入門者による\nあなたの身近にある\ndRuby 入門" %w[Rabbit最高 dRubyすごい 大阪たのしい ].each { rabbit.append_comment _1 } rabbit.available_interfaces # => [...] rabbit.toggle_fullscreen スタブを介してメッセージを送ることで Rabbit を操作できる
Rabbit API 提供
Rabbit API RabbiRack( *11) Web ブラウザから Rabbit を操作するツール get "/pages/next"
do @rabbit.move_to_next_if_can haml :index end ( *11) RabbiRack https://rabbit-shocker.org/ja/rabbirack https://github.com/rabbit-shocker/rabbirack ※ macOS ではhttps://github.com/rabbit-shocker/rabbit/commit/ 2b2ce805d98fd972d0a288ac7df944e53d48bbbfの適用が必要
Rabbit API Rabbiter( *12) Twitter からツイートを収集し、コメントとして Rabbit に流しこむツール rabbit =
DRbObject.new_with_uri(options.rabbit_uri) client = Rabbiter::Client.new(logger) client.start(*options.filters) do |status| # ... comment = "@#{status.user.screen_name}: #{clean_text(status, options)}" rabbit.append_comment(comment) end ( *12) Rabbiter https://rabbit-shocker.org/ja/rabbiter https://github.com/rabbit-shocker/rabbiter ※ Twitter (現 X) が壊れているので 2024 年 8 月現在は動かせない
わたしたちの身近にある dRuby RSpec ActiveSupport Rabbit るりま
るりま ( *13) ( *13) オブジェクト指向スクリプト言語 Ruby リファレンスマニュアル https://docs.ruby-lang.org/ja/latest/doc/index.html
るりま doctree ドキュメント https://github.com/rurema/doctree BitClust ドキュメントシステム リファレンスデータベースの更新、表示、検索、html 生成など https://github.com/rurema/bitclust
BitClust BitClust データベース Ruby のクラスをふつうに使う rd をコンパイルしたデータを持つ テキストファイルで永続化 人間可読のテキスト MySQL
でも PostgreSQL でも Redis でもないデータベース SQL も O/R マッパーも要らない
BitClust refe( *14) るりまのエントリを引くためのコマンドライン用ツール デーモン化 BitClust データベースをフロントオブジェクトとして dRuby サーバを起動 class
BitClust::Server def listen(url, foreground = false) # ... WEBrick::Daemon.start unless foreground DRb.start_service url, @db DRb.thread.join end end ( *14) ReFe https://i.loveruby.net/ja/prog/refe.html
BitClust データベースとしての Ruby プロセス PORO でデータ操作 ファイルに永続化 ふつうの Ruby プログラミングの延長線上で
データベースサーバを作れる
わたしたちの身近にある dRuby プリローダ 並列 API データベース
たとえば明日から dRuby を使うとしたら
たとえば明日から dRuby を使うとしたら PoC Web サーバを dRuby で立ててみる DB サーバを
dRuby で立ててみる 手に馴染む道具で検討して固まったら本実装に入るのも手かも
たとえば明日から dRuby を使うとしたら PoC Web サーバを dRuby で立ててみる DB サーバを
dRuby で立ててみる 手に馴染む道具で検討して固まったら本実装に入るのも手かも
dRuby ( *15) ( *15) dRubyによる分散・Webプログラミング / 関将俊 https://www.ohmsha.co.jp/book/9784274066092/
Special Thanks @youchan
ご清聴 ありがとう ございました