Class: Legion::Transport::Messages::Direct

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

Overview

Generic publish to an arbitrary exchange + routing key without requiring legion-data or a function_id. Used by the /api/transport/publish route.

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/direct.rb', line 9

def exchange
  Legion::Transport::Exchange.new(@options[:exchange].to_s)
end

#messageObject



17
18
19
# File 'lib/legion/transport/messages/direct.rb', line 17

def message
  @options.except(:exchange, :routing_key)
end

#routing_keyObject



13
14
15
# File 'lib/legion/transport/messages/direct.rb', line 13

def routing_key
  @options[:routing_key]
end

#validateObject

Raises:

  • (ArgumentError)


21
22
23
24
25
26
# File 'lib/legion/transport/messages/direct.rb', line 21

def validate
  raise ArgumentError, 'exchange is required' unless @options[:exchange].is_a?(String) && !@options[:exchange].empty?
  raise ArgumentError, 'routing_key is required' unless @options[:routing_key].is_a?(String) && !@options[:routing_key].empty?

  @valid = true
end