Skip to content

Instantly share code, notes, and snippets.

@schmalz
schmalz / my-supervisor.lfe
Created September 11, 2017 11:06
Designing for Scalability with Erlang/OTP - Ch 8 - Coffee Supervisor - Pure LFE
(defmodule my-supervisor
(export
(start 2)
(init 1)
(stop 1)))
(defun start (name child-spec-list)
"Start a supervisor with `name` and `child-spec-list`."
(let ((pid (spawn (MODULE) 'init (list child-spec-list))))
(register name pid)
@schmalz
schmalz / coffee-fsm.lfe
Created September 6, 2017 15:05
Designing for Scalability with Erlang/OTP - Ch 6 - Coffee FSM - LFE + OTP
(defmodule coffee-fsm
(behaviour gen_fsm)
(export
(start-link 0)
(stop 0)
(handle_sync_event 4)
(init 1)
(terminate 3)
(selection 2)
(payment 2)
@schmalz
schmalz / coffee.lfe
Last active September 6, 2017 09:47
Designing for Scalability with Erlang/OTP - Ch 6 - Coffee FSM - Pure LFE
(defmodule coffee
(export
(tea 0)
(espresso 0)
(americano 0)
(cappuccino 0)
(pay 1)
(cup-removed 0)
(cancel 0)
(start_link 0)