1 hour dive into            Erlang/OTP@jvalduvieco            @jordillonch
Problem domain
Lots of users
Lots of users
24x7x365
24x7x365
Lots of critical concurrent       transactions
Lots of critical concurrent       transactions
Hardware or software      breaks
Hardware or software      breaks
Lots of code changes
Lots of code changes
UnscalableUnmaintainable   }   code
UnscalableUnmaintainable   }   code
Maintenance/Debug        inproduction system
Maintenance/Debug        inproduction system
Does it sound to you?
The Erlang solution
Simplicity...
Minimize defensive  programming
Typeless variables
Develop by contract
t-shirt function      size  If
 a
 function
 does
 not
 fit
 on
 your
 t-shirt
 it
 is
 too
 long!
Single responsibility      principle
No shared statebetween entities
High Concurrency
High ConcurrencyHigh concurrency
Light threads
Light threads    hundreds of thousands of threads in one      machine with a good cpu scheduler
Light threads    hundreds of thousands of threads in one      machine with a good cpu scheduler    Lt                     ...
Message passing     Lt                  Lt             Lt
Message passing        A shared nothing architecture that      communicates through message passing     Lt                ...
Message passing        A shared nothing architecture that      communicates through message passing     Lt                ...
Process Mailbox     Lt                  Lt             Lt
Process Mailbox     Every process has a mailbox with incoming       messages, process take on convenience     Lt          ...
No shared state       Lt   S                     Lt                          S                Lt            S
No shared state    Every process its own internal state stored in         a variable avoiding lock contention       Lt   S...
Soft realtime
Soft realtimeYou have no strict guarantees onlatency but language is designed      to have low latency
High availability
High availability High availability
Supervised processes       Pa                       Pb
Supervised processes     processes can be monitored by other      processes, handling its termination       Pa            ...
Fail early                  Pa             Pb              S
Fail early Fail as soon as possible and let someonehandle bad data, someone will restart you                              ...
Fail early Fail as soon as possible and let someonehandle bad data, someone will restart you                              ...
Hot code updatePb          Pa v1              S     Pc
Hot code update     processes code and data can be replaced             without loosing servicePb                   Pa v1 ...
Hot code update     processes code and data can be replaced             without loosing servicePb                   Pa v1 ...
DistributionNode            NodeP      P        P      PP      P        P      PP      P        P      P
DistributionProcesses run on nodes and can be located            wherever they areNode                        NodeP      P...
How does it look like?
Show me the code!
Demo 1
Hands on
The shell
Type on your console:        erl
You should see:Erlang R16B (erts-5.10.1) [source] [64-bit][smp:2:2] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]...
Variables
Variables start Uppercase
Variables are immutable
Can contain any type
You can do things like...
1 Foo = 1.12 Foo = 2.** exception error: no match of right handside value 2
Foo
 is
 bounded
 to
 11 Foo = 1.12 Foo = 2.** exception error: no match of right handside value 2
Foo
 is
 bounded
 to
 11 Foo = 1.1          Foo
 ==
 2
 ?2 Foo = 2.** exception error: no match of right handside value 2
1 Foo = 1.12 Bar = 2.23 Foo = Bar.** exception error: no match of righthand side value 2
This is GREAT!
Now you have yourbasic error checkingsystem implemented
Advanced types
[List]
[1,2,3,4,5,6]
You can do things like...
Iterate sequentially
1 MyList = [1,2,3,4].[1,2,3,4]2 [Head|Tail] = MyList.[1,2,3,4]3 Head.14 Tail.[2,3,4]
1 MyList = [1,2,3,4].[1,2,3,4]2 [Head|Tail] = MyList.[1,2,3,4]3 Head.14 Tail.[2,3,4]
1 MyList = [1,2,3,4].[1,2,3,4]2 [Head|Tail] = MyList.[1,2,3,4]3 Head.14 Tail.[2,3,4]
Do something to all or some items on a list(list comprehensions)
1 MyList = [1, 2, 3, 4].[1,2,3,4]2 [X + 2 || X - MyList, X  2].[5,6]
[Strings]
A list
You can do things like...
1 MyString = Erlang is not Ruby.Erlang is not Ruby
1 MyString = Erlang is not Ruby.Erlang is not Ruby2 [Head2|Tail2] = MyString.Erlang is not Ruby3 Head2.69 ASC
 =
 “E”4 Tail2.rlang is not Ruby
{Tuples}
{1,2,3}
Basic data container
random access
matcheable
You can do things like...
1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.13 B = 2.24 {A,B,C,D} = {1,2,3,4}.{1,2,3,4}5 C.36 D.4
1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.1         A
 and
 B
 are3 B = 2. bounded
 variables24 {A,B,C,D} = {1,2,3,4}.{1,2,3,4}5 C.36 D.4
1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.1         A
 and
 B
 are3 B = 2. bounded
 variables24 {A,B,C,D} = {1,2,3,4}.{1,2,3,4}5 C. pattern
 matching3                                           A==1?6 D.                              B==2?4
1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.1         A
 and
 B
 are3 B = 2. bounded
 variables24 {A,B,C,D} = {1,2,3,4}.                                                                                       ...
 and
 D
 are
 {1,2,3,4}                                                                                                                ...
 5 C. pattern
 matching                                                                                                                 ...
functions
functions are types
single exit point
You can do things like...
foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.
This
 is
 a
 arity
 2
 function
                                               (2
 parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.
This
 is
 a
 arity
 2
 function
                                                                         (2
 parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.                  means
 that
 more
                   code
 is
 to
 come
This
 is
 a
 arity
 2
 function
                                                                         (2
 parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.                  means
 that
 more
                   code
 is
 to
 come                                                                                                                     ...
 the
 function
                                                                                                                          ...
 has
 ended
This
 is
 a
 arity
 2
 function
                                                                                                  (2
 parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.                                                          ...
 more
Upcoming SlideShare
Loading in...5
×

1 hour dive into Erlang/OTP

8,416

Published on

Introduction to Erlang and OTP

Published in: Technology
2 Comments
6 Likes
Statistics
Notes
No Downloads
Views
Total Views
8,416
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
31
Comments
2
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "1 hour dive into Erlang/OTP"

  1. 1. 1 hour dive into Erlang/OTP@jvalduvieco @jordillonch
  2. 2. Problem domain
  3. 3. Lots of users
  4. 4. Lots of users
  5. 5. 24x7x365
  6. 6. 24x7x365
  7. 7. Lots of critical concurrent transactions
  8. 8. Lots of critical concurrent transactions
  9. 9. Hardware or software breaks
  10. 10. Hardware or software breaks
  11. 11. Lots of code changes
  12. 12. Lots of code changes
  13. 13. UnscalableUnmaintainable } code
  14. 14. UnscalableUnmaintainable } code
  15. 15. Maintenance/Debug inproduction system
  16. 16. Maintenance/Debug inproduction system
  17. 17. Does it sound to you?
  18. 18. The Erlang solution
  19. 19. Simplicity...
  20. 20. Minimize defensive programming
  21. 21. Typeless variables
  22. 22. Develop by contract
  23. 23. t-shirt function size If
  24. 24.  a
  25. 25.  function
  26. 26.  does
  27. 27.  not
  28. 28.  fit
  29. 29.  on
  30. 30.  your
  31. 31.  t-shirt
  32. 32.  it
  33. 33.  is
  34. 34.  too
  35. 35.  long!
  36. 36. Single responsibility principle
  37. 37. No shared statebetween entities
  38. 38. High Concurrency
  39. 39. High ConcurrencyHigh concurrency
  40. 40. Light threads
  41. 41. Light threads hundreds of thousands of threads in one machine with a good cpu scheduler
  42. 42. Light threads hundreds of thousands of threads in one machine with a good cpu scheduler Lt Lt Lt
  43. 43. Message passing Lt Lt Lt
  44. 44. Message passing A shared nothing architecture that communicates through message passing Lt Lt Lt
  45. 45. Message passing A shared nothing architecture that communicates through message passing Lt Lt Lt
  46. 46. Process Mailbox Lt Lt Lt
  47. 47. Process Mailbox Every process has a mailbox with incoming messages, process take on convenience Lt Lt Lt
  48. 48. No shared state Lt S Lt S Lt S
  49. 49. No shared state Every process its own internal state stored in a variable avoiding lock contention Lt S Lt S Lt S
  50. 50. Soft realtime
  51. 51. Soft realtimeYou have no strict guarantees onlatency but language is designed to have low latency
  52. 52. High availability
  53. 53. High availability High availability
  54. 54. Supervised processes Pa Pb
  55. 55. Supervised processes processes can be monitored by other processes, handling its termination Pa Pb
  56. 56. Fail early Pa Pb S
  57. 57. Fail early Fail as soon as possible and let someonehandle bad data, someone will restart you Pa Pb S
  58. 58. Fail early Fail as soon as possible and let someonehandle bad data, someone will restart you Pa Pb2 S
  59. 59. Hot code updatePb Pa v1 S Pc
  60. 60. Hot code update processes code and data can be replaced without loosing servicePb Pa v1 S Pc
  61. 61. Hot code update processes code and data can be replaced without loosing servicePb Pa v1 v2 S Pc
  62. 62. DistributionNode NodeP P P PP P P PP P P P
  63. 63. DistributionProcesses run on nodes and can be located wherever they areNode NodeP P P PP P P PP P P P
  64. 64. How does it look like?
  65. 65. Show me the code!
  66. 66. Demo 1
  67. 67. Hands on
  68. 68. The shell
  69. 69. Type on your console: erl
  70. 70. You should see:Erlang R16B (erts-5.10.1) [source] [64-bit][smp:2:2] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]Eshell V5.10.1 (abort with ^G)1
  71. 71. Variables
  72. 72. Variables start Uppercase
  73. 73. Variables are immutable
  74. 74. Can contain any type
  75. 75. You can do things like...
  76. 76. 1 Foo = 1.12 Foo = 2.** exception error: no match of right handside value 2
  77. 77. Foo
  78. 78.  is
  79. 79.  bounded
  80. 80.  to
  81. 81.  11 Foo = 1.12 Foo = 2.** exception error: no match of right handside value 2
  82. 82. Foo
  83. 83.  is
  84. 84.  bounded
  85. 85.  to
  86. 86.  11 Foo = 1.1 Foo
  87. 87.  ==
  88. 88.  2
  89. 89.  ?2 Foo = 2.** exception error: no match of right handside value 2
  90. 90. 1 Foo = 1.12 Bar = 2.23 Foo = Bar.** exception error: no match of righthand side value 2
  91. 91. This is GREAT!
  92. 92. Now you have yourbasic error checkingsystem implemented
  93. 93. Advanced types
  94. 94. [List]
  95. 95. [1,2,3,4,5,6]
  96. 96. You can do things like...
  97. 97. Iterate sequentially
  98. 98. 1 MyList = [1,2,3,4].[1,2,3,4]2 [Head|Tail] = MyList.[1,2,3,4]3 Head.14 Tail.[2,3,4]
  99. 99. 1 MyList = [1,2,3,4].[1,2,3,4]2 [Head|Tail] = MyList.[1,2,3,4]3 Head.14 Tail.[2,3,4]
  100. 100. 1 MyList = [1,2,3,4].[1,2,3,4]2 [Head|Tail] = MyList.[1,2,3,4]3 Head.14 Tail.[2,3,4]
  101. 101. Do something to all or some items on a list(list comprehensions)
  102. 102. 1 MyList = [1, 2, 3, 4].[1,2,3,4]2 [X + 2 || X - MyList, X 2].[5,6]
  103. 103. [Strings]
  104. 104. A list
  105. 105. You can do things like...
  106. 106. 1 MyString = Erlang is not Ruby.Erlang is not Ruby
  107. 107. 1 MyString = Erlang is not Ruby.Erlang is not Ruby2 [Head2|Tail2] = MyString.Erlang is not Ruby3 Head2.69 ASC
  108. 108.  =
  109. 109.  “E”4 Tail2.rlang is not Ruby
  110. 110. {Tuples}
  111. 111. {1,2,3}
  112. 112. Basic data container
  113. 113. random access
  114. 114. matcheable
  115. 115. You can do things like...
  116. 116. 1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.13 B = 2.24 {A,B,C,D} = {1,2,3,4}.{1,2,3,4}5 C.36 D.4
  117. 117. 1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.1 A
  118. 118.  and
  119. 119.  B
  120. 120.  are3 B = 2. bounded
  121. 121.  variables24 {A,B,C,D} = {1,2,3,4}.{1,2,3,4}5 C.36 D.4
  122. 122. 1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.1 A
  123. 123.  and
  124. 124.  B
  125. 125.  are3 B = 2. bounded
  126. 126.  variables24 {A,B,C,D} = {1,2,3,4}.{1,2,3,4}5 C. pattern
  127. 127.  matching3 A==1?6 D. B==2?4
  128. 128. 1 Mytuple = {1,2,3,4}.{1,2,3,4}2 A = 1.1 A
  129. 129.  and
  130. 130.  B
  131. 131.  are3 B = 2. bounded
  132. 132.  variables24 {A,B,C,D} = {1,2,3,4}. C
  133. 133.  and
  134. 134.  D
  135. 135.  are
  136. 136.  {1,2,3,4} unbounded
  137. 137.  5 C. pattern
  138. 138.  matching variables3 A==1?6 D. B==2?4
  139. 139. functions
  140. 140. functions are types
  141. 141. single exit point
  142. 142. You can do things like...
  143. 143. foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.
  144. 144. This
  145. 145.  is
  146. 146.  a
  147. 147.  arity
  148. 148.  2
  149. 149.  function
  150. 150.   (2
  151. 151.  parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result.
  152. 152. This
  153. 153.  is
  154. 154.  a
  155. 155.  arity
  156. 156.  2
  157. 157.  function
  158. 158.   (2
  159. 159.  parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result. means
  160. 160.  that
  161. 161.  more
  162. 162.   code
  163. 163.  is
  164. 164.  to
  165. 165.  come
  166. 166. This
  167. 167.  is
  168. 168.  a
  169. 169.  arity
  170. 170.  2
  171. 171.  function
  172. 172.   (2
  173. 173.  parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result. means
  174. 174.  that
  175. 175.  more
  176. 176.   code
  177. 177.  is
  178. 178.  to
  179. 179.  come means
  180. 180.  the
  181. 181.  function
  182. 182.   code
  183. 183.  has
  184. 184.  ended
  185. 185. This
  186. 186.  is
  187. 187.  a
  188. 188.  arity
  189. 189.  2
  190. 190.  function
  191. 191.   (2
  192. 192.  parameters)foo_bar_func(Foo, Bar) - Result = Foo + Bar, Result. means
  193. 193.  that
  194. 194.  more
  195. 195.   code
  196. 196.  is
  197. 197.  to
  198. 198.  comeSingle
  199. 199.  exit
  200. 200.  pointReturns
  201. 201.  Result means
  202. 202.  the
  203. 203.  function
  204. 204.   code
  205. 205.  has
  206. 206.  ended
  207. 207. 1 FooBar = fun(Foo, Bar) -1 Foo + Bar1 end.#Funerl_eval.12.829309122 Result = FooBar(1, 2).3
  208. 208. atoms
  209. 209. A constant with name
  210. 210. lowercase
  211. 211. You can do things like...
  212. 212. 1 ok.ok2 ko.ko3 ok =:= ko.false4 ok =:= ok.true
  213. 213. 1 MyFuncOK = fun() - {ok, 33} end.#Funerl_eval.20.829309122 MyFuncFail = fun() - {error, bad_arg} end.#Funerl_eval.20.829309123 {ok, Result} = MyFuncOK().{ok,33}4 {ok, Result2} = MyFuncFail().** exception error: no match of right handside value {error,bad_arg}
  214. 214. atoms1 MyFuncOK = fun() - {ok, 33} end.#Funerl_eval.20.829309122 MyFuncFail = fun() - {error, bad_arg} end.#Funerl_eval.20.829309123 {ok, Result} = MyFuncOK().{ok,33}4 {ok, Result2} = MyFuncFail().** exception error: no match of right handside value {error,bad_arg}
  215. 215. atoms1 MyFuncOK = fun() - {ok, 33} end.#Funerl_eval.20.829309122 MyFuncFail = fun() - {error, bad_arg} end.#Funerl_eval.20.82930912 }3 {ok, Result} = MyFuncOK().{ok,33} error4 {ok, Result2} = MyFuncFail(). checking** exception error: no match of right handside value {error,bad_arg}
  216. 216. atoms1 MyFuncOK = fun() - {ok, 33} end.#Funerl_eval.20.829309122 MyFuncFail = fun() - {error, bad_arg} end.#Funerl_eval.20.82930912 }3 {ok, Result} = MyFuncOK().{ok,33} error4 {ok, Result2} = MyFuncFail(). checking** exception error: no match of right handside value {error,bad_arg} do
  217. 217.  they
  218. 218.  match?
  219. 219. modules
  220. 220. basic name spacing
  221. 221. public/private functions
  222. 222. You can do things like...
  223. 223. On your ${EDITOR} create cool_func.erl-module(cool_func).-export([foo_bar_func/2]).foo_bar_func (Foo, Bar) - Result = Foo + Bar, {ok, Result}.
  224. 224. On erlang shell type:1 c(cool_module).{ok,cool_module}2 {ok, Result3} = cool_module:sum(33, 44).{ok,77}3 Result3.77
  225. 225. Too easy? Let’s add some patternmatching on parameters!
  226. 226. area({square, Side}) - {ok,Side * Side};area({circle, Radius}) - % almost :-) {ok, 3 * Radius * Radius};area({triangle, A, B, C}) - S = (A + B + C)/2, {ok, math:sqrt(S*(S-A)*(S-B)*(S-C))};area(Other) - {error, invalid_object}.
  227. 227. area({square, Side}) - {ok,Side * Side}; means
  228. 228.  that
  229. 229.  there
  230. 230.  is
  231. 231.  area({circle, Radius}) - another
  232. 232.  matching
  233. 233.   % almost :-) posibility {ok, 3 * Radius * Radius};area({triangle, A, B, C}) - S = (A + B + C)/2, {ok, math:sqrt(S*(S-A)*(S-B)*(S-C))};area(Other) - {error, invalid_object}.
  234. 234. area({square, Side}) - {ok,Side * Side}; means
  235. 235.  that
  236. 236.  there
  237. 237.  is
  238. 238.  area({circle, Radius}) - another
  239. 239.  matching
  240. 240.   % almost :-) posibility {ok, 3 * Radius * Radius};area({triangle, A, B, C}) - S = (A + B + C)/2, {ok, math:sqrt(S*(S-A)*(S-B)*(S-C))};area(Other) - {error, invalid_object}.mymodule:area({square, 10}).mymodule:area({circle, 10}).mymodule:area({triangle, 2, 2, 3.5}).
  241. 241. Want more?Let’s add some recursion!
  242. 242. Want more?Let’s add some recursion! Erlang does not use loops
  243. 243. factorial(0) - 1;factorial(N) - N * factorial(N-1).
  244. 244. OTP
  245. 245. Oh, This is Perfect!
  246. 246. OTP is a set of rock solid architecture patterns, practices and tools
  247. 247. Improves the design, fault tolerance anddeployment of your app
  248. 248. Erlang is just a language,OTP makes it great for the real world
  249. 249. Basic architecture patterns
  250. 250. Supervisor SP P P S P P
  251. 251. Supervisor SP P P S P P
  252. 252. Supervisor spawns processes and handles its death
  253. 253. gen_serverPP gsP
  254. 254. gen_serverPP gsP
  255. 255. Generic single threaded server
  256. 256. gen_fsmPP gf{S}P
  257. 257. gen_fsmPP gf{S}P
  258. 258. Generic Finite State Machine
  259. 259. gen_event PP P emP P P
  260. 260. gen_event PP P emP P P
  261. 261. Event handler, you can subscribe to events
  262. 262. More on OTP...• File hierarchy• Applications• Releases• Basic abstraction libraries (logging, system...)
  263. 263. Let’s see a gen_server in action!
  264. 264. IntroducingSimple Key Value Store
  265. 265. A server that is able to store {Key,Value} and retrieve them by Key
  266. 266. Demo II
  267. 267. skvs diagram SP gs ets
  268. 268. skvs diagram SP gs ets
  269. 269. Starting skvsGo to skvs source directoryCompile./rebar compileStart the Erlang nodeerl -pa ebinStart the appapplication:start(skvs).
  270. 270. Some commandsSet a value skvs_server:set(“Key”,”Value”). skvs_server:set(“Key2”,”Value2”).Get a value skvs_server:get(“Key2”).
  271. 271. Code on client: skvs_server.erlstart_link() - gen_server:start_link({local, skvs},skvs_server, [], []).get(Key) - gen_server:call(skvs, {get, Key}).set(Key,Value) - gen_server:call(skvs, {set, Key, Value}).set_fire_and_forget(Key,Value) - gen_server:cast(skvs, {set, Key, Value}).
  272. 272. Code on client: skvs_server.erl start
  273. 273.  gen_serverstart_link() - gen_server:start_link({local, skvs},skvs_server, [], []).get(Key) - gen_server:call(skvs, {get, Key}).set(Key,Value) - gen_server:call(skvs, {set, Key, Value}).set_fire_and_forget(Key,Value) - gen_server:cast(skvs, {set, Key, Value}).
  274. 274. Code on client: skvs_server.erl start
  275. 275.  gen_serverstart_link() - gen_server:start_link({local, skvs},skvs_server, [], []).get(Key) - gen_server:call(skvs, {get, Key}). sync
  276. 276.  call
  277. 277.  to
  278. 278.  serverset(Key,Value) - (waits
  279. 279.  for
  280. 280.  reply) gen_server:call(skvs, {set, Key, Value}).set_fire_and_forget(Key,Value) - gen_server:cast(skvs, {set, Key, Value}).
  281. 281. Code on client: skvs_server.erl start
  282. 282.  gen_serverstart_link() - gen_server:start_link({local, skvs},skvs_server, [], []).get(Key) - gen_server:call(skvs, {get, Key}). sync
  283. 283.  call
  284. 284.  to
  285. 285.  serverset(Key,Value) - (waits
  286. 286.  for
  287. 287.  reply) gen_server:call(skvs, {set, Key, Value}).set_fire_and_forget(Key,Value) - gen_server:cast(skvs, {set, Key, Value}). async
  288. 288.  call
  289. 289.  to
  290. 290.  server (fire
  291. 291.  
  292. 292.  forget)
  293. 293. Callback code: skvs_server.erl%% Client Callbacks on server%% Sync calls, expects responsehandle_call({set, Key, Value}, _From,State) - {reply, set_value(Key,Value), State};handle_call({get, Key}, _From, State) - {reply, get_value(Key), State}.%% Async calls, do not expect responsehandle_cast({set, Key, Value}, State) - set_value(Key,Value), {noreply, State}.
  294. 294. Callback code: skvs_server.erl%% Client Callbacks on server%% Sync calls, expects responsehandle_call({set, Key, Value}, _From,State) - {reply, set_value(Key,Value), State};handle_call({get, Key}, _From, State) - {reply, get_value(Key), State}.%% Async calls, do not expect responsehandle_cast({set, Key, Value}, State) - set_value(Key,Value), {noreply, State}. return
  295. 295.  value
  296. 296. Callback code: skvs_server.erl%% Client Callbacks on server%% Sync calls, expects responsehandle_call({set, Key, Value}, _From,State) - {reply, set_value(Key,Value), State};handle_call({get, Key}, _From, State) - {reply, get_value(Key), State}.%% Async calls, do not expect responsehandle_cast({set, Key, Value}, State) - set_value(Key,Value), {noreply, State}. Survives
  297. 297.  between
  298. 298.   return
  299. 299.  value requests
  300. 300. Actual work...: skvs_server.erl%% Private functionsset_value(Key, Value) - % Insert Key, Value into ETS. % Fail early {ok,Result}=case ets:insert(data_store,{Key,Value}) of true - {ok, {Key,Value}}; {error, Reason} - {error, Reason} end, Result.
  301. 301. Actual work...: skvs_server.erl%% Private functionsset_value(Key, Value) - % Insert Key, Value into ETS. % Fail early {ok,Result}=case ets:insert(data_store,{Key,Value}) of true - {ok, {Key,Value}}; {error, Reason} - {error, Reason} end, ETS
  302. 302.  is
  303. 303.  a
  304. 304.  Key
  305. 305.  value
  306. 306.  store
  307. 307.   Result. in
  308. 308.  RAM
  309. 309. Use cases
  310. 310. Gaming Industry
  311. 311. Gaming Industry
  312. 312. Messaging / IM
  313. 313. Messaging / IM
  314. 314. Payments
  315. 315. Payments
  316. 316. Databases
  317. 317. Databases
  318. 318. Others
  319. 319. Others
  320. 320. Some day...
  321. 321. Every highly interactive website? ;)
  322. 322. Pay Hello Ouch! Every highly interactive website? ;) Would you... HeyNO! ! Hi Buf
  323. 323. Internet of things
  324. 324. And now what?
  325. 325. Install Erlang/OTP!https://www.erlang-solutions.com/downloads/download-erlang-otp
  326. 326. Use a great IDE• IntelliJ + Erlang (plugin)• Sublime Text + SublimErl• Emacs
  327. 327. Read some books
  328. 328. RTFM• http://www.erlang.org/doc.html• http://erldocs.com/
  329. 329. Join mailing lists• Official Erlang mailing list • http://erlang.org/mailman/listinfo/erlang- questions• Join Barcelona Erlang user group on google groups
  330. 330. Find know-how• Check http://www.erlang-factory.com/ videos• Search for Erlang conferences on slideshare• Pray for an http://erlangcamp.com/ near your city
  331. 331. Read some code
  332. 332. This is the result of 6 months of fun learning Erlang/OTP
  333. 333. We are looking for awesome projects http://es.linkedin.com/in/jvalduvieco http://es.linkedin.com/in/jllonch
  334. 334. Thank you!https://github.com/jvalduvieco/betabeers_201303
  335. 335. Thank you! https://github.com/jvalduvieco/betabeers_201303we
  336. 336.  hope
  337. 337.  you
  338. 338.  feel
  339. 339.   like
  340. 340.  him
  341. 341.  :) (we
  342. 342.  did)
  343. 343. Erlang, The Moviehttp://www.youtube.com/watch?v=uKfKtXYLG78
  344. 344. Images sourceshttp://diromero.wordpress.com/2011/10/07/home-automation/http://iffergan.com/http://technode.com/2012/05/14/internet-of-things-not-just-a-concept-for-fund-raising/http://modernherstory.wordpress.com/2011/05/18/open-minds-open-hearts/http://www.i-m.co/eviemouse/problemsolved/http://strategicsalesmarketingosmg.wordpress.com/2012/06/25/who-are-twitter-users/http://www.secureworks.com/it_security_services/advantage/soc/http://labourlist.org/2011/11/my-biggest-worry-about-labour%E2%80%99s-future/broken-chain/http://prothemedesign.com/how-to/why-you-should-keep-wordpress-and-your-plugins-up-to-date/attachment/matrix-code-update/http://thegapbetweentwoworlds.com/category/career-transitionhttp://www.wingweb.co.uk/Images/697/KC-10_Extender_SR-71_Blackbirdhttp://www.tonywoodtraining.com/2010/11/29/motivation-to-exercise-and-eat-right/http://portalmie.com/blog/6/2011/09/kushimoto-diving-park-tokushima-revista-no-7/http://www.bcsagroup.com/http://www.losemyaccent.com/tag/hand/http://articulo.mercadolibre.com.ar/MLA-450970296-cortaplumas-victorinox-huntsman-15-usos-navaja-origen-suizo-_JMhttp://openclipart.org/detail/4112/http://blog-en.coaching-go.com/2012/02/learn-to-say-no-and-know-how-to-say-yes/ok-2/http://en.wikipedia.org/wiki/File:We_Can_Do_It!.jpghttp://triniblog.wordpress.com/tag/laberintos/http://www.catskillsnyrealestate.com/Want-More-Info-Catskill-Real-Estate.phphttp://www.thelovelyplanet.net/lush-green-images-planet-earth/http://www.growthmax.com/how-exactly-does-growthmax-plus-make-you-grow-taller/http://www.ayurvedalive.in/keep-your-eyes-healthy-beautifulhttp://my.mmosite.com/510619/blog/item/lord_of_the_rings_online.htmlhttp://scifistorm.org/2010/03/24/lord-of-the-rings-blu-ray-review/http://www.123rf.com/photo_15612022_3d-cartoon-bug.htmlhttp://www.airliners.net/photo/1134244/L/http://www.muypymes.com/2009/12/04/moleskine-mucho-mas-que-una-agenda-personalhttp://learnyousomeerlang.com/the-hitchhikers-guide-to-concurrencyhttp://planetpooks.com/one-more-reason-to-love-hermiones-handbag/

×