Module: RSMP::Receiver

Includes:
Inspect
Included in:
Collector, Queue
Defined in:
lib/rsmp/collect/receiver.rb

Instance Method Summary collapse

Methods included from Inspect

#inspect, #inspector

Instance Method Details

#accept_message?(message) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rsmp/collect/receiver.rb', line 28

def accept_message?(message)
  @filter.nil? || @filter.accept?(message)
end

#handle_message(message) ⇒ Object



36
# File 'lib/rsmp/collect/receiver.rb', line 36

def handle_message(message); end

#initialize_receiver(distributor, filter: nil) ⇒ Object



9
10
11
12
# File 'lib/rsmp/collect/receiver.rb', line 9

def initialize_receiver(distributor, filter: nil)
  @distributor = distributor
  @filter = filter
end

#receive(message) ⇒ Object



22
23
24
# File 'lib/rsmp/collect/receiver.rb', line 22

def receive(message)
  handle_message(message) if accept_message?(message)
end

#receive_error(error, options = {}) ⇒ Object



26
# File 'lib/rsmp/collect/receiver.rb', line 26

def receive_error(error, options = {}); end

#reject_message?(message) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rsmp/collect/receiver.rb', line 32

def reject_message?(message)
  !accept_message?(message)
end

#start_receivingObject



14
15
16
# File 'lib/rsmp/collect/receiver.rb', line 14

def start_receiving
  @distributor.add_receiver(self)
end

#stop_receivingObject



18
19
20
# File 'lib/rsmp/collect/receiver.rb', line 18

def stop_receiving
  @distributor.remove_receiver(self)
end