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
Simple組み合わせ村から大都会Railsにやってきた俺は / Coming to Rails from the Simple
moznion
3
2.1k
AIレシート読み取り機能をRuby on Rails on AWSで実現するLLMにまつわるアレコレ / AI-based receipt reading function powered by LLM on Ruby on Rails on AWS
moznion
3
130
Develop to Survive - YAPC::Hakodate 2024 Keynote
moznion
10
15k
これはPerl? それともRuby? クイズ〜〜〜〜〜!!!- Perl or Ruby Quiz
moznion
3
2.5k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
960
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
73
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
Other Decks in Technology
See All in Technology
Oracle Exadata Database Service(Dedicated Infrastructure):サービス概要のご紹介
oracle4engineer
PRO
0
12k
ドメイン駆動設計の実践により事業の成長スピードと保守性を両立するショッピングクーポン
lycorptech_jp
PRO
12
1.7k
今年一年で頑張ること / What I will do my best this year
pauli
1
220
Formal Development of Operating Systems in Rust
riru
1
420
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
170
自社 200 記事を元に整理した読みやすいテックブログを書くための Tips 集
masakihirose
2
330
データ基盤におけるIaCの重要性とその運用
mtpooh
4
500
Git scrapingで始める継続的なデータ追跡 / Git Scraping
ohbarye
5
490
GeometryReaderやスクロールを用いた表現と紐解き方
fumiyasac0921
0
100
GoogleのAIエージェント論 Authors: Julia Wiesinger, Patrick Marlow and Vladimir Vuskovic
customercloud
PRO
0
150
JAWS-UG20250116_iOSアプリエンジニアがAWSreInventに行ってきた(真面目編)
totokit4
0
140
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
290
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
3
180
Documentation Writing (for coders)
carmenintech
67
4.5k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Navigating Team Friction
lara
183
15k
Speed Design
sergeychernyshev
25
740
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Side Projects
sachag
452
42k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
173
51k
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ΛγϟʔσΟϯάͯ͠͏ ͱ͔……ʁ
ະ