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
350
dRuby 入門者によるあなたの身近にあるdRuby 入門
dRuby 入門者によるあなたの身近にあるdRuby 入門
2024.08.24. 大阪 Ruby 会議 04
makicamel
August 24, 2024
Tweet
Share
More Decks by makicamel
See All by makicamel
BulletmarkRepairer: auto corrector for N+1 queries
makicamel
10
6.1k
How to say goodbye to technical debt
makicamel
8
2.8k
circuit_switch: small start to create gem
makicamel
3
2.4k
Ganbaranai wo ganbaru
makicamel
5
4.3k
Automate the boring staff with Ruby
makicamel
1
920
Lets enjoy creating gems
makicamel
3
1.8k
Play with Rubys AST
makicamel
0
1.8k
Lets enjoy code reading
makicamel
5
860
OSS is great but not special
makicamel
7
7.6k
Other Decks in Programming
See All in Programming
Lessons by WebAssembly app in production on CDN Edge Computing Service
tetsuharuohzeki
0
170
2024 컴포즈 정원사
jisungbin
0
150
Prompt Cachingは本当に効果的なのか検証してみた.pdf
ttnyt8701
0
530
ブラウザ互換の重要性 - あらゆるユーザーに価値を届けるために必要なこと
yamanoku
0
110
rails_girls_is_my_gate_to_join_the_ruby_commuinty
maimux2x
0
190
エンジニア1年目で複雑なコードの改善に取り組んだ話
mtnmr
3
1.9k
いまから追い上げる、Jetpack Compose トレーニング
nyafunta9858
0
250
KSPの導入・移行を前向きに検討しよう!
shxun6934
PRO
0
130
Rechartsで楽にゴリゴリにカスタマイズする!
10tera
1
160
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
GraphQL あるいは React における自律的なデータ取得について
quramy
11
2.8k
Some more adventure of Happy Eyeballs
coe401_
2
180
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1365
200k
The Language of Interfaces
destraynor
153
23k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
227
52k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
109
6.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
230
17k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
Teambox: Starting and Learning
jrom
131
8.7k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
Designing with Data
zakiwarfel
98
5k
[RailsConf 2023] Rails as a piece of cake
palkan
48
4.6k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.1k
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
ご清聴 ありがとう ございました