Class: Skyfall::Firehose
Overview
Most of the methods of this class that you might want to use are defined in Stream.
Client of a standard AT Protocol firehose websocket.
This is the main Skyfall class to use to connect to a CBOR-based firehose websocket endpoint like subscribeRepos (on a PDS or a relay).
To connect to the firehose, you need to:
-
create an instance of Firehose, passing it the hostname/URL of the server, name of the endpoint (normally
:subscribe_repos) and optionally a cursor -
set up callbacks to be run when connecting, disconnecting, when a message is received etc. (you need to set at least a message handler)
-
call Stream#connect to start the connection
-
handle the received messages (instances of a Message subclass)
Defined Under Namespace
Classes: AccountMessage, CommitMessage, IdentityMessage, InfoMessage, LabelsMessage, Message, Operation, SyncMessage, UnknownMessage
Constant Summary collapse
- SUBSCRIBE_REPOS =
the main firehose endpoint on a PDS or relay
"com.atproto.sync.subscribeRepos"- SUBSCRIBE_LABELS =
only used with moderation services (labellers)
"com.atproto.label.subscribeLabels"- NAMED_ENDPOINTS =
{ :subscribe_repos => SUBSCRIBE_REPOS, :subscribe_labels => SUBSCRIBE_LABELS }
Constants inherited from Stream
Stream::MAX_RECONNECT_INTERVAL
Instance Attribute Summary collapse
-
#cursor ⇒ Integer?
Current cursor (seq of the last seen message).
Attributes inherited from Stream
#auto_reconnect, #check_heartbeat, #heartbeat_interval, #heartbeat_timeout, #last_update, #user_agent
Instance Method Summary collapse
-
#initialize(server, endpoint = nil, cursor = nil) ⇒ Firehose
constructor
A new instance of Firehose.
Methods inherited from Stream
#connect, #default_user_agent, #disconnect, #inspect, #on_connect, #on_connecting, #on_disconnect, #on_error, #on_message, #on_raw_message, #on_reconnect, #on_timeout, #reconnect, #version_string
Constructor Details
#initialize(server, endpoint, cursor = nil) ⇒ Firehose #initialize(server, cursor = nil) ⇒ Firehose
Returns a new instance of Firehose.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/skyfall/firehose.rb', line 94 def initialize(server, endpoint = nil, cursor = nil) require_relative 'firehose/message' super(server) if cursor.nil? && (endpoint.nil? || endpoint.to_s =~ /\A\d+\z/) cursor = endpoint endpoint = :subscribe_repos end @endpoint = check_endpoint(endpoint) @cursor = check_cursor(cursor) @root_url = ensure_empty_path(@root_url) end |
Instance Attribute Details
#cursor ⇒ Integer?
Current cursor (seq of the last seen message)
67 68 69 |
# File 'lib/skyfall/firehose.rb', line 67 def cursor @cursor end |