lib/sensu/server/mutate.rb
# Create a mutator callback (Proc). A mutator callback takes two
# parameters, for the mutator output and status code. The
# created callback can be used for standard mutators and mutator
# extensions. The provided callback will only be called when the
# mutator status is `0` (OK). If the status is not `0`, an error
# is logged, and the `@in_progress[:events]` is decremented by
# `1`.
#
# @param mutator [Object] definition or extension.
# @param event [Hash] data.
# @param callback [Proc] to call when the mutator status is `0`.
# @return [Proc] mutator callback.
Create a mutator callback (Proc). A mutator callback takes two
parameters, for the mutator output and status code. The
created callback can be used for standard mutators and mutator
extensions. The provided callback will only be called when the
mutator status is `0` (OK).
Create a mutator callback ( Proc ) . A mutator callback takes two parameters for the mutator output and status code . The created callback can be used for standard mutators and mutator extensions . The provided callback will only be called when the mutator status is ` 0 ` ( OK ) .
def mutator_callback(mutator, event, &callback)
        Proc.new do |output, status|
          if status == 0
            callback.call(output)
          else
            definition = mutator.is_a?(Hash) ? mutator : mutator.definition
            @logger.error("mutator error", {
              :mutator => definition,
              :event => event,
              :output => output,
              :status => status
            })
            @in_progress[:events] -= 1 if @in_progress
          end
        end
      end
def mutator_callback ( mutator , event , & callback ) Proc . new do | output , status | if status == 0 callback . call ( output ) else definition = mutator . is_a? ( Hash ) ? mutator : mutator . definition @logger . error ( "mutator error" , { :mutator => definition , :event => event , :output => output , :status => status } ) @in_progress [ :events ] -= 1 if @in_progress end end end
Create a mutator callback (Proc).
Create a mutator callback ( Proc ) .
None
Proc
mutator
definition or extension.
definition or extension .
event
None
callback
to call when the mutator status is `0`.
to call when the mutator status is ` 0 ` .