Sha256: c63fbab5e8cd7127d9d31f52bb009cc953776139e212fe7e645ec026231e7ffe

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Legion::Extensions::Scheduler::Transport::Messages
  class SendTask < Legion::Transport::Message
    def type
      'task'
    end

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

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

    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

    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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lex-scheduler-0.1.3 lib/legion/extensions/scheduler/transport/messages/send_task.rb
lex-scheduler-0.1.2 lib/legion/extensions/scheduler/transport/messages/send_task.rb
lex-scheduler-0.1.1 lib/legion/extensions/scheduler/transport/messages/send_task.rb