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
GoとMicroserviceでDDDやってみました
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
hitsuji-haneta
April 20, 2020
Programming
410
0
Share
GoとMicroserviceでDDDやってみました
hitsuji-haneta
April 20, 2020
More Decks by hitsuji-haneta
See All by hitsuji-haneta
SSIで覗き見るPWAの世界 / SSI on PWA
hitsuji_haneta
2
1.2k
やってみたよVueNative
hitsuji_haneta
2
500
これもフロントエンド!画面つきスピーカーで遊んでみた
hitsuji_haneta
0
120
VueではじめるWeb Components
hitsuji_haneta
1
570
webエンジニア向けブロックチェーンの技術的「へぇ」 / Blockchain tech tips for web developers
hitsuji_haneta
0
170
Other Decks in Programming
See All in Programming
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
770
My daily life on Ruby
a_matsuda
3
200
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
500
AIを導入する前にやるべきこと
negima
2
340
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
200
JCON - Create Agentic AI Apps, The Easy Way!
kdubois
1
100
Agentic Elixir
whatyouhide
0
450
Programming with a DJ Controller — not vibe coding
m_seki
3
810
AI Agent と正しく分析するための環境作り
yoshyum
0
100
[RubyKaigi 2026] Require Hooks
palkan
1
310
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
160
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
300
How to Talk to Developers About Accessibility
jct
2
190
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
370
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
910
My Coaching Mixtape
mlcsv
0
120
Are puppies a ranking factor?
jonoalderson
1
3.4k
Typedesign – Prime Four
hannesfritz
42
3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Evolving SEO for Evolving Search Engines
ryanjones
0
190
Side Projects
sachag
455
43k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
110
Transcript
やってみました Go MicroService DDD で と 2020/04/20 DDD Talk Meetup
Online
高橋翔太 hitsuji-haneta LasTrust株式会社 h1tsuj1_haneta https://lastrust.io ・ブロックチェーン証明書の発行 ・証明書の管理アプリの開発 (ヒツジハネタ) ࣗݾհ
教育機関・金融機関・自治体など ࣗݾհ 個人の見えざる価値を可視化する
Go Sendai 2020/7/4 Conference
Go言語+MicroServicesで構築していた 弊社サービスにDDDを導入してみました ・DDDを導入しようとしたきっかけ ・マイクロサービスから見たDDD ・Go言語から見たDDD(アーキテクチャ) ・所感
DDDは初心者です よくない設計もあるかも知れないので お気づきの方は懇親会で教えて下さい
Service A Service C Service B %%%ಋೖͷ͖͔͚ͬɹ サービスの数が増えてきた ◦◦を元にした設計 ✕✕な感じの設計
Service D Service E △△風な設計 つらい…
%%%ಋೖͷ͖͔͚ͬɹ → ちゃんとドキュメントを残せばいい? → 最小限にしたい → チームとして共通の設計認識を持って それを規律としていきたい 個々のサービスの設計思想がバラバラ&追えない
DDDはどうだろう??
Go言語 マイクロサービス
Go言語 マイクロサービス
ϚΠΫϩαʔϏε͔Βݟͨ%%%ɹ Service A Service C Service B DDDを元にした設計 DDDを元にした設計 Service
D Service E DDDを元にした設計 見やすい! レビューしやすい!
ϚΠΫϩαʔϏε͔Βݟͨ%%%ɹ Service A Service C Service B Service D Service
E 予期していなかった効果 → 境界づけられたコンテキスト 実はマージした方が いいのでは?
ϚΠΫϩαʔϏε͔Βݟͨ%%%ɹ それまで 「責務の分離」に応じてサービスを区切っていた DDD導入後 BUT 意外にそこの解釈は人による… 基準ができた!
Go言語 マイクロサービス
(Pݴޠ͔Βݟͨ%%%ɹ Go言語の特徴 ・実行速度が速い ・並列処理が簡単 ・シンプルな言語構造 Class構文がない Interfaceはある でも継承はない
(Pݴޠ͔Βݟͨ%%%ɹ どういうこと? type dog struct { id uint name string
} func(d *dog) Cry() string { return “Bow!" } type Animal interface { Cry() string } func test(a Animal) { fmt.Printf(a.Cry()) } メソッドは構造体(struct)に紐付ける Interfaceに定義されたメソッドと 同じものが定義された構造体はそ のInterfaceとして使用できる
(Pݴޠ͔Βݟͨ%%%ɹ Goで有名な考え方 accept interfaces, return structs. 関数はインターフェースを受け入れて 構造体を返すように作りましょう
type someStc struct { id uint name string } type
SomeIf interface { CreateStc() someStc } func Test(i SomeIf) *someStc { return i.CreateStc } (Pݴޠ͔Βݟͨ%%%ɹ Func Interface ダックタイピングに近い Interfaceは使う人が定義する (同じpackage内とか) Struct
(Pݴޠ͔Βݟͨ%%%ɹ IssueCertificate() Issuerドメイン 証明書を発行して ストレージに格納 S3 GCS ファイル システム Storage
Adapter S3 Adapter 外から渡す インターフェースは どこで定義する?
(Pݴޠ͔Βݟͨ%%%ɹ Issuerドメイン IssueCertificate() Storage Adapter S3 Adapter Interfaceは使う人が定義 シンプルになった!
まとめ ・マイクロサービスの設計に明確な基準ができた ・「accept interfaces, return structs.」の 考え方を使えば置き場所の悩みがスッキリする 懸念 ・Interfaceの置き方がコレでいのかという
不安はある。詳しい方の見解聞きたい!
ありがとうございました!