A Distributed Video Server
John Kemp, ESPN
Dispatch = [{'_', [{[<<"index.html">>], index_handler, []},
{[<<"player.html">>], player_handler, []},
{'_', new_ws_handler, []}
]}]
websocket_handle({binary, <<"Upload:", Msg/binary>>}, Req, State) ->
lager:debug("Received binary upload command"),
...
websocket_handle({text, <<"Play:", Msg/binary>>}, Req, State) ->
lager:debug("Received text play command"),
...
Which enables...
THIS IS NOT YOUR FATHER'S KV STORE!
-> fill out handle_command/3 and other vnode functions
... "play", "upload"
handle_command({upload, ReqID, Filename, Size}, _Sender, State)
waiting({error, ReqID, Val}, SD0=#state{from=From, num_r=NumR0, replies=Replies0}) ->
...
ok = riak_core:register_vnode_module(lilith_chunkr_vnode),
ok = riak_core_node_watcher:service_up(lilith_chunkr, self()),
lookup( Name, [{Name, Buffer, F, Downloaded} | Tail ], Head) ->
{ok, Buffer, F, Downloaded, Head, Tail};
lookup( Name, [_| Tail], Head) ->
lookup( Name, Tail, Head );
lookup( _, [], _ ) ->
{ok, notfound}.
receive
{ReqID, ok} -> ok;
{ReqID, ok, Val} -> {ok, Val};
{ReqID, error, Val} -> {error, Val}
after Timeout ->
{error, timeout}
end.
14:20:47.307 [debug] Supervisor ranch_sup started ranch_listener_sup:start_link(http, 100,
ranch_tcp, [{port,8080}], cowboy_protocol, [{env,[{dispatch,[{'_',[{[<<"index.html">>],
index_handler,[]},{[<<"player.html">>],player_handler...}...]}]}]}]) at pid <0.144.0>
14:20:47.307 [info] Application lilith started on node 'lilith@127.0.0.1'
Eshell V5.9.3.1 (abort with ^G)
(lilith@127.0.0.1)1>
make devrel
for d in dev/dev*; do $d/bin/lilith start; done
for d in dev/dev*; do $d/bin/lilith ping; done
for d in dev/dev{2,3}; do $d/bin/lilith-admin join lilith1@127.0.0.1; done