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

Set message processing asynchronous #454

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/archethic/p2p/listener_protocol/broadway_pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule Archethic.P2P.ListenerProtocol.BroadwayPipeline do
alias Archethic.P2P.Message
alias Archethic.P2P.MessageEnvelop
alias Archethic.P2P.Client
alias Archethic.TaskSupervisor

alias Broadway.Message, as: BroadwayMessage

Expand Down Expand Up @@ -40,13 +41,16 @@ defmodule Archethic.P2P.ListenerProtocol.BroadwayPipeline do
# start_time = System.monotonic_time(:millisecond)

BroadwayMessage.update_data(message, fn {socket, transport, data} ->
message =
data
|> decode()
|> process()
|> encode()
Task.Supervisor.async_nolink(TaskSupervisor, fn ->
message =
data
|> decode()
|> process()
|> encode()

transport.send(socket, message)
end)

transport.send(socket, message)
# end_time = System.monotnonic_time(:millisecond)
# Logger.debug("Request processed in #{end_time - start_time} ms")
end)
Expand Down