Class: Legion::Extensions::Scheduler::Transport::Messages::SendTask

Inherits:
Transport::Message
  • Object
show all
Defined in:
lib/legion/extensions/scheduler/transport/messages/send_task.rb

Instance Method Summary collapse

Instance Method Details

#exchangeObject



24
25
26
27
28
29
30
# File 'lib/legion/extensions/scheduler/transport/messages/send_task.rb', line 24

def exchange
  @exchange ||= if @options.key?(:exchange) && @options[:exchange].is_a?(String)
                  Legion::Transport::Exchange.new(@options[:exchange])
                else
                  Legion::Transport::Exchange.new(function.runner.extension.values[:exchange])
                end
end

#functionObject



32
33
34
# File 'lib/legion/extensions/scheduler/transport/messages/send_task.rb', line 32

def function
  @function ||= Legion::Data::Model::Function[@options[:function_id]]
end

#messageObject



7
8
9
10
11
12
13
14
# File 'lib/legion/extensions/scheduler/transport/messages/send_task.rb', line 7

def message
  return @options if routing_key == 'task.subtask.transform'

  {
    args: @options[:args] || @options,
    function: function.values[:name]
  }
end

#routing_keyObject



16
17
18
19
20
21
22
# File 'lib/legion/extensions/scheduler/transport/messages/send_task.rb', line 16

def routing_key
  @routing_key ||= if @options.key?(:routing_key)
                     @options[:routing_key]
                   else
                     "#{function.runner.extension.values[:name]}.#{function.runner.values[:name]}.#{function.values[:name]}" # rubocop:disable Layout/LineLength
                   end
end

#typeObject



3
4
5
# File 'lib/legion/extensions/scheduler/transport/messages/send_task.rb', line 3

def type
  'task'
end