Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RailsEventStore使ってみた
Search
n.kakuta
August 27, 2020
Programming
980
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RailsEventStore使ってみた
サンプルアプリのgithubはこちらです
https://github.com/naoki-k/book-rental
n.kakuta
August 27, 2020
Other Decks in Programming
See All in Programming
Railsバージョンを4倍にした話
optim
0
440
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
630
sbt 2.0: takeoff
eed3si9n
0
160
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
160
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
golang-bob.pdf
iwatsukayura
0
130
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
160
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
33k
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.2k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
4 Signs Your Business is Dying
shpigford
187
23k
How GitHub (no longer) Works
holman
316
150k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
Transcript
RailsEventStore使ってみた Da Vinch Studio アプリ部所属 角田 直己 2020/08/27
だれ? エンジニア2年目 一年間のRails研修を受けた後,アプリ部に所属 現在はAndroid・iOSのアプリ開発を担当
アプリはオブジェクトの生存時間が長い 関心の分離のため,対話的なプログラミングが求められる (Observer, Rx, イベントドリブン etc...) Webとアプリの違い
RailsでCQRS×ESを試してみる Railsのアーキテクチャも試したい
事前知識 ・CQRS(コマンドクエリ責務分離) ・Event Sourcing
CQRS(コマンドクエリ責務分離) 書き換え操作(コマンド)と読み込み操作(クエリ)の分離 CRUD 出典: http://sensetecnic.com/cqrs-and-event-sourcing-for-the-iot/
Event Sourcing と State Sourcing State Sourcing (一般的なアプリケーション) → 状態を管理する
Event Sourcing → 過程を管理する example: git 通帳番号 残金 1110001 10,000 通帳番号 日付 取引内容 支払い金額 預かり金額 1110001 1/1 預金 20,000 1110001 1/4 クレジットカード 5,000 1110001 1/5 クレジットカード 5,000 → 残高10,000(状態)
Event Sourcing × CQRS 出典: http://sensetecnic.com/cqrs-and-event-sourcing-for-the-iot/
自由に触ってみてください! 今回はアーキテクチャの話なので,この裏側をお話しします サンプルアプリ作ってみた
None
None
None
主役 gem “rails_event_store” (https://railseventstore.org/) EventStoreとEventのPub/Sub機能の提供
アプリの要件 今回のコマンド ・本を登録する ・本を貸し出す ・本を返却する ・本を破棄する これらの操作履歴を閲覧できること!
今回の設計 出典: https://assist-software.net/blog/introduction-event-sourcing-ruby-rails
サンプルコードを見ていく
コントローラ 各アクションは,コマンドの生成と実行をする コマンドはコントローラに実行の成否を返す
コマンド
ドメインモデル
サブスクライバー リードモデルへの同期を担当する 今回はリレーショナル DBの更新のみ
機能したか ・メディア系アプリケーション等,リソースのライフサイクルを軸に考える場合は返って複雑さを 高める ・EventSoucingが必要な場合は,CQRSは簡単に機能する
導入すべきシーン ・イベントの過程が価値をもつ場合 (ポイントサービス等は,ユーザーが過程に関心を持つ) ・複数ユーザーが同一リソースで共同作業をする場合 (操作履歴がundoを可能にする) ・アプリケーションに部分的に導入することが現実的
感想 新しいアーキテクチャを試して,選択肢が広がった アプリ部でもAPIサーバーの開発に活かせそう
参考文献 ・From CRUD to CQRS https://medium.com/@antonnalivayko1/from-crud-to-cqrs-part1-cqrs-cbeac0350043 ・CQRS and Event Sourcing
for the IoT http://sensetecnic.com/cqrs-and-event-sourcing-for-the-iot/ ・RailsEventStore Docs https://railseventstore.org/ ・Introduction to event sourcing in Ruby on Rails https://assist-software.net/blog/introduction-event-sourcing-ruby-rails