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
hitsuji-haneta
April 20, 2020
Programming
0
340
GoとMicroserviceでDDDやってみました
hitsuji-haneta
April 20, 2020
Tweet
Share
More Decks by hitsuji-haneta
See All by hitsuji-haneta
SSIで覗き見るPWAの世界 / SSI on PWA
hitsuji_haneta
2
1.1k
やってみたよVueNative
hitsuji_haneta
2
400
これもフロントエンド!画面つきスピーカーで遊んでみた
hitsuji_haneta
0
82
VueではじめるWeb Components
hitsuji_haneta
1
500
webエンジニア向けブロックチェーンの技術的「へぇ」 / Blockchain tech tips for web developers
hitsuji_haneta
0
130
Other Decks in Programming
See All in Programming
実践!難読化ガイド
mitchan
0
200
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
0
120
はじめてみよう量子プログラミング
itokoichi01
0
210
o1モデルのプロンプトエンジニアリングって?
ktc_wada
0
260
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
1
410
Hono・Prisma・AWSでGeoなAPI開発
nokonoko1203
5
680
Ruby Parser progress report 2024
yui_knk
2
230
GraphQL あるいは React における自律的なデータ取得について
quramy
11
3k
Debugging: All you need to know (for simultaneous interpreting)
jmatsu
2
800
LangGraphでのHuman-in-the-Loopの実装
os1ma
3
1.1k
エラーレスポンス設計から考える、0→1開発におけるGraphQLへの向き合い方
bicstone
5
1.5k
What you can do with Ruby on WebAssembly
kateinoigakukun
0
170
Featured
See All Featured
A Philosophy of Restraint
colly
202
16k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
166
48k
Docker and Python
trallard
39
3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
38
9.2k
Statistics for Hackers
jakevdp
794
220k
Scaling GitHub
holman
458
140k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
27
7.4k
Gamification - CAS2011
davidbonilla
79
5k
Designing Experiences People Love
moore
138
23k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
GitHub's CSS Performance
jonrohan
1030
450k
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の置き方がコレでいのかという
不安はある。詳しい方の見解聞きたい!
ありがとうございました!