anchor.diff:  %%% Internal functions
   %%%===================================================================
   
  +% internal receive-loop that handles all potentially 'long' running
  +% tasks of the 'finder' so that the main metrics finder service is
  +% as responsive as possible
  +% the processing loop asynchronously maintains the main metrics data
  +% structure and reports back to the parent server with the results
   processor_loop(Parent) ->
       lager:info("spawning asynchronous finder processor at ~p", [self()]),
       processor_loop(Parent, ?EMPTY_METRIC_DIR, 0).
   
   processor_loop(Parent, Metrics, Count) ->
       receive
  +        % register new metrics handler
           {register_handler, Metric, Paths} ->
               NewMetrics = update_or_insert_metric(Paths, Metric, Metrics),
               Parent ! {finder_result, NewMetrics},
   
               processor_loop(Parent, NewMetrics, Count);
   
  +        % search local file system for metrics files and integrate
  +        % those in the metrics data structure
           {update_metrics, Dir} ->
               {NewMetrics, NewCount} = update_metrics_files(Dir, Count),
               Merged = merge_metric_dir(Metrics, NewMetrics),
  
positive.code:             lager:error("unexpected message in finder processor: ~p", [Unhandled]),
              error
      end.
  
  
  % before sending our local metrics structure we want to
  
negative.code:     Dir#metric_dir{metrics=Ms0, dirs=Ds0}.
  
  
  % this function is used on node disconnect/removal
  % so that all metrics that reference that specific remote node
  % are removed from the metrics structure
  remove_remotes(Remote, #metric_dir{metrics=Metrics, dirs=Dirs}=Dir) ->
      Ms0 = orddict:fold(fun(K, V, Ms) ->
                                 case V#metric_file.handler of
  