Class: Carnivore::Source::Test

Inherits:
Carnivore::Source show all
Defined in:
lib/carnivore/source/test.rb

Overview

Test source

Constant Summary

RAND_MAX =

Maximum rand value

99999
RAND_DIV =

Default rand divisor

3
RAND_SLEEP =

Sleep length when valid

10

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

This class inherits a constructor from Carnivore::Source

Instance Attribute Details

- (TrueClass, FalseClass) auto_confirm (readonly) Originally defined in class Carnivore::Source

Returns auto confirm received messages

Returns:

  • (TrueClass, FalseClass)

    auto confirm received messages

- (TrueClass, FalseClass) auto_process (readonly) Originally defined in class Carnivore::Source

Returns start source processing on initialization

Returns:

  • (TrueClass, FalseClass)

    start source processing on initialization

- (Carnivore::Supervisor) callback_supervisor (readonly) Originally defined in class Carnivore::Source

Returns supervisor maintaining callback instances

Returns:

- (Array<Callback>) callbacks (readonly) Originally defined in class Carnivore::Source

Returns registered callbacks

Returns:

  • (Array<Callback>)

    registered callbacks

- (Queue) message_loop (readonly) Originally defined in class Carnivore::Source

Returns local loop message queue

Returns:

  • (Queue)

    local loop message queue

- (Hash) message_registry (readonly) Originally defined in class Carnivore::Source

Returns registry of processed messages

Returns:

  • (Hash)

    registry of processed messages

- (Queue) message_remote (readonly) Originally defined in class Carnivore::Source

Returns remote message queue

Returns:

  • (Queue)

    remote message queue

- (String, Symbol) name (readonly) Originally defined in class Carnivore::Source

Returns name of source

Returns:

  • (String, Symbol)

    name of source

- (TrueClass, FalseClass) processing (readonly) Originally defined in class Carnivore::Source

Returns currently processing a message

Returns:

  • (TrueClass, FalseClass)

    currently processing a message

- (TrueClass, FalseClass) run_process (readonly) Originally defined in class Carnivore::Source

Returns message processing control switch

Returns:

  • (TrueClass, FalseClass)

    message processing control switch

Instance Method Details

- (Object) connect(*args)

Note that we are connected



14
15
16
# File 'lib/carnivore/source/test.rb', line 14

def connect(*args)
  info 'Test connect called'
end

- (Array<String>) receive(*args)

Receive randomly generated message

Returns:

  • (Array<String>)


21
22
23
24
25
26
27
28
# File 'lib/carnivore/source/test.rb', line 21

def receive(*args)
  if(rand(RAND_MAX) % RAND_DIV == 0)
    sleep_for = rand(RAND_SLEEP)
    debug "Test source sleep for: #{sleep_for}"
    sleep sleep_for
  end
  20.times.map{('a'..'z').to_a.shuffle.first}.join
end

- (Object) transmit(message)

Dummy transmit message

Parameters:



33
34
35
# File 'lib/carnivore/source/test.rb', line 33

def transmit(message)
  info "Transmit requested: #{message}"
end