Class: Moleculer::Packets::Info
- Includes:
- Support
- Defined in:
- lib/moleculer/packets/info.rb
Overview
Represents an INFO packet
Defined Under Namespace
Classes: Client
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Moleculer::Support::OpenStruct
readonly
The configuration of the node.
-
#hostname ⇒ String
readonly
The hostname of the node.
-
#ip_list ⇒ Array<String>
readonly
A list of the node's used IP addresses.
-
#services ⇒ Array<Moleculer::Services::Remote|Moleculer::Services::Base>
readonly
An array of the services the endpoint provides.
Instance Method Summary collapse
-
#initialize(config, data = {}) ⇒ Info
constructor
A new instance of Info.
- #to_h ⇒ Object
- #topic ⇒ Object
Methods inherited from Base
inherited, packet_accessors, packet_attr, packet_name, #sender, #ver
Constructor Details
#initialize(config, data = {}) ⇒ Info
Returns a new instance of Info.
67 68 69 70 71 72 73 74 75 |
# File 'lib/moleculer/packets/info.rb', line 67 def initialize(config, data = {}) super(config, data) @services = HashUtil.fetch(data, :services) @ip_list = HashUtil.fetch(data, :ip_list) @hostname = HashUtil.fetch(data, :hostname) @client = Client.new(HashUtil.fetch(data, :client, {})) node = HashUtil.fetch(data, :node, nil) @node_id = HashUtil.fetch(data, :node_id, node&.id) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
54 55 56 57 58 |
# File 'lib/moleculer/packets/info.rb', line 54 attr_reader :services, :config, :ip_list, :hostname, :client |
#config ⇒ Moleculer::Support::OpenStruct (readonly)
Returns the configuration of the node.
54 55 56 57 58 |
# File 'lib/moleculer/packets/info.rb', line 54 attr_reader :services, :config, :ip_list, :hostname, :client |
#hostname ⇒ String (readonly)
Returns the hostname of the node.
54 55 56 57 58 |
# File 'lib/moleculer/packets/info.rb', line 54 attr_reader :services, :config, :ip_list, :hostname, :client |
#ip_list ⇒ Array<String> (readonly)
Returns a list of the node's used IP addresses.
54 55 56 57 58 |
# File 'lib/moleculer/packets/info.rb', line 54 attr_reader :services, :config, :ip_list, :hostname, :client |
#services ⇒ Array<Moleculer::Services::Remote|Moleculer::Services::Base> (readonly)
Returns an array of the services the endpoint provides.
54 55 56 |
# File 'lib/moleculer/packets/info.rb', line 54 def services @services end |
Instance Method Details
#to_h ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/moleculer/packets/info.rb', line 83 def to_h super.merge( services: @services, config: config_for_hash, ipList: @ip_list, hostname: @hostname, client: @client.to_h, ) end |
#topic ⇒ Object
77 78 79 80 81 |
# File 'lib/moleculer/packets/info.rb', line 77 def topic return "#{super}.#{@node_id}" if @node_id super end |