Module: Kinetic::DSL

Includes:
Configuration, Serialization, TimedEvents
Included in:
Base
Defined in:
lib/kinetic/dsl.rb,
lib/kinetic/dsl/timed_events.rb,
lib/kinetic/dsl/configuration.rb,
lib/kinetic/dsl/serialization.rb

Defined Under Namespace

Modules: Configuration, Serialization, TimedEvents

Instance Method Summary collapse

Methods included from Serialization

#deserialize

Methods included from TimedEvents

#timed_event

Methods included from Configuration

#config, #config_file, #set

Instance Method Details

#after_fork(&block) ⇒ Object



12
13
14
15
# File 'lib/kinetic/dsl.rb', line 12

def after_fork(&block)
  raise Kinetic::Errors::BlockMissing unless block_given?
  after_fork_procs << block
end

#loggerLogger

Returns the application logger instance

Returns:

  • (Logger)

    returns the application logger instance



37
38
39
# File 'lib/kinetic/dsl.rb', line 37

def logger
  @logger ||= config[:logging] ? reopen_logger : Logger.new('/dev/null')
end

#on_direct(key) {|message| ... } ⇒ Object Also known as: on

Defines a direct queue subscription. Direct queues do not allow fuzzy matching so all messages sent to this queue must exactly match the key.

Parameters:

  • key (String)

    the key of the queue to which to subscribe.

Yields:

  • (message)

    yields the message passed to the queue to the block

Raises:



27
28
29
30
31
32
# File 'lib/kinetic/dsl.rb', line 27

def on_direct(key, &block)
  raise Kinetic::Errors::NoSubscriberBlock unless block_given?
  raise Kinetic::Errors::KeyMustBeString   unless key.is_a? String
  logger.debug "Setting up '#{key}' on 'direct'"
  direct[key] = block
end