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
13k
これはPerl? それともRuby? クイズ〜〜〜〜〜!!!- Perl or Ruby Quiz
moznion
3
2.3k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
890
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
60
AWS上に構築する メンテ容易なElasticsearch System / Maintainable Elasticsearch system on AWS
moznion
2
3.9k
PROXY Protocol aware Proxy Server on Node.js
moznion
2
2.4k
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
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
1
1.3k
ライブラリでしかお目にかかれない珍しい実装
mikanichinose
2
340
20241108_CS_LLMMT
shigashiyama
0
260
いざ、BSC討伐の旅
nikinusu
2
740
인디 앱 개발자와 Flutter
tinyjin
0
160
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
3
1.2k
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
290
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
140
Lambdaと地方とコミュニティ
miu_crescent
2
330
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
190
音声×Copilot オンコパの世界
kasada
1
120
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
200
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building Adaptive Systems
keathley
38
2.3k
What's new in Ruby 2.0
geeforr
343
31k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Designing for Performance
lara
604
68k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
RailsConf 2023
tenderlove
29
900
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
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ΛγϟʔσΟϯάͯ͠͏ ͱ͔……ʁ
ະ