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
110
ErdMap: Thinking about a map for Rails applications
makicamel
1
1.4k
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
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
7
3.3k
定理証明プラットフォーム lapisla.net
abap34
1
1.7k
SpringBoot3.4の構造化ログ #kanjava
irof
2
920
Azure AI Foundryのご紹介
qt_luigi
1
280
さいきょうのレイヤードアーキテクチャについて考えてみた
yahiru
3
710
パスキーのすべて ── 導入・UX設計・実装の紹介 / 20250213 パスキー開発者の集い
kuralab
3
570
Linux && Docker 研修/Linux && Docker training
forrep
23
4.4k
Introduction to kotlinx.rpc
arawn
0
250
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
120
Spring gRPC について / About Spring gRPC
mackey0225
0
220
[Fin-JAWS 第38回 ~re:Invent 2024 金融re:Cap~]FaultInjectionServiceアップデート@pre:Invent2024
shintaro_fukatsu
0
400
個人アプリを2年ぶりにアプデしたから褒めて / I just updated my personal app, praise me!
lovee
0
330
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
Typedesign – Prime Four
hannesfritz
40
2.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
Agile that works and the tools we love
rasmusluckow
328
21k
KATA
mclloyd
29
14k
We Have a Design System, Now What?
morganepeng
51
7.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
400
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
Writing Fast Ruby
sferik
628
61k
Optimising Largest Contentful Paint
csswizardry
34
3.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
ご清聴 ありがとう ございました