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
そして物語は何度目かのアプリ内通知再実装を迎える / Reimplement in app n...
Search
moznion
August 21, 2016
Technology
5
7k
そして物語は何度目かのアプリ内通知再実装を迎える / Reimplement in app notification
京都なんか #2 の資料です
moznion
August 21, 2016
Tweet
Share
More Decks by moznion
See All by moznion
Develop to Survive - YAPC::Hakodate 2024 Keynote
moznion
9
14k
これはPerl? それともRuby? クイズ〜〜〜〜〜!!!- Perl or Ruby Quiz
moznion
3
2.4k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
930
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
65
AWS上に構築する メンテ容易なElasticsearch System / Maintainable Elasticsearch system on AWS
moznion
2
3.9k
PROXY Protocol aware Proxy Server on Node.js
moznion
2
2.5k
Perl meets AWS Lambda
moznion
0
4.7k
ソフトウェア開発における 「設計」と「パフォーマンス」の相互作用 / Interaction Between Design and Performance on Software Development
moznion
12
6.9k
Javaカードの世界 / The world of Java Card
moznion
9
13k
Other Decks in Technology
See All in Technology
MLOps の現場から
asei
5
600
tokyo_re_Growth2024_yoshi
yoshi22
0
200
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
3
1.3k
Tailwind CSSとAtomic Designで実現する効率的な Web 開発の事例
toranoana
1
310
Jetpack Composeで始めるServer Cache State
ogaclejapan
2
150
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
140
イノベーショントークから見るクラウド運用の未来を振り返ってみた
nyankotaro
0
480
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
180
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
140
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
240
コンテナセキュリティのためのLandlock入門
nullpo_head
2
300
Classmethod_regrowth_2024_tokyo_security_identity_governance_summary
hiashisan
0
970
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Unsuck your backbone
ammeep
669
57k
Become a Pro
speakerdeck
PRO
26
5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Scaling GitHub
holman
458
140k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Thoughts on Productivity
jonyablonski
67
4.3k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
270
Side Projects
sachag
452
42k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Transcript
ͦͯ͠ޠԿ͔ͷ ΞϓϦ௨࠶࣮Λܴ͑Δ @moznion
@moznion
ΞϓϦ௨
ྫ͑͜͏͍͏ͷ
None
ྫ͑͜͏͍͏ͷ
ΞϓϦ௨Ͳ͏ͯ͠·͔͢ - ࠷ۙ͜͏ͬͯ·͢Αͱ͍͏ - ࣮ࡍࠓͪΐͬͱΜͰ͍Δ ͱ͍͏εςʔλε
ΞϓϦ௨ͷ๊͑Δ
ΞϓϦ௨ͷ๊͑Δ - ΞϓϦ௨͕ສೳͩͱ ࢥΘΕ͍ͯΔ
ΞϓϦ௨ͷ๊͑Δ - ΞϓϦ௨͕ສೳͩͱ ࢥΘΕ͍ͯΔ ສೳͰͳ͍
ΞϓϦ௨ͷ๊͑Δ - ༗ޮͳσʔλϞσϧΛߟ͑Δͷ͕͍͠ - τϨʔυΦϑ͕ੜ·Ε͕ͪ - writeʹڧ͘͢Δͷ͔ - readʹڧ͘͢Δͷ͔ -
ͲͪΒ͔ (ͦΜͳͷ͋Δͷ͔) - ࣮ࡍͦͷลྑ͍Ϟσϧͬͯ͋ΔΜͰ͔͢ʁ
σʔλϞσϧͷτϨʔυΦϑ - ྫ) ૉͳmailboxͷΑ͏ͳΈ - Read͕؆୯ - Subscriberʹඥͮ͘boxΛಡΊྑ͍ - Write͕ଟ͘ͳΔ
- Subscriberʹൺྫ͢Δ
σʔλϞσϧͷτϨʔυΦϑ - ྫ) ௨͕1rowͰsubscriberใ͕ͿΒԼ͕Δ - Write͕؆୯ (গͳ͍) - 1௨1writeͰࡁΉ -
Read͕͘͠ͳΔ - ಡΜͰ͘Δͱ͖ʹෳࡶͳΫΤϦ͕ཁΓ͕ͪ - JOINࠈ (͘͠ఱࠃ)
༷͔Βߟ͑Δ
ΞϓϦ௨ͷಛੑ (mailboxత࣮ͷ߹)
ΞϓϦ௨ͷಛੑ (Ծఆ) - ଈ࣌ੑ͕ཉ͍͠ - ͕͋ΔఔͷԆڐ༰Ͱ͖Δ - (ڐ༰ग़དྷͳ͍߹͋Δ) - աڈʹḪͬͯϞϦϞϦݟΔɼΈ͍ͨͳػೳ
ఏڙ͠ͳͯ͘ྑ͍ - ͋ΔఔͰใͷอ͕࣋ଧͪΓՄೳ
͋·Γؔͳ͍Ͱ͕͢ twitter App λΠϜϥΠϯͷ աڈϖʔδϯάΛ ఘΊ·ͨ͠Ͷ ͜ΕҎ্ಡΊͳ͍
ԿΛҎͬͯͯ͠อ࣋ΛଧͪΔ͔ - ௨݅ - ࣌ؒܦա
- ௨݅ - ࣌ؒܦա ͲͪΒͰྑ͍ͱࢥ͏ ԿΛҎͬͯͯ͠อ࣋ΛଧͪΔ͔
- ௨݅Λج४ͱ͢Δ - ͋ΔϢʔβʹର͢Δσʔλ༰ྔ͕ ߴʑN݅ʹݻఆͰ͖Δ - σʔλྔ͕༧ଌ͍͢͠ - ௨͕࣌ؒʹେྔʹૹΒΕΔͱ Ϣʔβଆ͕ݟΕͳ͘ͳΔͱ͍͏͋Δ
ԿΛҎͬͯͯ͠อ࣋ΛଧͪΔ͔
- ࣌ؒܦաΛج४ͱ͢Δ - ௨͕࣌ؒʹେྔʹૹΒΕͯҰఆ͕࣌ؒ ܦա͢Δ·Ͱഁغ͞Εͳ͍ͷͰಡΊΔ - ϢʔβʹΑΓσʔλͷ࠷େྔ͕ҟͳΔͷͰ ༧ଌ͠ʹ͍͘ - ͢͞·͍͡Λfollow͢ΔϢʔβͱ͔
- ͍ΔΜͰ͢ΑͶ ԿΛҎͬͯͯ͠อ࣋ΛଧͪΔ͔
- େྔʹ௨͕ཷ·͍ͬͯΔ࣌ɼ Ռͨͯ͠ϢʔβಡΉͷ͔Ͳ͏͔ - ͍͍ͤͥNݸ͋Εྑ͍ΑͶɼ Έ͍ͨͳ߹͕ଟ͍ؾ͕͢Δ - ͱ͍͑͜ͷΜαʔϏεͷಛੑʹΑΔ - τϨʔυΦϑ
ԿΛҎͬͯͯ͠อ࣋ΛଧͪΔ͔
༷ϨϕϧͰ ͋Δఔݱ࣮తʹ͢Δ - ༷Ͱ͋ΔఔແཧͳػೳΛ͘ - ແݶʹϖʔδωʔγϣϯ͍ͨ͠ͱ͔ - ฒͼॱΛϢʔβ͝ͱʹࣗ༝ʹઃఆ͍ͨ͠ͱ͔ - ະདྷӬ߷ফ͑ͳ͍ͱ͔
- (͔͠͠αʔϏεͷಛੑʹΑΔ) - ΞϓϦ௨ۜͷؙͰͳ͍
ͦΕͦ͏ͱ
ϢʔβA͕ϢʔβBΛfollowͨ࣌͠ʹɼ ϢʔβBͷաڈͷ௨ΛͲ͏͖͔͢
Ͳ͏͖͔͢ - ݟํͷ - ͦΕʮ௨ʯͳͷ͔ʁ - ͦΕʮλΠϜϥΠϯʯͳͷ͔ʁ
Ͳ͏͖͔͢ - ʮ௨ʯͷ߹ - ೖΕΔඞཁͳ͠ - ௨ͦͷλΠϛϯά͋Γ͖Ͱ Ձ͕͋Δใ
Ͳ͏͖͔͢ - ʮλΠϜϥΠϯʯͷ߹ - ೖΕΔඞཁ͋Δ - ͔͠͠ࠓճʮ௨ʯͷ - ͜Εݴ͍࢝ΊͨΒͳΜ͔צҧ͍Λ ͍ͯ͠ΔՄೳੑ͋Δ
ݴͬͯΔ͜ͱΘ͔Δ - ΞϓϦʹʮλϒʯͱͯ͠௨͕͋Δͱ λΠϜϥΠϯͩͱࢥͬͪΌ͏ - Θ͔ΔΘ͔Δ - ͔͠͠ҧ͏ (ҧ͏ͱ͍͏߹͕ଟ͍) -
͜͜ΒΜࠞಉ͢Δͱෆ͕͖ͬͯ·͢
͍
༷ײ͕͋Δఔڞ༗ Ͱ͖ͨͱ͜ΖͰΛ ݟͯΈ·͠ΐ͏
ΞϓϦ௨ͷ๊͑Δ - ༗ޮͳσʔλϞσϧΛߟ͑Δͷ͕͍͠ - τϨʔυΦϑ͕ੜ·Ε͕ͪ - writeʹڧ͘͢Δͷ͔ - readʹڧ͘͢Δͷ͔ -
ͲͪΒ͔ (ͦΜͳͷ͋Δͷ͔) - ࣮ࡍͦͷลྑ͍Ϟσϧͬͯ͋ΔΜͰ͔͢ʁ
͔͜͜Βઌզʑ͕ Ͳ͏͔ͬͨͱ͍͏ʹͳΓ·͢
എܠ
എܠ - Java 8ͰΞϓϦέʔγϣϯΛॻ͍͍ͯΔ - ͍ΘΏΔmicroservicesΈ͍ͨͳߏ - ͑ΔετϨʔδͷछྨෳ͋Δ - MySQL
- Redis - Elasticsearch - Memcached - ͦͦ͜͜Ϣʔβ͕͋Δ
ํ - MailboxͰΖ͏ - ײతͰ͋Δ - σʔλྔͷ༧ଌ͕͋Δఔͭ͘ - ͱΓ͋͑ͣ௨ݸϕʔεͰΔ
Ͳ͏Δ͔ - ʮʯͰॻ͍ͨΑ͏ʹɼ RDBMS (SQL) Ͱ্ख͘Δํ๏Λ ฤΈग़ͤͳ͔ͬͨ - ࠓʹͳͬͯͬ͘͡Γߟ͑ͯΈΔͱ ग़དྷͨؾ͕͢Δ
(γϟʔσΟϯάͱ͔)
Ͳ͏Δ͔ - ͔͠͠༰ࣻͳ͘కΊΓ͍ۙͮ ͯ͘Δ (ʹ͕֮͑͋ΔͰ͠ΐ͏) - Α͠ɼ͜͜ҰஸRedisͰΖ͏
Redis
Redis - આ໌ུ - LISTΒZSETΒɼ ௨ʹ͍͍ͯͦ͏ͳσʔλߏ͕ αϙʔτ͞Ε͍ͯͯศར
Redis Cluster - Version 3͔Βఏڙ͞Ε͍ͯΔ ClusteringػೳΛར༻͍ͯ͠Δ - TODO: ͜͜ͰRedis ClusterΛ
๙Ίশ͑Δ
ͲͷσʔλߏΛ ࠾༻͢Δ͔
ͲͷσʔλߏΛ࠾༻͢Δ͔ - LIST - γϯϓϧ - LPUSH/RPOPΛΈ߹ΘͤΔͱ ؆୯ʹQueueͷΑ͏ͳߏΛ࣮ݱ Ͱ͖Δ
ͲͷσʔλߏΛ࠾༻͢Δ͔ - ZSET - ιʔτࡁΈηοτ - Α͘ϥϯΩϯάͷ࣮ͱ͔ʹΘΕΔͭ - TimestampΛscoreʹͯ͠ɼͦΕΛ ZREVRANGE
ͱ͔ͰҾ͍ͯ͘Δͱ࠷৽ॱͰऔͬͯ͜ΕΔ - ॱҐείΞϕʔεͰΓ٧ΊͰ͖ΔͷͰศར
ͲΕʹͨ͠ͷ͔
ͲͷσʔλߏΛ࠾༻͢Δ͔ ZSETʹͨ͠
ZSETʹͨ͠ - Timestamp ͷ߱ॱͰදࣔ͞ΕΔͷͰɼ ͠Կ͔͋ͬͨ࣌ʹλΠϜελϯϓ Λج४ͱͯ͠௨ίϯςϯπͷௐ ͕ޮ͘
ZSETʹͨ͠ - ͨͱ͑ʢࢄʑ൱ఆͯͨ͠Μ͚ͩͲʣ ৗʹઌ಄ʹද͍ࣔͨ͠ɼΈ͍ͨͳͷ͕ དྷͨ࣌ʹରԠ͕ग़དྷΔ (ແݶʹେ͖͍Λ score ʹͯ͠Δͱ ࣮ݱ͕Ͱ͖Δ)
ZSETʹͨ͠ - ͨͱ͑ʢࢄʑ൱ఆͯͨ͠Μ͚ͩͲʣ ৗʹઌ಄ʹද͍ࣔͨ͠ɼΈ͍ͨͳͷ͕ དྷͨ࣌ʹରԠ͕ग़དྷΔ (ແݶʹେ͖͍Λ score ʹͯ͠Δͱ ࣮ݱ͕Ͱ͖Δ) ੈͷதԿ͕ى͜Δ͔Θ͔Βͳ͍
ZSETʹͨ͠ - ݸϕʔεͷmailboxʹɼ ࣌ؒܦաϕʔεͷmailboxʹ ରԠͰ͖Δ
ZSETʹͨ͠ - ݸϕʔεͷmailboxʹɼ ࣌ؒܦաϕʔεͷmailboxʹ ରԠͰ͖Δ ੈͷதԿ͕ى͜Δ͔Θ͔Βͳ͍
ZSETʹͨ͠ - ෭࡞༻͚ͩΕͲ - จݴ͕ಉ͔ͭ͡timestamp͕ҧ͏ͱ͍͏ΞΠςϜ ͕དྷͨ߹ɼ৽͘͠དྷͨͷ͕༏ઌ͞ΕΔ => μϒΓ͕ͳ͘ͳΔ - ͜Ε͕ศརͳ߹ͱศརͰͳ͍߹͕
͋Γͦ͏͕ͩࠓճศརͩͬͨ
ະಡཧͲ͏͢Δ͔
ະಡཧͲ͏͢Δ͔ - ଟ͘ͷΞϓϦ௨Ͱ ະಡཧͷ࣮͕ཁٻ͞ΕΔ - Կ݅ཷ·ͬͯΔ͔ɼͱ͔ - ͲΕ͕৽ணͷ௨͔ɼͱ͔
ະಡཧ - MailboxͱରԠ͢ΔΧϯλͷΤ ϯτϦΛredisʹ࣋ͭΑ͏ʹͨ͠ - ৽͍͠௨͕དྷͨࡍʹZSETʹ Ճ͢Δͱಉ࣌ʹΧϯλΛINCR
Add notification notification|{subscriberId} - Notification unreadCount|{subscriberId} - Unread count
Add notification notification|{subscriberId} - Notification unreadCount|{subscriberId} - Unread count ZADD
Add notification notification|{subscriberId} - Notification unreadCount|{subscriberId} - Unread count INCR
Add notification notification|{subscriberId} - Notification unreadCount|{subscriberId} - Unread count INCR
ZADD ಉ࣌ʹߦ͏ (ޙड़)
ະಡཧ - ΫϥΠΞϯτ͔ΒϦΫΤετ͕͋ͬͨ࣌ ʹ௨ͱҰॹʹΧϯτΛฦͯ͠Δ - ΫϥΠΞϯτͦͷΧϯτΛͬͯ ʮ͜Ε͕৽ணʯͱ͍͏ݟͤํ͕Ͱ͖Δ - ͦͷ࣌ʹΧϯλΫϦΞͯ͠Δ
Client Get notification
Client Get notification Return notification and unread count
Client Get notification Return notification and unread count SET unreadCount|{subscriberId}
0 ͱಉ࣌ʹ
ະಡཧ - ৭ʑ͍Ͱ͕͋ΔͷͰະಡΧϯ τ͚ͩΛฦ͢APIఏڙ͍ͯ͠Δ - શମతʹγϯϓϧ
AtomicʹredisΛ ૢ࡞͢Δ
AtomicʹredisΛૢ࡞͢Δ - 1subscriber͋ͨΓͷ௨Λ࣮ݱ ͢Δʹ͋ͨͬͯredisʹ2Τϯτ Ϧඞཁͱͳͬͨ - Atomicʹૢ࡞͢Δඞཁ͕ग़ͯ͘Δ
Add notification notification|{subscriberId} - Notification unreadCount|{subscriberId} - Unread count INCR
ZADD ಉ࣌ʹߦ͏
AtomicʹredisΛૢ࡞͢Δ - Redis TransactionΛ͏ - MULTI-EXECΛ͏ํ๏ - ͋·ΓΦεεϝͰ͖ͳ͍ - Redis
Scriptingͷํ͕ߴ - ͍ͣΕػೳ͔Βআڈ͢Δ͔ͬͯݴͬͯΔ
AtomicʹredisΛૢ࡞͢Δ - Redis ScriptingΛ͏ - LuaʹΑΔscriptingΛ͏ํ๏ - Redis TransactionΑΓߴ -
1Scriptͷૢ࡞atomicʹߦΘΕΔ - ཁྑ͍ετΞυΈ͍ͨͳͭͰ͢
Redis Scripting - EVALίϚϯυLuaεΫϦϓτΛ ຖճredis serverʹૹ৴͢Δ - EVALίϚϯυͰLuaεΫϦϓτΛ࣮ߦ ͢ΔͱͦͷεΫϦϓτ͕SHA1ͷKeyʹ ͳͬͯredis
serverʹ֨ೲ͞ΕΔ
Redis Scripting - ҰSHA1͕ొ͞Εͯ͠·͑ɼ Ҏ߱ͦͷSHA1ΛEVALSHAίϚϯυ Ͱ͢Α͏ʹ͢Δͱಈ࡞͢Δ - ଳҬΛઅͰ͖Δʂ
EVAL foo
EVAL foo Register sha1(foo) {sha1(foo) => foo}
EVAL foo Register sha1(foo) Execute foo {sha1(foo) => foo}
EVAL foo Register sha1(foo) Execute foo (Result of foo) {sha1(foo)
=> foo}
Remembering sha1(foo) {sha1(foo) => foo}
EVALSHA sha1(foo) Remembering sha1(foo) {sha1(foo) => foo}
EVALSHA sha1(foo) Remembering sha1(foo) {sha1(foo) => foo} Execute foo
EVALSHA sha1(foo) Remembering sha1(foo) {sha1(foo) => foo} Execute foo (Result
of foo)
Redis Scripting - ͍͍ͪͪͦ͏͍͏ॲཧΛॻ͘ͷ໘ ͍͘͞ͷͰwrapperΛॻ͍ͨ - https://github.com/moznion/redis- script-manager-core - த@shogo82148͞Μͷ
p5-Redis-ScriptͷҠ২
Redis Scripting - ϒϩάʹॻ͍͓͍ͯͨ - http://moznion.hatenadiary.com/entry/ 2016/05/10/214648
શମ૾ͱͯ͠ Ͳ͏ͳ͍ͬͯΔͷ͔
Redis (JobQueue) Redis Cluster Worker Business Domain
؆୯ͳྲྀΕ (ૹฤ) 1. ϏδωευϝΠϯ͕JobQueueʹ௨ͷ ͨΊͷpayloadΛͭΊΔ 2. Worker͕payloadΛऔͬͯ͘Δ 3. Worker͕ରԠ͢Δsubscriberʹ௨Λඈ ͢
i. Enqueue a job to deliver notification ii. Pickup a
job iii. Deliver notification Redis (JobQueue) Redis Cluster Worker Business Domain
؆୯ͳྲྀΕ (ૹฤ) 1. ϏδωευϝΠϯ͕JobQueueʹ௨ͷ ͨΊͷpayloadΛͭΊΔ 2. Worker͕payloadΛऔͬͯ͘Δ 3. Worker͕ରԠ͢Δsubscriberʹ௨Λඈ ͢
i. Enqueue a job to deliver notification ii. Pickup a
job iii. Deliver notification Redis (JobQueue) Redis Cluster Worker Business Domain
JobQueueʹPayloadΛͭΊΔ - NotificationDeliverer Interface - deliver(String json) ͱ͍͏ நmethodΛ࣋ͬͨInterface
JobQueueʹPayloadΛͭΊΔ - NotificationDeliverer#deliver(String json) - ୭ʹૹΔ͔ (Ͳͷredis entryʹૹ͢Δ͔) - Push௨͕ඞཁ͔Ͳ͏͔
- Λҙ࣮ࣝͭͭ͢͠Δ
JobQueueʹPayloadΛͭΊΔ - ҙͷNotificationDelivererͷ࣮ͷclass name (ForAllUserDeliverer.classΈ͍ͨͳ) - Delivererͷ࣮ͷarguments - MessageΛද͢JSON String
(ޙड़) - ΛPayloadͱͯ͠JobQueueʹͭΊΔ
؆୯ͳྲྀΕ (ૹฤ) 1. ϏδωευϝΠϯ͕JobQueueʹ௨ͷ ͨΊͷpayloadΛͭΊΔ 2. Worker͕payloadΛऔͬͯ͘Δ 3. Worker͕ରԠ͢Δsubscriberʹ௨Λඈ ͢
i. Enqueue a job to deliver notification ii. Pickup a
job iii. Deliver notification Redis (JobQueue) Redis Cluster Worker Business Domain
Worker͕payloadΛऔͬͯ͘Δ - ରԠ͢ΔWorker͕JobQueue͔Β payloadΛऔͬͯ͘Δ - Ҏ্
؆୯ͳྲྀΕ (ૹฤ) 1. ϏδωευϝΠϯ͕JobQueueʹ௨ͷ ͨΊͷpayloadΛͭΊΔ 2. Worker͕payloadΛऔͬͯ͘Δ 3. Worker͕ରԠ͢Δsubscriberʹ௨Λඈ ͢
i. Enqueue a job to deliver notification ii. Pickup a
job iii. Deliver notification Redis (JobQueue) Redis Cluster Worker Business Domain
௨Λඈ͢ - Workerऔ͖ͬͯͨpayload͔Β ʮNotificationDelivererͷ࣮ͷ class nameʯΛऔΓग़͠ɼ reflectionΛͬͯinstantiate͢Δ
JobQueueʹPayloadΛͭΊΔ - ҙͷNotificationDelivererͷ࣮ͷclass name (ForAllUserDeliverer.classΈ͍ͨͳ) - Delivererͷ࣮ͷarguments - MessageΛද͢JSON String
(ޙड़) - ΛPayloadͱͯ͠JobQueueʹͭΊΔ
௨Λඈ͢ - ͦͷΠϯελϯεͷ deliver(String json)Λpayloadʹ ؚ·Ε͍ͯͨJSONΛͬͯݺͼग़͢ - ࣮ʹج͍ͯ௨͕ඈͿ
JobQueueʹPayloadΛͭΊΔ - ҙͷNotificationDelivererͷ࣮ͷclass name (ForAllUserDeliverer.classΈ͍ͨͳ) - Delivererͷ࣮ͷarguments - MessageΛද͢JSON String
(ޙड़) - ΛPayloadͱͯ͠JobQueueʹͭΊΔ
௨Λඈ͢ - ௨͕ඈͿͱݴ࣮ͬͯࡍʹsubscriberͷ mailbox (ZSET) ʹՃ͞ΕΔ͚ͩ - ScoreλΠϜελϯϓ - Valueʹdeliver()
ʹ͖ͬͯͨJSON͕ͦͷ·· ೖΔ - ͦͷ࣌௨ݸ͕ଟ͚Εݹ͍ͷΛ͍ग़͢
ValueͷJSONʹԿ͕ ೖ͍ͬͯΔͷ͔
JSONʹԿ͕ʁ - NotificationMessageFactoryΛ࣮ ͨ͠classͷclass name - ϓϨʔεϗϧμʹೖΔΞΠς ϜͷJSON
JSONʹԿ͕ʁ - NotificationMessageFactory - String makeNotificationMessage( T bind, Language lang
) - ͱ͍͏நmethodΛ࣋ͭInterface
JSONʹԿ͕ʁ - makeNotificationMessage() - ௨ϝοηʔδΛΈཱͯΔ - Payload͔Βऔ͖ͬͯͨJSONΛ σγϦΞϥΠζͨ͠ͷΛ͏ - ଟݴޠԽ͜͜Ͱٵऩ
ྫ
JSONʹԿ͕ʁ - αʔόαΠυͰ௨จݴΛΈཱͯΔ ͱ͍͏લఏ (ޙड़) - ੜϝοηʔδ͕ೖͬͯΔͱi18n͕Γ ʹ͍͘ - ͷͰ͜͏͍͏ߏʹ
؆୯ͳྲྀΕ (औಘฤ) 1. ௨ΛҾ͍ͯ͘Δ 2. Ҿ͍͖ͨͨ௨શ෦ʹରͯ͠ ϝοηʔδΛΈཱͯΔ
o. Get Redis (JobQueue) Redis Cluster Worker Business Domain i.
Retrieve notification ii. Construct notification messages iii. Return
؆୯ͳྲྀΕ (औಘฤ) 1. ௨ΛҾ͍ͯ͘Δ 2. Ҿ͍͖ͨͨ௨શ෦ʹରͯ͠ ϝοηʔδΛΈཱͯΔ
o. Get Redis (JobQueue) Redis Cluster Worker Business Domain i.
Retrieve notification ii. Construct notification messages iii. Return
௨ΛҾ͍ͯ͘Δ - ରͱͳΔsubscriberͷmailbox (ZSET) ͔Β௨ΛҾ͍ͯ͘Δ - ZREVRANGEίϚϯυ
؆୯ͳྲྀΕ (औಘฤ) 1. ௨ΛҾ͍ͯ͘Δ 2. Ҿ͍͖ͨͨ௨શ෦ʹରͯ͠ ϝοηʔδΛΈཱͯΔ
o. Get Redis (JobQueue) Redis Cluster Worker Business Domain i.
Retrieve notification ii. Construct notification messages iii. Return
ϝοηʔδΛΈཱͯΔ - Ҿ͍͖ͯͨ௨JSON String - ͔͜͜Βਓ͕ಡΊΔϝοηʔδΛ ΈཱͯΔඞཁ͕͋Δ
JSONʹԿ͕ʁ - NotificationMessageFactoryΛ ࣮ͨ͠classͷclass name - ϓϨʔεϗϧμʹೖΔΞΠς ϜͷJSON
ϝοηʔδΛΈཱͯΔ - NotificationMessageFactoryΛ࣮ͨ͠classͷ class nameΛͬͯreflectionͰinstantiate - makeNotificationMessage() ݺͿ - ΞΠςϜͷJSONΛͬͯϓϨʔεϗϧμΛຒΊΔ
- ͷݴޠใʹج͖ͮ࠷దͳݴޠͰΈཱͯΔ
LLͷྑ͍ͱ͜ΖΛ आΓ͖࣮ͯͨͱ͍͏ײ͡
- ͱ͍࣮͑ߦ࣌ྫ֎͕όϯόϯ ى͖ΔͷࠔΔͷͰɼ δΣωϦΫεͰറ͍ͬͯΔײ͡ - ΠϯϓοτͷνΣοΫΛݫ֨ʹ
͔͠͠ReflectionͰinstantiate ͢Δͱίετߴͦ͏ͩ͠ɼ ͔͠ຖຖΔͷμα͘ͳ͍ʁ
FlyWeight - FlyWeightͰΕ҆৺ - ΫϥεࣗମΠϛϡʔλϒϧͳͷͰ ͍ճ͕͠ޮ͘ - ·͍ͨͭͰʹ sprint ͱ͍͏ͷ
ॻ͍ͨ https://github.com/moznion/sprint
ͱ͍͏ײ͡ ࣮ࡍʹͪΌΜͱಈ͍ͯΔʂ ΊͰͨ͠ΊͰͨ͠
ͱͳΒͳ͍
- Ͳ͏ͯ͠Redisʹෛՙ͕ूத͠ ͯ͠·͏…… - ௨৴࣌ͷτϥϑΟοΫͷ্ - σʔλαΠζͷ্ঢ
Ͳ͏͖͔͢
Ͳ͏͖͔͢ - RedisΛγϟʔσΟϯάͯ͠͏ ͱ͔……ʁ
ະ