SlideShare a Scribd company logo
Александр Хохлов
@nots_io
Phoenix and beyond:
Things we do with Elixir
Founder at Nots.io
http://nots.io
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Why this talk?
In the beginning…
Phoenix:
Web Sockets, HAML, SASS
Guardian, Arc, ex_aws, Swoosh,
ueberauth/ueberauth_github
RethinkDB
rethinkdb_changefeed
postgrex
https://github.com/h4cc/
awesome-elixir
http://obolinx.com/resources/?p=1837
Erlang/Elixir port to Java process
with JInterface
https://www.safaribooksonline.com/library/view/erlang-programming/9780596803940/ch16s05.html
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
def init(_params) do 

cd = “#{:code.priv_dir(:your_app)}" 

cmd = "java -jar package.jar" 

port = Port.open({:spawn,cmd}, [:binary, :use_stdio,
packet: 4, cd: cd]) 

true = Port.connect(port, self()) 

{:ok,port} 

end
Port.command(port, :erlang.term_to_binary(data))
def handle_info({port,{:data,b}}, port) do 

data = :erlang.binary_to_term(b) 

end
Postgrex.Notifications +
GenServer
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
PLPGSQL:
PERFORM pg_notify(‘invitations_changes’, payload)
Elixir:
{:ok, pid} = Postgrex.Notifications.start_link(config)
Postgrex.Notifications.listen(pid, "invitations_changes") 



def handle_info({:notification, _pid, _ref,
"invitations_changes", payload}, state) do … end
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
API:
HTTP API with
Poison & HTTPoison
HTTPoison.put(url, Poison.encode!(data)) 

HTTPoison.get(url) 

HTTPoison.post(url, Poison.encode!(data))) 

case resp do 

{:ok, %HTTPoison.Response{status_code: 200, body: body}}->
{:ok, body |> Poison.decode!} 

{:ok, %HTTPoison.Response{status_code: 404}} ->
{:error, :not_found} 

{:ok, %HTTPoison.Response{body: body}} ->
{:error, body |> Poison.decode!} 

{:error, %HTTPoison.Error{reason: reason}} ->
{:error, reason} 

end 

API:
Socket API with gen_tcp
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
# receive tcp packet as message 

{:ok, socket} = :gen_tcp.connect('localhost', port,
[:binary, active: true]) 

def handle_info({:tcp, _socket, msg}, state) do ...
end 



# receive tcp packet with recv 

:inet.setopts(socket, active: false) 

:ok = :gen_tcp.send(socket, data) 

{:ok, <<_msg_len :: binary - size(16),
msg :: binary>>} = :gen_tcp.recv(socket, 0, 2000) 

Concurrent tasks
results = notes 

|> Task.async_stream(__MODULE__, :update,
[some, params], max_concurrency: 20) 

|> Enum.to_list 

|> Keyword.get(:ok) 



def update(note, some, params) do ... end 

Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
point@nots.io
http://nots.io
http://blog.nots.io
@nots_io
facebook.com/nots.io

More Related Content

PDF
10x Command Line Fu
PDF
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
PDF
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
PDF
BUILDING APPS WITH ASYNCIO
PDF
Es.next
PDF
aiohttp intro
PDF
My Robot Poops - In JavaScript (with web sockets)
PPT
Mining Ruby Gem vulnerabilities for Fun and No Profit.
10x Command Line Fu
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
BUILDING APPS WITH ASYNCIO
Es.next
aiohttp intro
My Robot Poops - In JavaScript (with web sockets)
Mining Ruby Gem vulnerabilities for Fun and No Profit.

What's hot (19)

PPTX
Visualizing ORACLE performance data with R @ #C16LV
PPTX
10 tips for making Bash a sane programming language
PDF
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
PPTX
Fun with exploits old and new
PPTX
How to discover 1352 Wordpress plugin 0days in one hour (not really)
PDF
Fake My Party
PDF
Ansible for beginners ...?
KEY
Node.js
PDF
Git::Hooks
PDF
以 Laravel 經驗開發 Hyperf 應用
PDF
Machine learning on source code
PDF
Ansible tips & tricks
PDF
MeshU Thin & Rack
PDF
Cooking with Chef
PDF
New ES6 Hotness
PDF
Effective ES6
PDF
Yaroslav Martsynyuk - Deploying Elixir/Phoenix with Distillery
PDF
Ansible, Simplicity, and the Zen of Python
PDF
Introduction to Retrofit
Visualizing ORACLE performance data with R @ #C16LV
10 tips for making Bash a sane programming language
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
Fun with exploits old and new
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Fake My Party
Ansible for beginners ...?
Node.js
Git::Hooks
以 Laravel 經驗開發 Hyperf 應用
Machine learning on source code
Ansible tips & tricks
MeshU Thin & Rack
Cooking with Chef
New ES6 Hotness
Effective ES6
Yaroslav Martsynyuk - Deploying Elixir/Phoenix with Distillery
Ansible, Simplicity, and the Zen of Python
Introduction to Retrofit
Ad

Similar to Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov (20)

PDF
Echtzeitapplikationen mit Elixir und GraphQL
PDF
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
PDF
Elixir
PDF
Container (Docker) Orchestration Tools
PPTX
Cosmos, Big Data GE Implementation
PPTX
Cosmos, Big Data GE implementation in FIWARE
KEY
Erlang sucks. EUC 2012
PDF
Building web framework with Rack
PDF
Transforming WebSockets
PPT
Shell scripting - By Vu Duy Tu from eXo Platform SEA
PDF
Node intro
PDF
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
PPTX
Infrastructure as Code: Introduction to Terraform
PDF
Diseño y Desarrollo de APIs
PDF
Next Generation DevOps in Drupal: DrupalCamp London 2014
PDF
Great Developers Steal
PDF
Ecto and Phoenix: Doing Web With Elixir
PDF
Ecto and Phoenix: Doing web with Elixir - Yurii Bodarev
PDF
extending-php
PDF
extending-php
Echtzeitapplikationen mit Elixir und GraphQL
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
Elixir
Container (Docker) Orchestration Tools
Cosmos, Big Data GE Implementation
Cosmos, Big Data GE implementation in FIWARE
Erlang sucks. EUC 2012
Building web framework with Rack
Transforming WebSockets
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Node intro
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
Infrastructure as Code: Introduction to Terraform
Diseño y Desarrollo de APIs
Next Generation DevOps in Drupal: DrupalCamp London 2014
Great Developers Steal
Ecto and Phoenix: Doing Web With Elixir
Ecto and Phoenix: Doing web with Elixir - Yurii Bodarev
extending-php
extending-php
Ad

More from Elixir Club (20)

PDF
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
PDF
Integrating 3rd parties with Ecto - Eduardo Aguilera | Elixir Club Ukraine
PDF
— An async template - Oleksandr Khokhlov | Elixir Club Ukraine
PDF
BEAM architecture handbook - Andrea Leopardi | Elixir Club Ukraine
PDF
You ain't gonna need write a GenServer - Ulisses Almeida | Elixir Club Ukraine
PDF
— Knock, knock — An async templates — Who’s there? - Alexander Khokhlov | ...
PDF
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
PDF
Erlang cluster. How is it? Production experience. — Valerii Vasylkov | Elixi...
PDF
Promo Phx4RailsDevs - Volodya Sveredyuk
PDF
Web of today — Alexander Khokhlov
PDF
ElixirConf Eu 2018, what was it like? – Eugene Pirogov
PDF
Implementing GraphQL API in Elixir – Victor Deryagin
PDF
WebPerformance: Why and How? – Stefan Wintermeyer
PDF
GenServer in Action – Yurii Bodarev
PDF
Russian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
PDF
Practical Fault Tolerance in Elixir - Alexei Sholik
PDF
Monads are just monoids in the category of endofunctors - Ike Kurghinyan
PDF
Craft effective API with GraphQL and Absinthe - Ihor Katkov
PDF
Elixir in a service of government - Alex Troush
PDF
Pattern matching in Elixir by example - Alexander Khokhlov
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Integrating 3rd parties with Ecto - Eduardo Aguilera | Elixir Club Ukraine
— An async template - Oleksandr Khokhlov | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi | Elixir Club Ukraine
You ain't gonna need write a GenServer - Ulisses Almeida | Elixir Club Ukraine
— Knock, knock — An async templates — Who’s there? - Alexander Khokhlov | ...
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Erlang cluster. How is it? Production experience. — Valerii Vasylkov | Elixi...
Promo Phx4RailsDevs - Volodya Sveredyuk
Web of today — Alexander Khokhlov
ElixirConf Eu 2018, what was it like? – Eugene Pirogov
Implementing GraphQL API in Elixir – Victor Deryagin
WebPerformance: Why and How? – Stefan Wintermeyer
GenServer in Action – Yurii Bodarev
Russian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
Practical Fault Tolerance in Elixir - Alexei Sholik
Monads are just monoids in the category of endofunctors - Ike Kurghinyan
Craft effective API with GraphQL and Absinthe - Ihor Katkov
Elixir in a service of government - Alex Troush
Pattern matching in Elixir by example - Alexander Khokhlov

Recently uploaded (20)

PPT
chapter_1_a.ppthduushshwhwbshshshsbbsbsbsbsh
PPTX
了解新西兰毕业证(Wintec毕业证书)怀卡托理工学院毕业证存档可查的
PPTX
"Fundamentals of Digital Image Processing: A Visual Approach"
PPTX
Lecture 3b C Library _ ESP32.pptxjfjfjffkkfkfk
PDF
-DIGITAL-INDIA.pdf one of the most prominent
PPTX
code of ethics.pptxdvhwbssssSAssscasascc
PDF
Dynamic Checkweighers and Automatic Weighing Machine Solutions
PPTX
Nanokeyer nano keyekr kano ketkker nano keyer
PPTX
STEEL- intro-1.pptxhejwjenwnwnenemwmwmwm
PPTX
5. MEASURE OF INTERIOR AND EXTERIOR- MATATAG CURRICULUM.pptx
PPTX
1.pptxsadafqefeqfeqfeffeqfqeqfeqefqfeqfqeffqe
PPTX
Presentacion compuuuuuuuuuuuuuuuuuuuuuuu
PPT
FABRICATION OF MOS FET BJT DEVICES IN NANOMETER
PPTX
Embeded System for Artificial intelligence 2.pptx
PPTX
DEATH AUDIT MAY 2025.pptxurjrjejektjtjyjjy
DOCX
A PROPOSAL ON IoT climate sensor 2.docx
PPTX
INFERTILITY (FEMALE FACTORS).pptxgvcghhfcg
PPTX
making presentation that do no stick.pptx
PPTX
Prograce_Present.....ggation_Simple.pptx
PPTX
quadraticequations-111211090004-phpapp02.pptx
chapter_1_a.ppthduushshwhwbshshshsbbsbsbsbsh
了解新西兰毕业证(Wintec毕业证书)怀卡托理工学院毕业证存档可查的
"Fundamentals of Digital Image Processing: A Visual Approach"
Lecture 3b C Library _ ESP32.pptxjfjfjffkkfkfk
-DIGITAL-INDIA.pdf one of the most prominent
code of ethics.pptxdvhwbssssSAssscasascc
Dynamic Checkweighers and Automatic Weighing Machine Solutions
Nanokeyer nano keyekr kano ketkker nano keyer
STEEL- intro-1.pptxhejwjenwnwnenemwmwmwm
5. MEASURE OF INTERIOR AND EXTERIOR- MATATAG CURRICULUM.pptx
1.pptxsadafqefeqfeqfeffeqfqeqfeqefqfeqfqeffqe
Presentacion compuuuuuuuuuuuuuuuuuuuuuuu
FABRICATION OF MOS FET BJT DEVICES IN NANOMETER
Embeded System for Artificial intelligence 2.pptx
DEATH AUDIT MAY 2025.pptxurjrjejektjtjyjjy
A PROPOSAL ON IoT climate sensor 2.docx
INFERTILITY (FEMALE FACTORS).pptxgvcghhfcg
making presentation that do no stick.pptx
Prograce_Present.....ggation_Simple.pptx
quadraticequations-111211090004-phpapp02.pptx

Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov