Class: Messaging::Message::Metadata
- Inherits:
-
Object
- Object
- Messaging::Message::Metadata
- Includes:
- Schema::DataStructure
- Defined in:
- lib/messaging/message/metadata.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
- .causation_attribute_names ⇒ Object
- .origin_attribute_names ⇒ Object
- .source_attribute_names ⇒ Object
- .transient_attributes ⇒ Object
- .workflow_attribute_names ⇒ Object
Instance Method Summary collapse
- #causation_message_identifier ⇒ Object (also: #causation_identifier)
- #clear_local_properties ⇒ Object
- #clear_properties ⇒ Object
- #clear_reply_stream_name ⇒ Object
- #correlated?(stream_name) ⇒ Boolean (also: #correlates?)
- #delete_local_property(name) ⇒ Object
- #delete_property(name) ⇒ Object
- #follow(preceding_metadata) ⇒ Object
-
#follows?(preceding_metadata) ⇒ Boolean
Consider whether “following” takes correlation stream and reply stream into consideration.
- #get_local_property(name) ⇒ Object
- #get_property(name) ⇒ Object
- #identifier ⇒ Object (also: #source_message_identifier)
- #reply? ⇒ Boolean
- #set_local_property(name, value) ⇒ Object
- #set_property(name, value) ⇒ Object
Class Method Details
.causation_attribute_names ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/messaging/message/metadata.rb', line 211 def self.causation_attribute_names [ :causation_message_stream_name, :causation_message_position, :causation_message_global_position ] end |
.origin_attribute_names ⇒ Object
219 220 221 222 223 224 |
# File 'lib/messaging/message/metadata.rb', line 219 def self.origin_attribute_names [ :correlation_stream_name, :reply_stream_name ] end |
.source_attribute_names ⇒ Object
203 204 205 206 207 208 209 |
# File 'lib/messaging/message/metadata.rb', line 203 def self.source_attribute_names [ :stream_name, :position, :global_position ] end |
.transient_attributes ⇒ Object
230 231 232 233 234 235 236 237 |
# File 'lib/messaging/message/metadata.rb', line 230 def self.transient_attributes [ :stream_name, :position, :global_position, :time ] end |
.workflow_attribute_names ⇒ Object
226 227 228 |
# File 'lib/messaging/message/metadata.rb', line 226 def self.workflow_attribute_names causation_attribute_names + origin_attribute_names end |
Instance Method Details
#causation_message_identifier ⇒ Object Also known as: causation_identifier
49 50 51 52 |
# File 'lib/messaging/message/metadata.rb', line 49 def return nil if .nil? || .nil? "#{}/#{}" end |
#clear_local_properties ⇒ Object
199 200 201 |
# File 'lib/messaging/message/metadata.rb', line 199 def clear_local_properties local_properties.clear end |
#clear_properties ⇒ Object
169 170 171 |
# File 'lib/messaging/message/metadata.rb', line 169 def clear_properties properties.clear end |
#clear_reply_stream_name ⇒ Object
120 121 122 |
# File 'lib/messaging/message/metadata.rb', line 120 def clear_reply_stream_name self.reply_stream_name = nil end |
#correlated?(stream_name) ⇒ Boolean Also known as: correlates?
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/messaging/message/metadata.rb', line 128 def (stream_name) correlation_stream_name = self.correlation_stream_name return false if correlation_stream_name.nil? stream_name = Category.normalize(stream_name) if MessageStore::StreamName.category?(stream_name) correlation_stream_name = MessageStore::StreamName.get_category(correlation_stream_name) end correlation_stream_name == stream_name end |
#delete_local_property(name) ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/messaging/message/metadata.rb', line 191 def delete_local_property(name) if not name.is_a?(Symbol) raise Error, "Local property name must be a symbol: #{name.inspect}" end local_properties.delete(name) end |
#delete_property(name) ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/messaging/message/metadata.rb', line 161 def delete_property(name) if not name.is_a?(Symbol) raise Error, "Property name must be a symbol: #{name.inspect}" end properties.delete(name) end |
#follow(preceding_metadata) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/messaging/message/metadata.rb', line 55 def follow() self. = .stream_name self. = .position self. = .global_position self.correlation_stream_name = .correlation_stream_name self.reply_stream_name = .reply_stream_name .properties.each do |name, value| properties[name] = value end end |
#follows?(preceding_metadata) ⇒ Boolean
Consider whether “following” takes correlation stream and reply stream into consideration. Arguably, these attributes aren’t indicative of causation. Also, follows? doesn’t take metadata into consideration What’s probably needed is a ‘copied?` predicate on metadata (without a delegation from message) Scott, Aaron, Tue Apr 11 2023
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/messaging/message/metadata.rb', line 76 def follows?() if .nil? && .stream_name.nil? return false end if != .stream_name return false end if .nil? && .position.nil? return false end if != .position return false end if .nil? && .global_position.nil? return false end if != .global_position return false end if not .correlation_stream_name.nil? if correlation_stream_name != .correlation_stream_name return false end end if not .reply_stream_name.nil? if reply_stream_name != .reply_stream_name return false end end true end |
#get_local_property(name) ⇒ Object
183 184 185 186 187 188 189 |
# File 'lib/messaging/message/metadata.rb', line 183 def get_local_property(name) if not name.is_a?(Symbol) raise Error, "Local property name must be a symbol: #{name.inspect}" end local_properties[name] end |
#get_property(name) ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/messaging/message/metadata.rb', line 153 def get_property(name) if not name.is_a?(Symbol) raise Error, "Property name must be a symbol: #{name.inspect}" end properties[name] end |
#identifier ⇒ Object Also known as: source_message_identifier
43 44 45 46 |
# File 'lib/messaging/message/metadata.rb', line 43 def identifier return nil if stream_name.nil? || position.nil? "#{stream_name}/#{position}" end |
#reply? ⇒ Boolean
124 125 126 |
# File 'lib/messaging/message/metadata.rb', line 124 def reply? !reply_stream_name.nil? end |
#set_local_property(name, value) ⇒ Object
173 174 175 176 177 178 179 180 181 |
# File 'lib/messaging/message/metadata.rb', line 173 def set_local_property(name, value) if not name.is_a?(Symbol) raise Error, "Local property name must be a symbol: #{name.inspect}" end local_properties[name] = value value end |
#set_property(name, value) ⇒ Object
143 144 145 146 147 148 149 150 151 |
# File 'lib/messaging/message/metadata.rb', line 143 def set_property(name, value) if not name.is_a?(Symbol) raise Error, "Property name must be a symbol: #{name.inspect}" end properties[name] = value value end |