Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database change notifications with Server-sent Events (SSE) #1807

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
784bfd9
Add for use with subscribing to database records with Server Sent Ev…
kodeFant Sep 1, 2023
fc9b092
Fix typo in module name
kodeFant Sep 1, 2023
e592b25
Remove commented code
kodeFant Sep 1, 2023
ee1ab07
Remove duplicate headers
kodeFant Sep 1, 2023
f514043
Try to improve formatting
kodeFant Sep 1, 2023
c21290e
Add some documentation
kodeFant Sep 1, 2023
9b51967
Catch errors on heartbeat
kodeFant Sep 1, 2023
d2a2550
Clean up code a bit
kodeFant Sep 1, 2023
81bdc7c
Document code
kodeFant Sep 1, 2023
eb4bf41
More precise comment
kodeFant Sep 1, 2023
b7d8184
Unsubscribe PGListener and gracefully shut down heartbeat loop after …
kodeFant Sep 2, 2023
6346369
More explicit imports
kodeFant Sep 2, 2023
020b125
Use header names provided by WAI library
kodeFant Sep 2, 2023
610ddd7
Add comment to cleanup runCleanupActions
kodeFant Sep 2, 2023
618f7f4
Whitespace adjustments
kodeFant Sep 2, 2023
1d605fc
Concentrate notification query and do some performance optimizations
kodeFant Sep 2, 2023
6c63526
Add comments
kodeFant Sep 2, 2023
cb2fb1b
Re-order imports so easier to scan
kodeFant Sep 2, 2023
acde116
Re-order imports so easier to scan
kodeFant Sep 2, 2023
2239175
Add comment about why notificationTrigger was written this way
kodeFant Sep 2, 2023
f95e9a1
Nitpick whitespace
kodeFant Sep 2, 2023
aef20b0
Rename to IHP.PGEventStore
kodeFant Sep 2, 2023
3242dbb
Correct comment
kodeFant Sep 2, 2023
13fdd23
Try to organize the order of the functions better
kodeFant Sep 2, 2023
555cb46
Try to organize the order of the functions better
kodeFant Sep 2, 2023
7a4d67d
Add comment to
kodeFant Sep 2, 2023
8f4c8a1
Go back on notificationTrigger. The simple one is probably better and…
kodeFant Sep 2, 2023
a8e608a
Use pge_ prefix on notification and trigger names
kodeFant Sep 2, 2023
fd73387
Improve comment
kodeFant Sep 2, 2023
c542997
Remove stream initialize message as it's not necessary
kodeFant Sep 3, 2023
41b5686
Remove unecessary abstraction
kodeFant Sep 3, 2023
0690dcd
improve heartbeat a bit an use readTVarIO
kodeFant Sep 3, 2023
ee7d54c
Make import syntax consistent with rest of IHP source
kodeFant Sep 3, 2023
cc7b7a0
Go with more readable event payload
kodeFant Sep 3, 2023
cd5532a
Add newline on end of event payload
kodeFant Sep 3, 2023
75f4e42
Add newline on end of event payload
kodeFant Sep 3, 2023
49093b6
Mostly cosmetic change
kodeFant Sep 3, 2023
1787941
Add space between colon and data
kodeFant Sep 3, 2023
1858acc
Add MDN reference
kodeFant Sep 3, 2023
8b717d9
Fix typo and formatting
kodeFant Sep 3, 2023
adc1720
Improve some comments and logging
kodeFant Sep 3, 2023
3b9c47e
Some comment clarifications
kodeFant Sep 3, 2023
f196190
Nitpick
kodeFant Sep 3, 2023
f5bc7f1
Remove unecessary imports
kodeFant Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More explicit imports
kodeFant committed Sep 2, 2023
commit 6346369d6923b6e47f238ba3d808b50a4236d7a0
6 changes: 3 additions & 3 deletions IHP/DBEvent.hs
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@ import qualified Data.Set as Set
import IHP.ModelSupport ( withTableReadTracker, withRowLevelSecurityDisabled, sqlExec, trackTableRead )
import qualified IHP.PGListener as PGListener
import qualified Database.PostgreSQL.Simple.Types as PG
import Data.String.Interpolate.IsString
import Data.String.Interpolate.IsString ( i )
import Network.Wai ( responseStream )
import qualified Control.Exception as Exception
import qualified Data.ByteString.Builder as ByteString
import IHP.ApplicationContext
import IHP.Controller.Context
import IHP.ApplicationContext ( ApplicationContext(pgListener) )
import IHP.Controller.Context ( fromContext, putContext )
import Network.HTTP.Types (status200)
import Network.HTTP.Types.Header ( hContentType )
import Control.Concurrent (threadDelay)