suitepad-gmbh/pipette

Need to use an IP for starting a Recipe using the client

Closed this issue · 3 comments

The client methods push and call currently taking a value and wrapping it inside an IP, also if the value already is an IP. In case of call, the reply_to: field is set an the new IP as well.

@Overbryd Instead of changing the signatures of the client functions, what do you think about removing the IP.update function and have the IP.new function take care of updating as well, depending on the input. The signature of IP.new would then look like this:

IP.new(%IP{} = ip, {route, value}) when is_atom(route)
IP.new(%IP{} = ip, opts) when is_list(opts)
IP.new(%IP{} = ip, value)
IP.new(%IP{} = ip, {route, value}, opts) when is_atom(route) && is_list(opts)
IP.new(%IP{} = ip, value, opts) when is_list(opts)
IP.new({route, value}) when is_atom(route)
IP.new(value)
IP.new({route, value}, opts) when is_atom(route) && is_list(opts)
IP.new(value, opts) when is_list(opts)

I think we can extend Pipette.Client to accept two different inputs on push/3 for example:

  def push(pid, %IP{} = ip, opts \\ []) do
    GenServer.call(pid, {:push, ip, opts})
  end

  def push(pid, value, opts \\ []) do
    GenServer.call(pid, {:push, IP.new(value), opts})
  end

And about changing IP.new to also handle IP.update, I would argue to keep the method signature of IP.new and IP.update small and separate.

It might be much easier to comprehend and read the documentation when those are two separate functions on IP.

Other elements in Elixir handle it the same way, so that Map.new and Map.put are distinct.

👍