Class: Legion::Transport::Messages::SubTask

Inherits:
Legion::Transport::Message show all
Defined in:
lib/legion/transport/messages/subtask.rb

Constant Summary

Constants inherited from Legion::Transport::Message

Legion::Transport::Message::ENVELOPE_KEYS

Constants included from Common

Common::NAMESPACE_BOUNDARIES

Instance Method Summary collapse

Methods inherited from Legion::Transport::Message

#app_id, #channel, #content_encoding, #content_type, #correlation_id, #encode_message, #encrypt?, #encrypt_message, #exchange_name, #expiration, #headers, #initialize, max_payload_bytes, #message_id, #persistent, #priority, #publish, #reply_to, #timestamp, #type, #user_id

Methods included from Common

#channel, #channel_open?, #close, #close!, #deep_merge, #generate_consumer_tag, #open_channel, #options_builder

Constructor Details

This class inherits a constructor from Legion::Transport::Message

Instance Method Details

#exchangeObject



9
10
11
# File 'lib/legion/transport/messages/subtask.rb', line 9

def exchange
  Legion::Transport::Exchanges::Task
end

#messageObject



13
14
15
16
17
18
19
20
# File 'lib/legion/transport/messages/subtask.rb', line 13

def message
  {
    transformation: @options[:transformation],
    conditions:     @options[:conditions],
    results:        @options[:results],
    engine:         @options[:engine]
  }.compact
end

#routing_keyObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/transport/messages/subtask.rb', line 22

def routing_key
  key = if @options[:conditions].is_a?(String) && @options[:conditions].length > 2
          'task.subtask.conditioner'
        elsif @options[:transformation].is_a?(String) && @options[:transformation].length > 2
          'task.subtask.transform'
        elsif @options[:function_id].is_a? Integer
          function = Legion::Data::Model::Function[@options[:function_id]]
          "#{function.runner.extension.values[:exchange]}.#{function.runner.values[:queue]}.#{function.values[:name]}"
        end
  log.debug "SubTask routing_key=#{key} function_id=#{@options[:function_id]}"
  key
end

#validateObject

Raises:

  • (TypeError)


35
36
37
38
39
# File 'lib/legion/transport/messages/subtask.rb', line 35

def validate
  raise TypeError unless @options[:function].is_a? String

  @valid = true
end