Class: Carnivore::Source::Test
- Inherits:
-
Carnivore::Source
- Object
- Carnivore::Source
- Carnivore::Source::Test
- 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)
-
- (TrueClass, FalseClass) auto_confirm
inherited
from Carnivore::Source
readonly
Auto confirm received messages.
-
- (TrueClass, FalseClass) auto_process
inherited
from Carnivore::Source
readonly
Start source processing on initialization.
-
- (Carnivore::Supervisor) callback_supervisor
inherited
from Carnivore::Source
readonly
Supervisor maintaining callback instances.
-
- (Array<Callback>) callbacks
inherited
from Carnivore::Source
readonly
Registered callbacks.
-
- (Queue) message_loop
inherited
from Carnivore::Source
readonly
Local loop message queue.
-
- (Hash) message_registry
inherited
from Carnivore::Source
readonly
Registry of processed messages.
-
- (Queue) message_remote
inherited
from Carnivore::Source
readonly
Remote message queue.
-
- (String, Symbol) name
inherited
from Carnivore::Source
readonly
Name of source.
-
- (TrueClass, FalseClass) processing
inherited
from Carnivore::Source
readonly
Currently processing a message.
-
- (TrueClass, FalseClass) run_process
inherited
from Carnivore::Source
readonly
Message processing control switch.
Instance Method Summary (collapse)
-
- (Object) connect(*args)
Note that we are connected.
-
- (Array<String>) receive(*args)
Receive randomly generated message.
-
- (Object) transmit(message)
Dummy transmit message.
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
- (TrueClass, FalseClass) auto_process (readonly) Originally defined in class Carnivore::Source
Returns start source processing on initialization
- (Carnivore::Supervisor) callback_supervisor (readonly) Originally defined in class Carnivore::Source
Returns supervisor maintaining callback instances
- (Array<Callback>) callbacks (readonly) Originally defined in class Carnivore::Source
Returns registered callbacks
- (Queue) message_loop (readonly) Originally defined in class Carnivore::Source
Returns local loop message queue
- (Hash) message_registry (readonly) Originally defined in class Carnivore::Source
Returns registry of processed messages
- (Queue) message_remote (readonly) Originally defined in class Carnivore::Source
Returns remote message queue
- (String, Symbol) name (readonly) Originally defined in class Carnivore::Source
Returns name of source
- (TrueClass, FalseClass) processing (readonly) Originally defined in class Carnivore::Source
Returns currently processing a message
- (TrueClass, FalseClass) run_process (readonly) Originally defined in class Carnivore::Source
Returns 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
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
33 34 35 |
# File 'lib/carnivore/source/test.rb', line 33 def transmit() info "Transmit requested: #{}" end |