eiri commented on a change in pull request #474: 3364 fix view compactor
unknown info
URL: https://github.com/apache/couchdb/pull/474#discussion_r111139987
##########
File path: src/couch_index/src/couch_index_compactor.erl
##########
@@ -81,6 +85,14 @@ handle_cast(_Mesg, State) ->
handle_info({'EXIT', Pid, normal}, #st{pid=Pid}=State) ->
{noreply, State#st{pid=undefined}};
+handle_info({'EXIT', Pid, Reason}, #st{pid = Pid} = State) ->
+ #st{idx = Idx, mod = Mod} = State,
+ {ok, IdxState} = gen_server:call(Idx, {compaction_failed, Reason}),
Review comment:
I can unfold my reasoning if it helps.
First, there are nothing inherently wrong with using gen_server's `call`.
Wrapping it into convenience function is not a requirement for its usage and
rides on disputable notion that messages' format got changed more often than
functions' name or signature. In this particular case trading arity 2
gen_server's function for arity 2 couch_index's function gives no convenience
advantages, but exporting `handle_failure` encourages to think about it as a
public method that could be called from more than one place and this is
dangerous, as it could delete compaction file under running compactor.
Second, index_compactor that knows what message to send to index server no
more exposed to its internals than couch_compactor that knows what function to
call, it is just one-to-one trading of tag of the message to the name of the
function. Consider that those are not isolated apps, but two server processes
that share a general task of managing index, an introduction of new ambiguous
method is going to make a task of understanding how couch_index works more
challenging for future curious reader.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services