Empex 2016 Meetup Recap

Andrew Forward
2 min readJun 23, 2016

--

In May 2016, I attended Empex, the first (annual, let’s hope) Elixir conference in NYC (called Empex). It was a one day conference full of great talks about Elixir, Phoenix, and Erlang. I am presenting a recap at a local meetup this month, and tracking my notes here.

Highlights

Keynote with Bruce Tate

Bruce Tate is a cool guy. He talked a lot about how we progressed from Java, to Ruby and now onto Elixir and Erlang.

Years ago he was on a train with Dave Thomas and talking about not getting ruby, to which a rarely frustrated Dave says “Shut up and do something nontrivial in ruby, and then we can talk”.

Another word that I may or may not have heard of was QWAN or Quality With a Name. In particular, language making in seeking QWAN.

Async Jobs in Elixir with George Guimarães

Task.Async

Avoid it. If the task dies it brings down the caller too.

Task.Supervisor

Familiar pattern that is used throughout most libs. You create your supervisory tree as follows (and it can be nested and complex if you like)

children = [
supervisor(Backyard.Endpoint, []),
supervisor(Bakcyard.Repo, []),
supervisor(Task.Supervisor, [[name: Backyard.Spreadsheet.ImporterSupervisor]]),
]

To start off your supervisor,

Task.Supervisor.start_child(
Backyard.Spreadsheet.ImporterSupervisor,
Spreadsheet.Importer, :start, [file]
)

Smart defaults include

strategy: :simple_one_for_one
restart: :temporary

Useful for things like

  • spreadsheet importer
  • image resize
  • email
  • counter cache
  • ratings

For deployment, consider using

shutdown: :brutal_kill (or :infinity, 5_000)

Be weary of external resources and consider restraining your code to avoid overwhelming those services (e.g. poolboy).

Poolboy

This provides a GenServer as a EventManager and is suitable when you want to limit the number of running processes in the pool; also supports retry if those services fail

External Queues

If you need a bit more persistence around your processes then look at using an external queue such as verk (job processor backed by redis). It has a great user interface for watching workers. Another option is nats, another message broker meant to be much simpler than say kafka or rabbitmq.

Your First Package with Brian Cardarella

Make sure to provide sensible values in your mix.exs and WTFM

def project do
[app: :crazypants,
version: "1.2.3",
elixir: “~> 1.2”,
deps: deps,
# Hex
description: "Lots of crazy pants",
package: [
maintainers: ["x"],
license: ["MIT"],
links %{"GitHub"}
],
docs: [
main: "CrazyPants",
logo: "/crazypants.png"
]

Look at the following packages to help

Create them locally

mix docsopen doc/index.html

For more advanced, take a look at Typespec

@spec drop(binary) :: binrary
def drop(location) do
“Hey, #{location}”
end

And use dialyxir for contract enforcement

mix dialyzer.plt
mix dialyzer

CodeGen In Elixir

Links

--

--

Andrew Forward

Back to PHP and #elixir; flirting with #Elm. TDD infected since jUnit 2.1, former cheesemaker, and working at #crossfit