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
43
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
57
Mystery of Realtime
atul9
0
45
Other Decks in Technology
See All in Technology
Codex 5.3 と Opus 4.6 にコーポレートサイトを作らせてみた / Codex 5.3 vs Opus 4.6
ama_ch
0
140
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
890
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
Amazon Bedrock Knowledge Basesチャンキング解説!
aoinoguchi
0
140
20260208_第66回 コンピュータビジョン勉強会
keiichiito1978
0
130
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
220
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
0
130
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
68k
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
150
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
210
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
110
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
77
5.2k
Agile that works and the tools we love
rasmusluckow
331
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
Automating Front-end Workflow
addyosmani
1371
200k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
450
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
64
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
The untapped power of vector embeddings
frankvandijk
1
1.6k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
110
How to Think Like a Performance Engineer
csswizardry
28
2.4k
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