Class: KubeMQ::ChannelInfo
- Inherits:
-
Object
- Object
- KubeMQ::ChannelInfo
- Defined in:
- lib/kubemq/channel_info.rb
Overview
Metadata about a KubeMQ channel returned by BaseClient#list_channels.
Instance Attribute Summary collapse
-
#incoming ⇒ Integer
readonly
Total number of incoming messages.
-
#is_active ⇒ Boolean
readonly
Whether the channel currently has active subscribers.
-
#last_activity ⇒ Integer
readonly
Unix timestamp of the last activity on this channel.
-
#name ⇒ String
readonly
Channel name.
-
#outgoing ⇒ Object
readonly
Returns the value of attribute outgoing.
-
#type ⇒ String
readonly
Channel type (one of ChannelType constants).
Class Method Summary collapse
-
.from_json(hash) ⇒ ChannelInfo
private
Constructs a ChannelInfo from a parsed JSON hash.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Returns whether the channel currently has active subscribers.
-
#initialize(name:, type:, last_activity: 0, is_active: false, incoming: 0, outgoing: 0) ⇒ ChannelInfo
constructor
Creates a new ChannelInfo instance.
-
#to_s ⇒ String
Returns a human-readable summary of the channel information.
Constructor Details
#initialize(name:, type:, last_activity: 0, is_active: false, incoming: 0, outgoing: 0) ⇒ ChannelInfo
Creates a new ChannelInfo instance.
37 38 39 40 41 42 43 44 |
# File 'lib/kubemq/channel_info.rb', line 37 def initialize(name:, type:, last_activity: 0, is_active: false, incoming: 0, outgoing: 0) @name = name @type = type @last_activity = last_activity @is_active = is_active @incoming = incoming @outgoing = outgoing end |
Instance Attribute Details
#incoming ⇒ Integer (readonly)
Returns total number of incoming messages.
27 |
# File 'lib/kubemq/channel_info.rb', line 27 attr_reader :name, :type, :last_activity, :is_active, :incoming, :outgoing |
#is_active ⇒ Boolean (readonly)
Returns whether the channel currently has active subscribers.
27 |
# File 'lib/kubemq/channel_info.rb', line 27 attr_reader :name, :type, :last_activity, :is_active, :incoming, :outgoing |
#last_activity ⇒ Integer (readonly)
Returns Unix timestamp of the last activity on this channel.
27 |
# File 'lib/kubemq/channel_info.rb', line 27 attr_reader :name, :type, :last_activity, :is_active, :incoming, :outgoing |
#name ⇒ String (readonly)
Returns channel name.
27 28 29 |
# File 'lib/kubemq/channel_info.rb', line 27 def name @name end |
#outgoing ⇒ Object (readonly)
Returns the value of attribute outgoing.
27 |
# File 'lib/kubemq/channel_info.rb', line 27 attr_reader :name, :type, :last_activity, :is_active, :incoming, :outgoing |
#type ⇒ String (readonly)
Returns channel type (one of KubeMQ::ChannelType constants).
27 |
# File 'lib/kubemq/channel_info.rb', line 27 attr_reader :name, :type, :last_activity, :is_active, :incoming, :outgoing |
Class Method Details
.from_json(hash) ⇒ ChannelInfo
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Constructs a KubeMQ::ChannelInfo from a parsed JSON hash.
Accepts both camelCase (from the broker REST API) and snake_case keys.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/kubemq/channel_info.rb', line 60 def self.from_json(hash) is_active_val = if hash.key?('isActive') then hash['isActive'] elsif hash.key?('is_active') then hash['is_active'] elsif hash.key?(:is_active) then hash[:is_active] else false end new( name: hash['name'] || hash[:name] || '', type: hash['type'] || hash[:type] || '', last_activity: hash['lastActivity'] || hash['last_activity'] || hash[:last_activity] || 0, is_active: is_active_val, incoming: hash['incoming'] || hash[:incoming] || 0, outgoing: hash['outgoing'] || hash[:outgoing] || 0 ) end |
Instance Method Details
#active? ⇒ Boolean
Returns whether the channel currently has active subscribers.
49 50 51 |
# File 'lib/kubemq/channel_info.rb', line 49 def active? @is_active end |
#to_s ⇒ String
Returns a human-readable summary of the channel information.
80 81 82 |
# File 'lib/kubemq/channel_info.rb', line 80 def to_s "ChannelInfo(name=#{@name}, type=#{@type}, active=#{active?})" end |