-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Show posts from firehose on dashboard
Add a list view of up to 500 firehose posts on the dashboard. This new feature introduces some changes in the plumbing in the serve command. Prevously there were only one channel that would allow the firehose to send create posts events to the db writer. Now both the db writer and server is interested in these events. Further more one channel is not enough for the server use case. In golang channels are single receiver. Even in a fan out pattern with multiple listeners, a message will be read by at most one receiver! To enable 1 to N broadcasting you need N channels. This commit introduces a new Broadcaster receiver struct that extends the sync.Mutex struct to handle locking so that go routines don't get into conflict when using the broadcaster. It contains a map of uuids keys (to identify a single SSE channel) and channel values. When a post is posted by the firehose to its channel glue code picks it up and passes it on to every channel in the broadcaster struct. To pass the posts to the client side dashboard Server Sent Events are used. The client creates an EventSource to initate the SSE connection. Upon connection the go server creates a channel and adds it to the broadcaster map. The first message passed by the server is the key identifying the SSE channel. This way the client can send a DELETE request before disconnecting to allow the server to clean up immediately. Otherwise the connection is held open until the underlying TCP connection disconnects and the server can no longer write to the connection. This can take a bit of time. The client shows the posts in a div which takes up at most 60% of the viewport height. it then uses scroll inside the element to allow scrolling posts. It only shows the data available in the firehose post format which means usernames and profile pictures are not available.
- Loading branch information
Showing
11 changed files
with
318 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer utilities { | ||
@variants responsive { | ||
/* Hide scrollbar for Chrome, Safari and Opera */ | ||
.no-scrollbar::-webkit-scrollbar { | ||
display: none; | ||
} | ||
|
||
/* Hide scrollbar for IE, Edge and Firefox */ | ||
.no-scrollbar { | ||
-ms-overflow-style: none; /* IE and Edge */ | ||
scrollbar-width: none; /* Firefox */ | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.