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
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
290
Deno+JSRでパッケージを作って公開する
askua
0
120
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
330
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
180
Engineering at LY Corporation
lycorp_recruit_jp
0
610
いざ、BSC討伐の旅
nikinusu
2
730
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
220
State of Open Source Web Mapping Libraries
dayjournal
0
240
マイベストのデータ基盤の現在と未来 / mybest-data-infra-asis-tobe
mybestinc
2
2k
音声×Copilot オンコパの世界
kasada
1
120
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
140
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
YesSQL, Process and Tooling at Scale
rocio
168
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
How STYLIGHT went responsive
nonsquared
95
5.2k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
The Cult of Friendly URLs
andyhume
78
6k
Typedesign – Prime Four
hannesfritz
40
2.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.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ΛγϟʔσΟϯάͯ͠͏ ͱ͔……ʁ
ະ