Conversation
Greptile OverviewGreptile SummaryAdds a new example demonstrating how to stream Bluesky posts from the Jetstream firehose to an S2 stream using WebSocket and the Producer API. Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Example as bluesky-firehose-to-s2.ts
participant S2 as S2 Client
participant Basin
participant Stream
participant Producer
participant WS as Bluesky Jetstream WebSocket
User->>Example: Run script
Example->>Example: Validate env vars (S2_ACCESS_TOKEN, S2_BASIN)
Example->>S2: new S2(config)
Example->>Basin: s2.basin(basinName)
Example->>Basin: streams.create(streamName)
alt Stream exists
Basin-->>Example: 409 Conflict
else Stream created
Basin-->>Example: Stream created
end
Example->>Stream: basin.stream(streamName)
Example->>Stream: appendSession()
Stream-->>Example: AppendSession
Example->>Producer: new Producer(BatchTransform, appendSession)
Example->>WS: new WebSocket(jetstreamUrl)
Example->>Example: Start logInterval (every 1s)
WS->>Example: onopen
Example->>Example: Log connection status
loop Firehose streaming
WS->>Example: onmessage(event)
Example->>Example: Parse JetstreamEvent
alt Not a create post
Example->>Example: Skip event
else Valid post with text
Example->>Producer: submit(AppendRecord)
Producer-->>Example: RecordSubmitTicket
Example->>Example: submitted++
Example->>Example: ticket.ack().then()
Note over Example: Async ack handler
Producer-->>Example: Ack resolved
Example->>Example: acked++
end
end
alt User presses Ctrl+C
User->>Example: SIGINT
Example->>WS: close()
else WebSocket error
WS->>Example: onerror
else WebSocket closed
WS->>Example: onclose
end
Example->>Example: clearInterval(logInterval)
Example->>Producer: close()
Example->>Stream: close()
Example->>Example: Log final stats
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.