Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Let's Chat
Search
Garrett Heinlen
September 12, 2017
Education
470
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Let's Chat
Ruby and Elixir. An exploration of cross language communication
Garrett Heinlen
September 12, 2017
Transcript
57 slides
Let's Chat Ruby and Elixir. An exploration of cross language
communication
Hey, I'm Garre!
None
None
I work for Blake Education
We teach children
None
We use Ruby && Elixir
Why did we move? — really fast — immutable data
— parallel / concurrent — easy to isolate complexity into applications (microservices w/o http) — encourages better design — shiny — does your taxes — #1 hacker news
Agenda — Refresher on Ruby — Explain Redis — Explore
Sidekiq — Introduce Elixir — Demo — Recap
Refresher on Ruby
Ruby - Hash We use keys to unlock values
Ruby - Hash ! ! " # ! " $
! " %
Ruby - Hash ! my_house ! door_1 " # shower
! door_2 " $ living_room ! door_3 " % bedroom
Ruby - Hash my_house = { door_1: "shower", door_2: "living_room",
door_3: "bedroom", }
Ruby - Hash person = { name: "Garrett", age: 27,
hearthstone_rank: 3, fav_things: [] } person[:hearthstone_rank] # => 3 person[:fav_things] << "gummy bears" # => ["gummy bears"]
Ruby - Array An Array is a list of items
in order
Ruby - Array ! " # $ %
Ruby - Array
Ruby - Array a = [] # => [] a
<< "abc" # => ["abc"] a # => ["abc"] a.pop # => "abc" a # => []
Ruby - Array a = [] # => [] a.push("abc")
# => ["abc"] a # => ["abc"] a.pop # => "abc" a # => []
Ruby - Array Appending to a list x << y
x.push(y)
Ruby - Array Pulling items off a list x.pop(y)
Ruby - Array Push && Pop x.push(y) x.pop(y)
None
PushPop
Well, that's Ruby.
Explain Redis
Redis is a hash in the cloud.
$redis = {} # setter $redis[:thought] = "Where's the Elixir
already?" # getter $redis[:thought] # => "Where's the Elixir already?" # setter $redis[:drinks] << "little creatures" $redis[:drinks] << "150 lashes" # getter $redis[:drinks] # => ["little creatures", "150 lashes"]
$ redis-cli set thought "Where's the Elixir already?" get thought
# => "Where's the Elixir already?" rpush drinks "little creatures" rpush drinks "150 lashes" lrange drinks 0 -1 # => 1) "little creatures" # => 2) "150 lashes" lpop drinks # => "little creatures"
Redis Desktop Manager
Explore Sidekiq
Sidekiq framework for background job processing
Why do I need a Sidekiq
¯\(ϑ)/¯
Common Use cases — Emails — Expensive computation — Imagine
Processing — Reports — Etc..
None
Sidekiq is built on 3 parts — Client — push
jobs into redis — Redis — store the jobs — Server — process the jobs
Client MyWorker.perform_async({abc: "123", simple_as: "drm"}) Redis rpush queue:default "{\"class\":\"MyWorker\",\"args\":[{\"abc\":\"123\",\"simple_as\":\"drm\"], \"retry\":true,\"queue\":\"default\",
\"jid\":\"f03cd72fef59bfbbf4098890\", \"created_at\":1503728661.8513222,\"enqueued_at\":1503728661.851379}" Server class MyWorker include Sidekiq::Worker def perform(hash) puts hash.inspect # => {abc: "123", simple_as: "drm"} end end
Client class SomethingSingularOrPluarl < BigBaseController def create MyWorker.perform_async(superfriend_params) head :created
end private def superfriend_params params.permit! # {abc: "123", simple_as: "drm"} end end
Redis
Server class MyWorker include Sidekiq::Worker def perform(hash) puts hash.inspect #
=> {abc: "123", simple_as: "drm"} end end
Lets Chat, A practical application
Sidekiq - how does it work? # clients rpush "redis:jobs"
{assignee: "Audience Member", task: "Greet your neighbour"} rpush "redis:jobs" {assignee: "Audience Member", task: "Take a drink"} rpush "redis:jobs" {assignee: "Audience Member", task: "Heckle louder"} rpush "redis:jobs" {assignee: "Audience Member", task: "Do Garrett's Taxes"} # sidekiq while true job = lpop "redis:jobs" if job AudienceMember.perform(job) end end
None
Well, thats Sidekiq.
Introduce Elixir
Elixir can act as the Server.
Exq job processing library compatible with Sidekiq for Elixir
Configure Exq config :exq, host: "localhost", port: 6379, namespace: "",
concurrency: 10, queues: ["default"], poll_timeout: 200
Ruby Sidekiq Server class MyWorker include Sidekiq::Worker def perform(hash) puts
hash.inspect # => {abc: "123", simple_as: "drm"} end end
Elixir Sidekiq Server defmodule MyWorker do def perform(map) do IO.inspect(map)
# => %{abc: "123", simple_as: "drm"} end end
Demo Time !
None
Recap — Redis is a Hash — We push jobs
into a list — We pull jobs off the list — We can process the jobs with Ruby or Elixir — Exq is the Elixir Sidekiq
Thanks @gogogarre!
More Decks by Garrett Heinlen
See All by Garrett Heinlen
Event Sourcing: Don't want to miss a thing
gogogarrett
0
150
Lets Program - A practical guide
gogogarrett
0
81
StudyGroups
gogogarrett
1
100
:gen_fsm meets elixir
gogogarrett
1
400
Intro into Ecto
gogogarrett
2
110
Hopscotch
gogogarrett
1
190
Ember Testing: is it a mirage?
gogogarrett
1
200
Elixir and Phoenix
gogogarrett
0
230
WTF is WF
gogogarrett
1
160
Other Decks in Education
See All in Education
El Geoparque Mundial UNESCO Volcanes de Calatrava de la Investigación Científica a la Transposición Didáctica en el aula
juanmartin2026
1
58k
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 Training Series, Session Six: Licensing & Market Power"
baltimoreniso
0
160
Evaluation Methods - Lecture 6 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.7k
PROTEINS
pawan_pharm
0
100
North Carolina Task Force on Child Care and Early Education
rashwhitman
0
1.6k
新型コロナ禍をともに「楽しみながら開いていこう!」 :中門 吉松 会員(2720 Japan O.K.ロータリーEクラブ)卓話 : 2026.10.19.例会・卓話
2720japanoke
0
770
Sekolah Sabat - Triwulan 4 2026 - Pelajaran 3
hiola
0
7.3k
[2026後期火5] 論理学(京都大学文学部 後期 第2回)「量化子の導入」
yatabe
0
300
Semantic Web and Web 3.0 - Lecture 9 - Web Technologies (1019888BNR)
signer
PRO
2
3.7k
OCI Always Freeの「えっ?」36選 〜「どうせ無料枠でしょ」と思っている人へ〜
shisyu_gaku
1
240
Unit 3: Subsidiary Book
bvr7352
0
110
AIができることを人はなぜ学ぶのか ― 専門性を育て、AIと学び続ける大学へ
gmoriki
0
200
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.7k
sira's awesome portfolio website redesign presentation
elsirapls
0
530
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
530
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
540
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
490
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
What's in a price? How to price your products and services
michaelherold
247
13k
WENDY [Excerpt]
tessaabrams
15
41k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Spectacular Lies of Maps
axbom
PRO
1
1.2k