54

Designing for Scalability with Erlang/OTP using Elixir – Part 2

 5 years ago
source link: https://www.tuicool.com/articles/hit/bABFnuj
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Chapter 4

I am still working my way through this book.

The main difficulty that I am finding with chapter 4 is the scattered nature of the example code. It’s all small snippets, some of which references code in the previous chapter.

This is in addition to the Erlang => Elixir translations:

  • atom => :atom
  • VariableName => variable_name
  • moduleName => ModuleName

Some of the Elixir functions are reordered for consistency.

#Erlang
1> gen_server:start_link({local, timeout}, timeout, [], []).

#Elixir
1> c "Timeout.ex"
2> GenServer.start_link(Timeout, [], name: :timeout)
3> GenServer.call(:timeout, {:sleep, 100})
4> GenServer.call(:timeout, {:sleep, 5001})

The GenServer will by default timeout if a message takes more than 5 seconds to respond.

Samples for Chapter 4 have been pushed to

https://github.com:chriseyre2000/scalability_ex with hash: cc8dd44

Chapter 5

The Erlang sys module can be reference from iex using :sys

The the log commands require atoms.

:sys.log(Frequency, :print)

:sys.log(Frequency, :get)

Now at hash: 830c1ea

Chapter 6

This is an odd chapter for Elixir as the Finite State Machine was considered defective and was not adapted as a wrapper. I am going to skip this chapter


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK