inaka / sumo_db

Erlang Persistency Framework
http://inaka.github.io/sumo_db/
Apache License 2.0
174 stars 37 forks source link

Update sumo_store to use wpool:call/4 #327

Open Svampen opened 7 years ago

Svampen commented 7 years ago

sumo_store uses wpool:call/2 which defaults to a 5 second timeout and to work around this when queries can take longer than 5 seconds, substitution of for example sumo:find_by/5 to sumo:call/3 is needed which will use application:get_env(sumo_db, query_timeout) for the timeout value.

I suggest that sumo_store should be updated to use wpool:call/4 and get timeout (and worker strategy?) from configuration file with application:get_env(sumo_db, query_timeout)

Svampen commented 7 years ago

sumo:call can't be used to call any sumo function because the handle_call/3 in sumo_store for {call,...} applies DocName and State on to the Args before doing erlang:apply/3. This results in my example sumo_store_mysql:find_by(Conditions, SortFields, Limit, Offset, DocName, State) instead of sumo_store_mysql:find_by(DocName, Conditions, SortFields, Limit, Offset, State).

sumo:call/3 can only be used for custom functions (which it states), thought I would have thought that the custom function should follow the same structure of having DocName as first argument and State as last :)