Maybe You can do like this?
# Maybe there is a typo in your module name :slight_smile:
defmodule AppName.on.Worker do
use GenServer
# THIS IS API
def start_link do
# receives the message as argument
GenServer.start_link/3
end
def some_task, do: GenServer.call ...
# THIS IS SERVER SIDE
def init/1 do
send self(), {:check_args, message_from_mqtt_as_map}
{:ok, state}
end
# Wherever You need it...
def handle_call(:some_task, _from, _state) do
perform_some_task()
end
def handle_info({:check_args, message_from_mqtt_as_map}, state) do
case message_from_mqtt_as_map["action"] do
:create ->
do_create(message_from_mqtt_as_map)
perform_some_task()
...
end
{:noreply, state}
end
# helper functions for the task
defp perform_some_task, do: ...
end
BTW Why do You need to do this
send self(), :some_task
instead of a simple function call?






















