ProtoRune. Firehose. Event
(proto_rune v0.5.1)
Copy Markdown
A single event decoded from the ATProto firehose.
Fields
:type- the event type::commit,:identity,:account,:handle,:migrate,:tombstone,:info,:erroror:unknown.:seq- the sequence number of the event. Feed it back as the:cursoroption ofProtoRune.Firehoseto resume the stream from this point.:repo- the DID of the repository the event belongs to.:time- the event timestamp as an ISO 8601 string.:rev- the repository revision (:commitevents only).:ops- the repository operations of a:commitevent.:blocks- the repository blocks of a:commitevent, CBOR-decoded and keyed by CID string. The record for an operation can be found atevent.blocks[to_string(op.cid)].:payload- the raw decoded frame payload, for event types without dedicated fields and for fields this module does not know about.
Summary
Functions
Returns true when any operation of a :commit event belongs to the
given collection or a collection under it.
Types
@type op() :: %{ action: :create | :update | :delete, path: String.t(), cid: ProtoRune.CID.t() | nil }
A repository operation within a :commit event.
:action-:create,:updateor:delete.:path- the record path, e.g."app.bsky.feed.post/3jxfb3nkkf22v".:cid- the record CID (nilfor deletions).
@type t() :: %ProtoRune.Firehose.Event{ blocks: %{optional(String.t()) => term()}, ops: [op()], payload: map(), repo: String.t() | nil, rev: String.t() | nil, seq: non_neg_integer() | nil, time: String.t() | nil, type: :commit | :identity | :account | :handle | :migrate | :tombstone | :info | :error | :unknown }
Functions
Returns true when any operation of a :commit event belongs to the
given collection or a collection under it.
The match is segment-aware: "app.bsky.feed" matches
"app.bsky.feed.post" but not "app.bsky.feedback.x". Non-commit
events carry no operations and always return false.
Examples
iex> Event.collection?(%Event{type: :commit, ops: [%{action: :create, path: "app.bsky.feed.post/abc", cid: nil}]}, "app.bsky.feed")
true
iex> Event.collection?(%Event{type: :commit, ops: [%{action: :create, path: "app.bsky.feedback.x/abc", cid: nil}]}, "app.bsky.feed")
false
iex> Event.collection?(%Event{type: :identity}, "app.bsky.feed")
false