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
2
1.3k
AIレシート読み取り機能をRuby on Rails on AWSで実現するLLMにまつわるアレコレ / AI-based receipt reading function powered by LLM on Ruby on Rails
moznion
1
7
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
950
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
69
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
Formal Development of Operating Systems in Rust
riru
1
410
能動的ドメイン名ライフサイクル管理のすゝめ / Practice on Active Domain Name Lifecycle Management
nttcom
0
340
Git scrapingで始める継続的なデータ追跡 / Git Scraping
ohbarye
4
110
20241125 - AI 繪圖實戰魔法工作坊 @ 實踐大學
dpys
1
450
完全自律型AIエージェントとAgentic Workflow〜ワークフロー構築という現実解
pharma_x_tech
0
240
Godot Engineについて調べてみた
unsoluble_sugar
0
180
商品レコメンドでのexplicit negative feedbackの活用
alpicola
1
200
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
110
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
250
LangGraphとFlaskを用いた社内資料検索ボットの実装②Retriever構築編
aoikumadaki
0
100
OCI技術資料 : ファイル・ストレージ 概要
ocise
3
12k
30分でわかる「リスクから学ぶKubernetesコンテナセキュリティ」/30min-k8s-container-sec
mochizuki875
3
400
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.5k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Gamification - CAS2011
davidbonilla
80
5.1k
Mobile First: as difficult as doing things right
swwweet
222
9k
Why Our Code Smells
bkeepers
PRO
335
57k
4 Signs Your Business is Dying
shpigford
182
22k
Code Reviewing Like a Champion
maltzj
521
39k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
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ΛγϟʔσΟϯάͯ͠͏ ͱ͔……ʁ
ະ