pinterest / riffed

Provides idiomatic Elixir bindings for Apache Thrift
Apache License 2.0
308 stars 37 forks source link

GenServer.call's timeout needs to be customizable #40

Open fire opened 7 years ago

fire commented 7 years ago

https://github.com/pinterest/riffed/blob/v_1_5_0/lib/riffed/client.ex#L98

fire commented 7 years ago

In my build the default 5000 ms is being triggered. https://travis-ci.org/fire/snappyex/builds/166231012

See https://gist.github.com/henrik/ceede9c4d9bf3fcb4dd5

scohen commented 7 years ago

So, I think we're painted into a bit of a corner; I don't know how to add this easily without making different functions with different names.

predrag-rakic commented 7 years ago

We added this function in our fork:

  def unquote(function_name)(options, unquote_splicing(arg_list))
    when is_list(options) do

      timeout = Keyword.get(options, :timeout) || 5000
      client  = Keyword.get(options, :client) || __MODULE__

      unquote_splicing(casts)

      rv = GenServer.call(client, {unquote(function_name), unquote(list_args)}, timeout)
      unquote(struct_module).to_elixir(rv, unquote(reply_meta))
  end