Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace triple nested case with foldl #58

Closed
tank-bohr opened this issue Oct 29, 2019 · 0 comments
Closed

Replace triple nested case with foldl #58

tank-bohr opened this issue Oct 29, 2019 · 0 comments

Comments

@tank-bohr
Copy link
Owner

handle_connection(#state{transport = Transport, socket = Socket, server = Server} = State) ->
case receive_request(State) of
{ok, Request} ->
ok = bookish_spork_server:store_request(Server, Request),
case bookish_spork_server:response(Server) of
{ok, Response} ->
reply(Transport, Socket, Response, Request),
complete_connection(State, Request);
{error, no_response} ->
Transport:close(Socket),
{stop, normal, State}
end;
socket_closed ->
{stop, normal, State}
end.
-spec complete_connection(State, Request) -> {noreply, State} | {stop, normal, State} when
State :: state(),
Request :: bookish_spork_request:t().
%% @private
complete_connection(#state{transport = Transport, socket = Socket} = State, Request) ->
case bookish_spork_request:is_keepalive(Request) of
true ->
handle_connection(),
{noreply, State};
false ->
Transport:shutdown(Socket, read_write),
{stop, normal, State}
end.

See

tank-bohr added a commit that referenced this issue Nov 21, 2019
Also:

- nuke handler supervisor
- get rid of accept timout
- close connection when no bookish_spork response
tank-bohr added a commit that referenced this issue Nov 21, 2019
Also:

- nuke handler supervisor
- get rid of accept timeout
- close connection when no bookish_spork response
tank-bohr added a commit that referenced this issue Nov 21, 2019
Also:

- nuke handler supervisor
- get rid of accept timeout
- close connection when no bookish_spork response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant