Safe Haskell | None |
---|
IHP.DataSync.ControllerImpl
Contents
Synopsis
- type EnsureRLSEnabledFn = Text -> IO TableWithRLS
- type InstallTableChangeTriggerFn = TableWithRLS -> IO ()
- type SendJSONFn = DataSyncResponse -> IO ()
- type HandleCustomMessageFn = (DataSyncResponse -> IO ()) -> DataSyncMessage -> IO ()
- runDataSyncController :: (HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ?applicationContext :: ApplicationContext, ?context :: ControllerContext, ?modelContext :: ModelContext, ?state :: IORef DataSyncController, ToField (PrimaryKey (GetTableName CurrentUserRecord)), Typeable CurrentUserRecord, HasNewSessionUrl CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord))) => EnsureRLSEnabledFn -> InstallTableChangeTriggerFn -> IO ByteString -> SendJSONFn -> HandleCustomMessageFn -> (Text -> Renamer) -> IO ()
- buildMessageHandler :: (HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ?applicationContext :: ApplicationContext, ?context :: ControllerContext, ?modelContext :: ModelContext, ?state :: IORef DataSyncController, ToField (PrimaryKey (GetTableName CurrentUserRecord)), Typeable CurrentUserRecord, HasNewSessionUrl CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord))) => EnsureRLSEnabledFn -> InstallTableChangeTriggerFn -> SendJSONFn -> HandleCustomMessageFn -> (Text -> Renamer) -> DataSyncMessage -> IO ()
- cleanupAllSubscriptions :: (?state :: IORef DataSyncController, ?applicationContext :: ApplicationContext) => IO ()
- changesToValue :: Renamer -> [Change] -> Value
- runInModelContextWithTransaction :: (?state :: IORef DataSyncController, ?modelContext :: ModelContext) => ((?modelContext :: ModelContext) => IO result) -> Maybe UUID -> IO result
- findTransactionById :: (?state :: IORef DataSyncController) => UUID -> IO DataSyncTransaction
- ensureBelowTransactionLimit :: (?state :: IORef DataSyncController, ?context :: ControllerContext) => IO ()
- ensureBelowSubscriptionsLimit :: (?state :: IORef DataSyncController, ?context :: ControllerContext) => IO ()
- maxTransactionsPerConnection :: (?context :: ControllerContext) => Int
- maxSubscriptionsPerConnection :: (?context :: ControllerContext) => Int
- sqlQueryWithRLSAndTransactionId :: (?modelContext :: ModelContext, ToRow parameters, ?context :: ControllerContext, userId ~ Id CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord)), HasNewSessionUrl CurrentUserRecord, Typeable CurrentUserRecord, ?context :: ControllerContext, HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ToField userId, FromRow result, ?state :: IORef DataSyncController) => Maybe UUID -> Query -> parameters -> IO [result]
- sqlExecWithRLSAndTransactionId :: (?modelContext :: ModelContext, ToRow parameters, ?context :: ControllerContext, userId ~ Id CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord)), HasNewSessionUrl CurrentUserRecord, Typeable CurrentUserRecord, ?context :: ControllerContext, HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ToField userId, ?state :: IORef DataSyncController) => Maybe UUID -> Query -> parameters -> IO Int64
- atomicModifyIORef'' :: IORef t -> (t -> t) -> IO ()
Documentation
type EnsureRLSEnabledFn = Text -> IO TableWithRLS Source #
type InstallTableChangeTriggerFn = TableWithRLS -> IO () Source #
type SendJSONFn = DataSyncResponse -> IO () Source #
type HandleCustomMessageFn = (DataSyncResponse -> IO ()) -> DataSyncMessage -> IO () Source #
runDataSyncController :: (HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ?applicationContext :: ApplicationContext, ?context :: ControllerContext, ?modelContext :: ModelContext, ?state :: IORef DataSyncController, ToField (PrimaryKey (GetTableName CurrentUserRecord)), Typeable CurrentUserRecord, HasNewSessionUrl CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord))) => EnsureRLSEnabledFn -> InstallTableChangeTriggerFn -> IO ByteString -> SendJSONFn -> HandleCustomMessageFn -> (Text -> Renamer) -> IO () Source #
buildMessageHandler :: (HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ?applicationContext :: ApplicationContext, ?context :: ControllerContext, ?modelContext :: ModelContext, ?state :: IORef DataSyncController, ToField (PrimaryKey (GetTableName CurrentUserRecord)), Typeable CurrentUserRecord, HasNewSessionUrl CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord))) => EnsureRLSEnabledFn -> InstallTableChangeTriggerFn -> SendJSONFn -> HandleCustomMessageFn -> (Text -> Renamer) -> DataSyncMessage -> IO () Source #
cleanupAllSubscriptions :: (?state :: IORef DataSyncController, ?applicationContext :: ApplicationContext) => IO () Source #
runInModelContextWithTransaction :: (?state :: IORef DataSyncController, ?modelContext :: ModelContext) => ((?modelContext :: ModelContext) => IO result) -> Maybe UUID -> IO result Source #
findTransactionById :: (?state :: IORef DataSyncController) => UUID -> IO DataSyncTransaction Source #
ensureBelowTransactionLimit :: (?state :: IORef DataSyncController, ?context :: ControllerContext) => IO () Source #
Allow max 10 concurrent transactions per connection to avoid running out of database connections
Each transaction removes a database connection from the connection pool. If we don't limit the transactions,
a single user could take down the application by starting more than DBPoolMaxConnections
concurrent transactions. Then all database connections are removed from the connection pool and further database
queries for other users will fail.
ensureBelowSubscriptionsLimit :: (?state :: IORef DataSyncController, ?context :: ControllerContext) => IO () Source #
maxTransactionsPerConnection :: (?context :: ControllerContext) => Int Source #
maxSubscriptionsPerConnection :: (?context :: ControllerContext) => Int Source #
sqlQueryWithRLSAndTransactionId :: (?modelContext :: ModelContext, ToRow parameters, ?context :: ControllerContext, userId ~ Id CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord)), HasNewSessionUrl CurrentUserRecord, Typeable CurrentUserRecord, ?context :: ControllerContext, HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ToField userId, FromRow result, ?state :: IORef DataSyncController) => Maybe UUID -> Query -> parameters -> IO [result] Source #
sqlExecWithRLSAndTransactionId :: (?modelContext :: ModelContext, ToRow parameters, ?context :: ControllerContext, userId ~ Id CurrentUserRecord, Show (PrimaryKey (GetTableName CurrentUserRecord)), HasNewSessionUrl CurrentUserRecord, Typeable CurrentUserRecord, ?context :: ControllerContext, HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord)), ToField userId, ?state :: IORef DataSyncController) => Maybe UUID -> Query -> parameters -> IO Int64 Source #
atomicModifyIORef'' :: IORef t -> (t -> t) -> IO () Source #
Orphan instances
FromJSON DataSyncMessage Source # | |
Methods parseJSON :: Value -> Parser DataSyncMessage # parseJSONList :: Value -> Parser [DataSyncMessage] # | |
ToJSON DataSyncResponse Source # | |
Methods toJSON :: DataSyncResponse -> Value # toEncoding :: DataSyncResponse -> Encoding # toJSONList :: [DataSyncResponse] -> Value # toEncodingList :: [DataSyncResponse] -> Encoding # omitField :: DataSyncResponse -> Bool # | |
SetField "asyncs" DataSyncController [Async ()] Source # | |
Methods setField :: [Async ()] -> DataSyncController -> DataSyncController Source # | |
SetField "subscriptions" DataSyncController (HashMap UUID (MVar ())) Source # | |
Methods setField :: HashMap UUID (MVar ()) -> DataSyncController -> DataSyncController Source # | |
SetField "transactions" DataSyncController (HashMap UUID DataSyncTransaction) Source # | |
Methods setField :: HashMap UUID DataSyncTransaction -> DataSyncController -> DataSyncController Source # |