Académique Documents
Professionnel Documents
Culture Documents
SOCKET.IO-ERLANG
Developed Used
as a base demo app for this presentation to write neat front-ends for conversational websites
Allows
BIZARRO SOCKET.IO-ERLANG
'Bad'
Freely
APP STRUCTURE
APP STRUCTURE
Bunch of supervisors
APP STRUCTURE
Bunch of supervisors
web server
APP STRUCTURE
Bunch of supervisors transport handlers web server
APP STRUCTURE
Client code attaches here web server Bunch of supervisors transport handlers
need a web server (the slide's title says just that (and also the previous slide)) annoying! parameters and a connection around is
Oh, Carrying
Let's
PARAMETRISED MODULES
-module(test_module,
[Param1]). some_method()
->
Param1. Equivalent to: -module(test_non_pmod). some_method(Param1)
->
Param1.
PARAMETRISED MODULES
1> X = test_module:new(horror), X:some_method(). horror 2> test_non_pmod:some_method(sane). sane
PARAMETRISED MODULES
They We
are great!
can use them as if they were objects! let us carry everything as one large parameter! do this!
They
Let's
PARAMETRISED MODULES
They We
are great!
can use them as if they were objects! let us carry everything as one large parameter! do this!
They
Let's
What?
The parameters are global and they ghost values, become implicit function arguments. Errors out of nowhere. They're based on a old fun hack ({Mod, Fun}:(Args)) They mess up the concept of arity They mess up tracing (previous slide!) They were added because some library accepts callback modules and nothing else but might still need state around. No other reason.
Some
of the supervisors are tricky and must interact with servers and dynamic children and ... starts who? By which API?
Who We
could probably just forget about supervisors, link stuff together and make it simpler do this!
Let's
Friday, June 10, 2011
APP STRUCTURE
APP STRUCTURE
transport handlers were moved and no longer need a supervisor. They only use links. The code is more straightforward!
APP STRUCTURE
transport handlers were moved and no longer need a supervisor. They only use links. The code is more straightforward!
What?
... my code is so much easier to read now!
need to add ad-hoc start/restart policies and make sure orderly shutdowns work ne with just links. Care to add tests? can no longer benet from systool's application upgrades and downgrades as they depend on supervisors will need to take your app down!
You
You
You're killing me. I'll leave the change in. Code is meant to be read rst!
Let's
And it works!
(believe me)
Friday, June 10, 2011
And it works!
(believe me)
Friday, June 10, 2011
starts all applications under the Application Controller one outside of it means it is not supervised by it
bad default values (or overly defensive code) for env variables, bad things happen...
In
this case, innitely many web sockets opened for each client
DO THIS INSTEAD
main(_) -> appmon:start(), application:start(sasl), application:start(misultin), application:start(socketio), {ok, Pid} = socketio_listener:start([ {http_port, 7878}, {default_http_handler,?MODULE}]), EventMgr = socketio_listener:event_manager(Pid), ok = gen_event:add_handler(EventMgr, ?MODULE,[]), receive _ -> ok end.
Oh...
RIGHT
Your OTP code is not worth much without that
Friday, June 10, 2011
DON'T LISTEN TO ME
If your product might not ship because of this. Making it work is #1. Making it pretty is not.
Friday, June 10, 2011
HAPPY HACKING
Hopefully you won't regret this
Friday, June 10, 2011