A Ruby gem for streaming data from the Bluesky/ATProto firehose

added rev, since and prev_data to CommitMessage

+27 -10
+8 -7
CHANGELOG.md
··· 7 7 - added `Skyfall::Jetstream::CommitMessage#operation` (aliased as `op`) which returns the (always single) operation in the `operations` array 8 8 - added `#kind` as alias for `#type` in both `Message` classes 9 9 - added a base class for error types, `Skyfall::Error` 10 - - added `#blocks` to `SyncMessage` 10 + - added `#blocks` to `Skyfall::Firehose::SyncMessage` 11 + - added `#rev`, `#since` and `#prev_data` to `Skyfall::Firehose::CommitMessage` 11 12 12 13 Deprecated & removed APIs: 13 14 ··· 15 16 - removed deprecated `CommitMessage#prev` 16 17 - deprecated `#path` in both `Operation` classes 17 18 19 + Optimizations: 20 + 21 + - much faster `Skyfall::Firehose::Message#time` parsing on Ruby 3.2+ 22 + - lazy decoding of sections in `CarArchive` – saves quite a lot of work if sections are only accessed through `Operation#raw_record` 23 + - added `frozen_string_literal: true` in all files to reduce garbage collection 24 + 18 25 Access level changes: 19 26 20 27 - restricted `Stream#start_heartbeat_timer` & `Stream#stop_heartbeat_timer` methods access to private ··· 23 30 - restricted `#inspectable_variables` methods access to either private or protected 24 31 - relaxed `Stream#build_websocket_url` & `Stream#build_websocket_client` methods access from private to protected 25 32 - fixed private class method `Skyfall::Firehose::Message.decode_cbor_objects` which wasn't actually private 26 - 27 - Optimizations: 28 - 29 - - much faster `Skyfall::Firehose::Message#time` parsing on Ruby 3.2+ 30 - - lazy decoding of sections in `CarArchive` – saves quite a lot of work if sections are only accessed through `Operation#raw_record` 31 - - added `frozen_string_literal: true` in all files to reduce garbage collection 32 33 33 34 Additional validations and other changes: 34 35
+16 -1
lib/skyfall/firehose/commit_message.rb
··· 26 26 # 27 27 def initialize(type_object, data_object) 28 28 super 29 - check_if_not_nil 'seq', 'repo', 'commit', 'blocks', 'ops', 'time' 29 + check_if_not_nil 'seq', 'repo', 'commit', 'blocks', 'ops', 'time', 'rev' 30 + end 31 + 32 + # @return [String] current revision of the repo 33 + def rev 34 + @data_object['rev'] 35 + end 36 + 37 + # @return [String, nil] revision of the previous commit in the repo 38 + def since 39 + @data_object['since'] 40 + end 41 + 42 + # @return [CID, nil] CID (Content Identifier) of data of the previous commit in the repo 43 + def prev_data 44 + @prev_data ||= CID.from_cbor_tag(@data_object['prevData']) 30 45 end 31 46 32 47 # @return [CID] CID (Content Identifier) of the commit
+3 -2
lib/skyfall/firehose/message.rb
··· 156 156 private 157 157 158 158 # Note: this method is written this way as an optimization 159 - def check_if_not_nil(a, b = nil, c = nil, d = nil, e = nil, f = nil) 159 + def check_if_not_nil(a, b = nil, c = nil, d = nil, e = nil, f = nil, g = nil) 160 160 ok = @data_object.has_key?(a) 161 161 ok &&= @data_object.has_key?(b) if b 162 162 ok &&= @data_object.has_key?(c) if c 163 163 ok &&= @data_object.has_key?(d) if d 164 164 ok &&= @data_object.has_key?(e) if e 165 165 ok &&= @data_object.has_key?(f) if f 166 + ok &&= @data_object.has_key?(g) if g 166 167 167 168 if !ok 168 - expected_fields = [a, b, c, d, e, f].compact 169 + expected_fields = [a, b, c, d, e, f, g].compact 169 170 missing_fields = expected_fields.select { |x| @data_object[x].nil? } 170 171 raise DecodeError.new("Missing event details (#{missing_fields.map(&:to_s).join(', ')})") 171 172 end