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
Froze middleware talk
Search
Atul Bhosale
July 29, 2017
Technology
0
37
Froze middleware talk
I had given this talk at Deccan Ruby Conf 2017, Pune
Atul Bhosale
July 29, 2017
Tweet
Share
More Decks by Atul Bhosale
See All by Atul Bhosale
Lets enhance ActionCable
atul9
0
53
Mystery of Realtime
atul9
0
37
Other Decks in Technology
See All in Technology
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
270
社内アプリで Cloudflare D1を プロダクト運用してみた体験談(Tokyo)
haochenx
0
120
2024春 注目のWeb系 OSS & SaaS 3選
makies
0
180
Next.js に疲れた私は Vue3 に癒やされた
akagire
0
140
自己改善からチームを動かす! 「セルフエンジニアリングマネージャー」のすゝめ
shoota
6
1k
Max out Local LLM in Challenging Environments
sashimimochi
1
110
Google Cloud Next '24でブログを10本書いた方法と勉強会を沸かせた方法
yasumuusan
0
330
Android Target SDK 35 (Android 15) 対応の概要
akkie76
0
150
GrafanaMeetup_AmazonManagedGrafanaのアクセス制御機能とマルチテナント環境下でのアクセス制御について
daitak
0
400
一生覚えておきたい「システム開発=コミュニケーション」〜初めての実務案件振り返りLT〜
maimyyym
2
320
JAWS-UG Bedrock Claude Night
yamahiro
3
710
【SORACOM UG 東海】あらゆるモノがつながる社会へ、IoT と SORACOM
soracom
PRO
1
140
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
Web development in the modern age
philhawksworth
203
10k
Design by the Numbers
sachag
274
18k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
22
1.6k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Robots, Beer and Maslow
schacon
PRO
155
7.9k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Embracing the Ebb and Flow
colly
80
4.2k
Transcript
ATUL BHOSALE CODEMANCERS @atul1b
None
Rack middleware
None
1 5 4 3 2 Web Requests
None
None
WHY?
# Non Thread safe code class Counter def initialize @counter
= 0 end def call(_env) counter = @counter sleep 1 counter += 1 @counter = counter [200, { 'Content-Type' => 'text/html' }, ["#{@counter}"]] end end
WHAT? • Don’t mutate state • Freeze middleware instances •
Use data-structures from concurrent-ruby
None
# Thread safe code class Counter def initialize @atomic =
Concurrent::AtomicReference.new(0) end def call(_env) @atomic.update { |v| v + 1 } [200, { 'Content-Type' => 'text/html' }, ["{@atomic}"]] end end
None
None
None
use (Class.new do def call(env) @a = 1 if env['PATH_INFO']
== '/a' @app.call(env) end freeze_app end)
There is no way to unfreeze a frozen object
Thank you
None