skyfall 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d272120c19a97451a6df364e1a7dbbb8191dc0247fd929129ecab0cf05902599
4
- data.tar.gz: 242ebbbbf44aee36a883c2fc78be327d29c14fa27168fc1eac66ef38ad16cc16
3
+ metadata.gz: 17dd2389545a6bd5c9c3483a89f95e40a62cf2014e263f69d3590cf651920865
4
+ data.tar.gz: 9fe379e3d713c50e4a4700941660b529827e2329e200859ddea58b7113da1c3b
5
5
  SHA512:
6
- metadata.gz: cebb5837133466638a7009d52be516af961644c55f91fe3f3e9a6fe120bc8875f614bbf849cea02fe23b81f3f1f4652226214d375adff12198faf3dd81c1bedd
7
- data.tar.gz: f1c8c48d58c344a67f4df27afc792b6d38272ecb0aefdf7cf4336269290e36c788d356547c2af0520a9d11664e62fb872157da88951cb669f7081bb0414cc029
6
+ metadata.gz: e9f7c603360a483241cbd6b2af8b49b315149b308c2064332b42d9fa7b27fd302c1b181c6fc7a60871f1dfead09cc3621ed2b9106db2680e0919f12119af881d
7
+ data.tar.gz: e8c7da9dc57730ded46de52cc7e500d84129782bd534c2163205330143bb1a5ec0f24feb39a86e440c073972b1c4af3840ce688e9caf55177003d140267c6473
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.6.0] - 2025-06-25
2
+
3
+ - significantly speeded up reading of events from the binary firehose (`Skyfall::Firehose`) - up to 4-5x faster than before
4
+ - removed the `Skyfall::Stream.new` constructor deprecated in 0.5.0
5
+
6
+ ## [0.5.1] - 2025-05-18
7
+
8
+ - added support for the new `#sync` message type
9
+ - added `#unknown?` helper in `Skyfall::Firehose::Message` and `Skyfall::Jetstream::Message`, which returns true if the message type is `UnknownMessage`
10
+ - added `:bsky_verification` and `:bsky_actor_status` lexicon type and shortcode
11
+ - added one missing require
12
+
1
13
  ## [0.5.0] - 2024-11-15
2
14
 
3
15
  Jetstream support! You can now connect to [Jetstream](https://github.com/bluesky-social/jetstream) sources using `Skyfall::Jetstream` (see readme).
data/README.md CHANGED
@@ -80,7 +80,7 @@ Alternatively, you can connect to a [Jetstream](https://github.com/bluesky-socia
80
80
  Jetstream connections are made using a `Skyfall::Jetstream` instance, which has more or less the same API as `Skyfall::Firehose`, so it should be possible to switch between those by just changing the line that creates the client instance:
81
81
 
82
82
  ```rb
83
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network')
83
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network')
84
84
 
85
85
  sky.on_message { |msg| ... }
86
86
  sky.on_error { |e| ... }
@@ -113,7 +113,7 @@ Jetstream has a similar mechanism, except the cursor is the event's timestamp in
113
113
  ```rb
114
114
  cursor = load_cursor
115
115
 
116
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', { cursor: cursor })
116
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', { cursor: cursor })
117
117
  sky.on_message do |msg|
118
118
  save_cursor(msg.seq)
119
119
  process_message(msg)
@@ -283,7 +283,7 @@ Jetstream allows you to specify [filters](https://github.com/bluesky-social/jets
283
283
  To use these filters, pass the "wantedCollections" and/or "wantedDids" parameters in the options hash when initializing `Skyfall::Jetstream`. You can use the original JavaScript param names, or a more Ruby-like snake_case form:
284
284
 
285
285
  ```rb
286
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', {
286
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', {
287
287
  wanted_collections: 'app.bsky.feed.post',
288
288
  wanted_dids: @dids
289
289
  })
@@ -292,7 +292,7 @@ sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', {
292
292
  For collections, you can also use the symbol codes used in `Operation#type`, e.g. `:bsky_post`:
293
293
 
294
294
  ```rb
295
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', {
295
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', {
296
296
  wanted_collections: [:bsky_post]
297
297
  })
298
298
  ```
@@ -18,7 +18,7 @@ if terms.empty?
18
18
  end
19
19
 
20
20
  # tell Jetstream to send us only post records
21
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', { wanted_collections: [:bsky_post] })
21
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', { wanted_collections: [:bsky_post] })
22
22
 
23
23
  sky.on_message do |msg|
24
24
  # we're only interested in repo commit messages
@@ -1,37 +1,41 @@
1
1
  module Skyfall
2
2
  module Collection
3
- BSKY_PROFILE = "app.bsky.actor.profile"
4
- BSKY_FEED = "app.bsky.feed.generator"
5
- BSKY_LIKE = "app.bsky.feed.like"
6
- BSKY_POST = "app.bsky.feed.post"
7
- BSKY_POSTGATE = "app.bsky.feed.postgate"
8
- BSKY_REPOST = "app.bsky.feed.repost"
9
- BSKY_THREADGATE = "app.bsky.feed.threadgate"
10
- BSKY_BLOCK = "app.bsky.graph.block"
11
- BSKY_FOLLOW = "app.bsky.graph.follow"
12
- BSKY_LIST = "app.bsky.graph.list"
13
- BSKY_LISTBLOCK = "app.bsky.graph.listblock"
14
- BSKY_LISTITEM = "app.bsky.graph.listitem"
15
- BSKY_STARTERPACK = "app.bsky.graph.starterpack"
16
- BSKY_LABELER = "app.bsky.labeler.service"
3
+ BSKY_PROFILE = "app.bsky.actor.profile"
4
+ BSKY_ACTOR_STATUS = "app.bsky.actor.status"
5
+ BSKY_FEED = "app.bsky.feed.generator"
6
+ BSKY_LIKE = "app.bsky.feed.like"
7
+ BSKY_POST = "app.bsky.feed.post"
8
+ BSKY_POSTGATE = "app.bsky.feed.postgate"
9
+ BSKY_REPOST = "app.bsky.feed.repost"
10
+ BSKY_THREADGATE = "app.bsky.feed.threadgate"
11
+ BSKY_BLOCK = "app.bsky.graph.block"
12
+ BSKY_FOLLOW = "app.bsky.graph.follow"
13
+ BSKY_LIST = "app.bsky.graph.list"
14
+ BSKY_LISTBLOCK = "app.bsky.graph.listblock"
15
+ BSKY_LISTITEM = "app.bsky.graph.listitem"
16
+ BSKY_STARTERPACK = "app.bsky.graph.starterpack"
17
+ BSKY_VERIFICATION = "app.bsky.graph.verification"
18
+ BSKY_LABELER = "app.bsky.labeler.service"
17
19
 
18
20
  BSKY_CHAT_DECLARATION = "chat.bsky.actor.declaration"
19
21
 
20
22
  SHORT_CODES = {
21
- BSKY_BLOCK => :bsky_block,
22
- BSKY_FEED => :bsky_feed,
23
- BSKY_FOLLOW => :bsky_follow,
24
- BSKY_LABELER => :bsky_labeler,
25
- BSKY_LIKE => :bsky_like,
26
- BSKY_LIST => :bsky_list,
27
- BSKY_LISTBLOCK => :bsky_listblock,
28
- BSKY_LISTITEM => :bsky_listitem,
29
- BSKY_POST => :bsky_post,
30
- BSKY_POSTGATE => :bsky_postgate,
31
- BSKY_PROFILE => :bsky_profile,
32
- BSKY_REPOST => :bsky_repost,
33
- BSKY_STARTERPACK => :bsky_starterpack,
34
- BSKY_THREADGATE => :bsky_threadgate,
23
+ BSKY_ACTOR_STATUS => :bsky_actor_status,
24
+ BSKY_BLOCK => :bsky_block,
25
+ BSKY_FEED => :bsky_feed,
26
+ BSKY_FOLLOW => :bsky_follow,
27
+ BSKY_LABELER => :bsky_labeler,
28
+ BSKY_LIKE => :bsky_like,
29
+ BSKY_LIST => :bsky_list,
30
+ BSKY_LISTBLOCK => :bsky_listblock,
31
+ BSKY_LISTITEM => :bsky_listitem,
32
+ BSKY_POST => :bsky_post,
33
+ BSKY_POSTGATE => :bsky_postgate,
34
+ BSKY_PROFILE => :bsky_profile,
35
+ BSKY_REPOST => :bsky_repost,
36
+ BSKY_STARTERPACK => :bsky_starterpack,
37
+ BSKY_THREADGATE => :bsky_threadgate,
38
+ BSKY_VERIFICATION => :bsky_verification,
35
39
  BSKY_CHAT_DECLARATION => :bsky_chat_declaration,
36
40
  }
37
41
 
@@ -15,6 +15,7 @@ module Skyfall
15
15
  require_relative 'identity_message'
16
16
  require_relative 'info_message'
17
17
  require_relative 'labels_message'
18
+ require_relative 'sync_message'
18
19
  require_relative 'tombstone_message'
19
20
  require_relative 'unknown_message'
20
21
 
@@ -34,6 +35,7 @@ module Skyfall
34
35
  when '#identity' then Firehose::IdentityMessage
35
36
  when '#info' then Firehose::InfoMessage
36
37
  when '#labels' then Firehose::LabelsMessage
38
+ when '#sync' then Firehose::SyncMessage
37
39
  when '#tombstone' then Firehose::TombstoneMessage
38
40
  else Firehose::UnknownMessage
39
41
  end
@@ -56,6 +58,10 @@ module Skyfall
56
58
  []
57
59
  end
58
60
 
61
+ def unknown?
62
+ self.is_a?(Firehose::UnknownMessage)
63
+ end
64
+
59
65
  def time
60
66
  @time ||= @data_object['time'] && Time.parse(@data_object['time'])
61
67
  end
@@ -0,0 +1,9 @@
1
+ require_relative '../firehose'
2
+
3
+ module Skyfall
4
+ class Firehose::SyncMessage < Firehose::Message
5
+ def rev
6
+ @rev ||= @data_object['rev']
7
+ end
8
+ end
9
+ end
@@ -13,13 +13,6 @@ module Skyfall
13
13
 
14
14
  attr_accessor :cursor
15
15
 
16
- def self.new(server, endpoint, cursor = nil)
17
- # to be removed in 0.6
18
- instance = self.allocate
19
- instance.send(:initialize, server, endpoint, cursor)
20
- instance
21
- end
22
-
23
16
  def initialize(server, endpoint, cursor = nil)
24
17
  require_relative 'firehose/message'
25
18
  super(server)
@@ -34,7 +27,7 @@ module Skyfall
34
27
  end
35
28
 
36
29
  def handle_message(msg)
37
- data = msg.data.pack('C*')
30
+ data = msg.data
38
31
  @handlers[:raw_message]&.call(data)
39
32
 
40
33
  if @handlers[:message]
@@ -39,6 +39,10 @@ module Skyfall
39
39
  @time_us = @json['time_us']
40
40
  end
41
41
 
42
+ def unknown?
43
+ self.is_a?(Jetstream::UnknownMessage)
44
+ end
45
+
42
46
  def operations
43
47
  []
44
48
  end
@@ -6,13 +6,6 @@ require 'uri'
6
6
 
7
7
  module Skyfall
8
8
  class Jetstream < Stream
9
- def self.new(server, params = {})
10
- # to be removed in 0.6
11
- instance = self.allocate
12
- instance.send(:initialize, server, params)
13
- instance
14
- end
15
-
16
9
  attr_accessor :cursor
17
10
 
18
11
  def initialize(server, params = {})
@@ -2,6 +2,8 @@ require 'eventmachine'
2
2
  require 'faye/websocket'
3
3
  require 'uri'
4
4
 
5
+ require_relative 'version'
6
+
5
7
  module Skyfall
6
8
  class Stream
7
9
  EVENTS = %w(message raw_message connecting connect disconnect reconnect error timeout)
@@ -10,18 +12,6 @@ module Skyfall
10
12
  attr_accessor :auto_reconnect, :last_update, :user_agent
11
13
  attr_accessor :heartbeat_timeout, :heartbeat_interval, :check_heartbeat
12
14
 
13
- def self.new(server, endpoint = nil, cursor = nil)
14
- # to be removed in 0.6
15
- if endpoint || cursor
16
- STDERR.puts "Warning: Skyfall::Stream has been renamed to Skyfall::Firehose. This initializer will be removed in the next version."
17
- Firehose.new(server, endpoint, cursor)
18
- else
19
- instance = self.allocate
20
- instance.send(:initialize, server)
21
- instance
22
- end
23
- end
24
-
25
15
  def initialize(service)
26
16
  @root_url = build_root_url(service)
27
17
 
@@ -53,7 +43,7 @@ module Skyfall
53
43
  @handlers[:error]&.call(e)
54
44
  end
55
45
 
56
- @ws = Faye::WebSocket::Client.new(url, nil, { headers: { 'User-Agent' => user_agent }})
46
+ @ws = build_websocket_client(url)
57
47
 
58
48
  @ws.on(:open) do |e|
59
49
  @handlers[:connect]&.call
@@ -183,6 +173,10 @@ module Skyfall
183
173
  end
184
174
  end
185
175
 
176
+ def build_websocket_client(url)
177
+ Faye::WebSocket::Client.new(url, nil, { headers: { 'User-Agent' => user_agent }})
178
+ end
179
+
186
180
  def build_websocket_url
187
181
  @root_url
188
182
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skyfall
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyfall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Suder
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-15 00:00:00.000000000 Z
10
+ date: 2025-06-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base32
@@ -90,14 +89,14 @@ dependencies:
90
89
  requirements:
91
90
  - - "~>"
92
91
  - !ruby/object:Gem::Version
93
- version: '0.11'
92
+ version: '0.12'
94
93
  type: :runtime
95
94
  prerelease: false
96
95
  version_requirements: !ruby/object:Gem::Requirement
97
96
  requirements:
98
97
  - - "~>"
99
98
  - !ruby/object:Gem::Version
100
- version: '0.11'
99
+ version: '0.12'
101
100
  description: "\n Skyfall is a Ruby library for connecting to the \"firehose\" of
102
101
  the Bluesky social network, i.e. a websocket which\n streams all new posts and
103
102
  everything else happening on the Bluesky network in real time. The code connects
@@ -132,6 +131,7 @@ files:
132
131
  - lib/skyfall/firehose/labels_message.rb
133
132
  - lib/skyfall/firehose/message.rb
134
133
  - lib/skyfall/firehose/operation.rb
134
+ - lib/skyfall/firehose/sync_message.rb
135
135
  - lib/skyfall/firehose/tombstone_message.rb
136
136
  - lib/skyfall/firehose/unknown_message.rb
137
137
  - lib/skyfall/jetstream.rb
@@ -152,7 +152,6 @@ metadata:
152
152
  bug_tracker_uri: https://github.com/mackuba/skyfall/issues
153
153
  changelog_uri: https://github.com/mackuba/skyfall/blob/master/CHANGELOG.md
154
154
  source_code_uri: https://github.com/mackuba/skyfall
155
- post_install_message:
156
155
  rdoc_options: []
157
156
  require_paths:
158
157
  - lib
@@ -167,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
166
  - !ruby/object:Gem::Version
168
167
  version: '0'
169
168
  requirements: []
170
- rubygems_version: 3.4.10
171
- signing_key:
169
+ rubygems_version: 3.6.2
172
170
  specification_version: 4
173
171
  summary: A Ruby gem for streaming data from the Bluesky/AtProto firehose
174
172
  test_files: []