module Hasura.Eventing.Backend
  ( BackendEventTrigger (..),
  )
where

import Control.Monad.Trans.Control (MonadBaseControl)
import Data.Aeson
import Data.Set.NonEmpty qualified as NE
import Data.Time.Clock qualified as Time
import Hasura.Backends.MSSQL.DDL.EventTrigger qualified as MSSQL
import Hasura.Backends.Postgres.DDL.EventTrigger qualified as Postgres
import Hasura.Base.Error
import Hasura.Prelude
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.BackendType
import Hasura.RQL.Types.Column (ColumnInfo)
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.EventTrigger
import Hasura.RQL.Types.Eventing
import Hasura.RQL.Types.Session (UserInfo)
import Hasura.RQL.Types.Source
import Hasura.Server.Types (MaintenanceMode)
import Hasura.Table.Cache (PrimaryKey)
import Hasura.Tracing qualified as Tracing

-- | The @BackendEventTrigger@ type class contains functions which interacts
--   with the source database to perform event trigger related operations like
--   fetching pending events from the database or inserting a new invocation log
--   after processing an event.
class (Backend b) => BackendEventTrigger (b :: BackendType) where
  -- | insertManualEvent inserts the specified event in the event log table,
  --   note that this method should also set the trace context and session
  --   variables in the source database context (if available).
  insertManualEvent ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    TableName b ->
    TriggerName ->
    Value ->
    UserInfo ->
    Maybe Tracing.TraceContext ->
    m EventId

  -- | @fetchUndeliveredEvents@ fetches the undelivered events from the source
  --   and locks those events for processing. The locking is done so that when
  --   there are multiple instances of graphql-engine connected to the same
  --   source they don't end up processing the same events concurrently.
  --
  --   Also, it's crucial that the SQL query used to fetch events in this
  --   function uses something like Postgres's `FOR UPDATE SKIP LOCKED`
  --   mechanism so that it skips past the events which are locked by the
  --   database and pick newer undelivered events to achieve maximum throughput.
  --
  --   The locking mechanism for event triggers is timestamp based i.e. when an
  --   event is fetched from the database, the `locked` column will contain the
  --   timestamp of when it was fetched from the database. Undelivered events
  --   will have `NULL` value as their `locked` column value.
  --
  --   The idea behind having a timestamp based locking mechanism is that if the
  --   graphql-engine is shutdown abruptly with events being fetched by the
  --   events processor, it will be locked and after the shutdown it will remain
  --   locked. Now with a timestamp based lock, when the graphql-engine is
  --   started again it will also fetch events which have a `locked` value of
  --   older than 30 mins along with the undelivered events. So, this way no
  --   events remain in a `locked` state.
  --
  --   When fetching the events from the event_log table we also include the
  --   list of the triggers that exist in the metadata at that point of time,
  --   because we have seen in some cases there are events that do not belong to
  --   any of the event triggers present in the metadata and those are fetched
  --   only to be failed saying the said event trigger doesn't exist. So, to
  --   avoid this (atleast, as much as possible) we get only the events of the
  --   event triggers we have in the metadata.
  fetchUndeliveredEvents ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    SourceName ->
    -- | List of trigger names which exist in the metadata
    [TriggerName] ->
    MaintenanceMode () ->
    FetchBatchSize ->
    m [Event b]

  -- | Ad-hoc function to set a retry for an undelivered event
  setRetry ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    Event b ->
    Time.UTCTime ->
    MaintenanceMode MaintenanceModeVersion ->
    m ()

  -- | @getMaintenanceModeVersion@ gets the source catalog version from the
  --   source
  getMaintenanceModeVersion ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    m MaintenanceModeVersion

  -- | @recordSuccess@ records a successful event invocation, it does a couple
  --   of things,
  --
  --   1. Insert the invocation in the invocation logs table
  --   2. Mark the event as 'delivered' in the event_log table
  recordSuccess ::
    (MonadIO m) =>
    SourceConfig b ->
    Event b ->
    Invocation 'EventType ->
    MaintenanceMode MaintenanceModeVersion ->
    m (Either QErr ())

  -- | @recordError@ records an erronous event invocation, it does a couple of
  --   things,
  --
  --   1. Insert the invocation in the invocation logs table
  --   2. Depending on the value of `ProcessEventError`, it will either,
  --        - Set a retry for the given event
  --        - Mark the event as 'error'
  recordError ::
    (MonadIO m) =>
    SourceConfig b ->
    Event b ->
    Invocation 'EventType ->
    ProcessEventError ->
    MaintenanceMode MaintenanceModeVersion ->
    m (Either QErr ())

  -- | @recordError'@ records an erronous event invocation, it does a couple of
  --   things,
  --
  --   1. If present, insert the invocation in the invocation logs table
  --   2. Depending on the value of `ProcessEventError`, it will either,
  --        - Set a retry for the given event
  --        - Mark the event as 'error'
  recordError' ::
    (MonadIO m) =>
    SourceConfig b ->
    Event b ->
    Maybe (Invocation 'EventType) ->
    ProcessEventError ->
    MaintenanceMode MaintenanceModeVersion ->
    m (Either QErr ())

  -- | @dropTriggerAndArchiveEvents@ drops the database trigger and
  --   marks all the events related to the event trigger as archived.
  --   See Note [Cleanup for dropped triggers]
  dropTriggerAndArchiveEvents ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    TriggerName ->
    TableName b ->
    m ()

  -- | @dropDanglingSQLTriggger@ is used to delete the extraneous SQL triggers
  --   created by an event trigger. The extraneous SQL triggers can be created
  --   when an event trigger's definition is replaced to a new definition. For
  --   example, an event trigger `authors_all` had an INSERT and UPDATE trigger
  --   defined earlier and after it has UPDATE and DELETE triggers. So, in this
  --   case, we need to drop the trigger created by us earlier for the INSERT
  --   trigger.
  dropDanglingSQLTrigger ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    TriggerName ->
    TableName b ->
    HashSet Ops ->
    m ()

  redeliverEvent ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    EventId ->
    m ()

  -- | @unlockEventsInSource@ unlocks the cached locked events which were
  --   captured when a graceful shutdown is initiated, so that when the
  --   graphql-engine restarts these events can be fetched to process them
  --   immediately.
  unlockEventsInSource ::
    (MonadIO m) =>
    SourceConfig b ->
    NE.NESet EventId ->
    m (Either QErr Int)

  -- | @createMissingSQLTriggers@ checks in the source whether all the triggers
  --   exist according to the event trigger's specification. If any SQL trigger doesn't
  --   exist then it will create it.
  createMissingSQLTriggers ::
    (MonadIO m, MonadError QErr m, MonadBaseControl IO m, Backend b) =>
    SQLGenCtx ->
    SourceConfig b ->
    TableName b ->
    ([ColumnInfo b], Maybe (PrimaryKey b (ColumnInfo b))) ->
    TriggerName ->
    TriggerOnReplication ->
    TriggerOpsDef b ->
    m ()

  createTableEventTrigger ::
    (MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
    SQLGenCtx ->
    SourceConfig b ->
    TableName b ->
    [ColumnInfo b] ->
    TriggerName ->
    TriggerOnReplication ->
    TriggerOpsDef b ->
    -- TODO: Naveen: Find a better way to pass these extra, backend specific
    -- parameters instead of adding a bunch of Maybes to the type class
    -- functions.
    --
    -- Update event trigger on MS-SQL are only supported on tables with primary
    -- keys. Hence the PrimaryKey argument below.
    Maybe (PrimaryKey b (ColumnInfo b)) ->
    m (Either QErr ())

  checkIfTriggerExists ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    TriggerName ->
    HashSet Ops ->
    m Bool

  -- | @addCleanupSchedules@ adds cleanup logs for given trigger names and cleanup configs.
  --   This will perform the following steps:
  --
  --   1. Get last scheduled cleanup event and count.
  --   2. If count is less than 5, then add add more cleanup logs, else do nothing
  addCleanupSchedules ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    [(TriggerName, AutoTriggerLogCleanupConfig)] ->
    m ()

  -- | @deleteAllScheduledCleanups@ deletes all scheduled cleanup logs for a given event trigger
  deleteAllScheduledCleanups ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    TriggerName ->
    m ()

  -- | @getCleanupEventsForDeletion@ returns the cleanup logs that are to be deleted.
  -- This will perform the following steps:
  --
  -- 1. Get the scheduled cleanup events that were scheduled before current time.
  -- 2. If there are multiple entries for the same trigger name with different scheduled time,
  --    then fetch the latest entry and mark others as dead.
  getCleanupEventsForDeletion ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    m [(Text, TriggerName)]

  -- | @updateCleanupEventStatusToDead@ updates the event trigger cleanup logs as dead
  updateCleanupEventStatusToDead ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    [Text] ->
    m ()

  -- | @updateCleanupEventStatusToPaused@ updates the cleanup log status to `paused` if the event trigger configuration is paused.
  updateCleanupEventStatusToPaused ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    Text ->
    m ()

  -- | @updateCleanupEventStatusToCompleted@ updates the cleanup log status after the event logs are deleted.
  -- This will perform the following steps:
  --
  -- 1. Updates the cleanup config status to `completed`.
  -- 2. Updates the number of event logs and event invocation logs that were deleted for a trigger name
  updateCleanupEventStatusToCompleted ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    Text ->
    DeletedEventLogStats ->
    m ()

  -- | @deleteEventTriggerLogs@ deletes the event logs (and event invocation logs) based on the cleanup configuration given
  -- This will perform the following steps:
  --
  -- 1. Select all the dead events based on criteria set in the cleanup config.
  -- 2. Lock the events in the database so that other HGE instances don't pick them up for deletion.
  -- 3. Based on the config, perform the delete action.
  deleteEventTriggerLogs ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    TriggerLogCleanupConfig ->
    IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus)) ->
    m DeletedEventLogStats

  -- | @fetchEventLogs fetches event logs from the source for a given event trigger.
  fetchEventLogs ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    GetEventLogs b ->
    m [EventLog]

  -- | @fetchEventInvocationLogs fetches invocation logs from the source for a given event trigger.
  fetchEventInvocationLogs ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    GetEventInvocations b ->
    m [EventInvocationLog]

  -- | @fetchEventById fetches the event and it's invocation logs from the source for a given EventId.
  fetchEventById ::
    (MonadIO m, MonadError QErr m) =>
    SourceConfig b ->
    GetEventById b ->
    m (EventLogWithInvocations)

--------------------------------------------------------------------------------
-- TODO: move those instances to 'Backend/*/Instances/Eventing' and create a
-- corresponding 'Instances.hs' file in this directory to import them, similarly
-- to how we import instances for other backend classes. This would
-- significantly reduce the number of files in the core engine that end up
-- depending / importing backend-specific files.

instance BackendEventTrigger ('Postgres 'Vanilla) where
  insertManualEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
insertManualEvent = SourceConfig ('Postgres Any)
-> TableName ('Postgres Any)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TableName ('Postgres pgKind)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
Postgres.insertManualEvent
  fetchUndeliveredEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres 'Vanilla)]
fetchUndeliveredEvents = SourceConfig ('Postgres 'Vanilla)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres 'Vanilla)]
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres pgKind)]
Postgres.fetchUndeliveredEvents
  setRetry :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry = SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
Postgres.setRetry
  getMaintenanceModeVersion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla) -> m MaintenanceModeVersion
getMaintenanceModeVersion = SourceConfig ('Postgres Any) -> m MaintenanceModeVersion
SourceConfig ('Postgres 'Vanilla) -> m MaintenanceModeVersion
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> m MaintenanceModeVersion
Postgres.getMaintenanceModeVersion
  recordSuccess :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess = SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
Postgres.recordSuccess
  recordError :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError = SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
Postgres.recordError
  recordError' :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' = SourceConfig ('Postgres 'Vanilla)
-> Event ('Postgres 'Vanilla)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
Postgres.recordError'
  dropTriggerAndArchiveEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> TableName ('Postgres 'Vanilla) -> m ()
dropTriggerAndArchiveEvents = SourceConfig ('Postgres Any)
-> TriggerName -> QualifiedTable -> m ()
SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> TableName ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TriggerName -> QualifiedTable -> m ()
Postgres.dropTriggerAndArchiveEvents
  dropDanglingSQLTrigger :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> TriggerName
-> TableName ('Postgres 'Vanilla)
-> HashSet Ops
-> m ()
dropDanglingSQLTrigger = SourceConfig ('Postgres Any)
-> TriggerName -> QualifiedTable -> HashSet Ops -> m ()
SourceConfig ('Postgres 'Vanilla)
-> TriggerName
-> TableName ('Postgres 'Vanilla)
-> HashSet Ops
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TriggerName -> QualifiedTable -> HashSet Ops -> m ()
Postgres.dropDanglingSQLTrigger
  redeliverEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla) -> EventId -> m ()
redeliverEvent = SourceConfig ('Postgres Any) -> EventId -> m ()
SourceConfig ('Postgres 'Vanilla) -> EventId -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> EventId -> m ()
Postgres.redeliverEvent
  unlockEventsInSource :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Vanilla)
-> NESet EventId -> m (Either QErr Int)
unlockEventsInSource = SourceConfig ('Postgres Any)
-> NESet EventId -> m (Either QErr Int)
SourceConfig ('Postgres 'Vanilla)
-> NESet EventId -> m (Either QErr Int)
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> NESet EventId -> m (Either QErr Int)
Postgres.unlockEventsInSource
  createTableEventTrigger :: forall (m :: * -> *).
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
SQLGenCtx
-> SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> [ColumnInfo ('Postgres 'Vanilla)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Vanilla)
-> Maybe
     (PrimaryKey ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla)))
-> m (Either QErr ())
createTableEventTrigger = SQLGenCtx
-> SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> [ColumnInfo ('Postgres 'Vanilla)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Vanilla)
-> Maybe
     (PrimaryKey ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla)))
-> m (Either QErr ())
SQLGenCtx
-> PGSourceConfig
-> QualifiedTable
-> [ColumnInfo ('Postgres 'Vanilla)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Vanilla)
-> Maybe
     (PrimaryKey ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla)))
-> m (Either QErr ())
forall (pgKind :: PostgresKind) (m :: * -> *).
(Backend ('Postgres pgKind), MonadIO m, MonadBaseControl IO m) =>
SQLGenCtx
-> PGSourceConfig
-> QualifiedTable
-> [ColumnInfo ('Postgres pgKind)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres pgKind)
-> Maybe
     (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind)))
-> m (Either QErr ())
Postgres.createTableEventTrigger
  createMissingSQLTriggers :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend ('Postgres 'Vanilla)) =>
SQLGenCtx
-> SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> ([ColumnInfo ('Postgres 'Vanilla)],
    Maybe
      (PrimaryKey
         ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Vanilla)
-> m ()
createMissingSQLTriggers = SQLGenCtx
-> SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> ([ColumnInfo ('Postgres 'Vanilla)],
    Maybe
      (PrimaryKey
         ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Vanilla)
-> m ()
SQLGenCtx
-> PGSourceConfig
-> TableName ('Postgres 'Vanilla)
-> ([ColumnInfo ('Postgres 'Vanilla)],
    Maybe
      (PrimaryKey
         ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Vanilla)
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend ('Postgres pgKind)) =>
SQLGenCtx
-> PGSourceConfig
-> TableName ('Postgres pgKind)
-> ([ColumnInfo ('Postgres pgKind)],
    Maybe
      (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres pgKind)
-> m ()
Postgres.createMissingSQLTriggers
  checkIfTriggerExists :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists = SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> HashSet Ops -> m Bool
PGSourceConfig -> TriggerName -> HashSet Ops -> m Bool
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> TriggerName -> HashSet Ops -> m Bool
Postgres.checkIfTriggerExists
  addCleanupSchedules :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
addCleanupSchedules = SourceConfig ('Postgres 'Vanilla)
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
PGSourceConfig
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
Postgres.addCleanupSchedules
  deleteAllScheduledCleanups :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla) -> TriggerName -> m ()
deleteAllScheduledCleanups = SourceConfig ('Postgres 'Vanilla) -> TriggerName -> m ()
PGSourceConfig -> TriggerName -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> TriggerName -> m ()
Postgres.deleteAllScheduledCleanups
  getCleanupEventsForDeletion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla) -> m [(Text, TriggerName)]
getCleanupEventsForDeletion = SourceConfig ('Postgres 'Vanilla) -> m [(Text, TriggerName)]
PGSourceConfig -> m [(Text, TriggerName)]
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> m [(Text, TriggerName)]
Postgres.getCleanupEventsForDeletion
  updateCleanupEventStatusToDead :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla) -> [Text] -> m ()
updateCleanupEventStatusToDead = SourceConfig ('Postgres 'Vanilla) -> [Text] -> m ()
PGSourceConfig -> [Text] -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> [Text] -> m ()
Postgres.updateCleanupEventStatusToDead
  updateCleanupEventStatusToPaused :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla) -> Text -> m ()
updateCleanupEventStatusToPaused = SourceConfig ('Postgres 'Vanilla) -> Text -> m ()
PGSourceConfig -> Text -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> Text -> m ()
Postgres.updateCleanupEventStatusToPaused
  updateCleanupEventStatusToCompleted :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> Text -> DeletedEventLogStats -> m ()
updateCleanupEventStatusToCompleted = SourceConfig ('Postgres 'Vanilla)
-> Text -> DeletedEventLogStats -> m ()
PGSourceConfig -> Text -> DeletedEventLogStats -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> Text -> DeletedEventLogStats -> m ()
Postgres.updateCleanupEventStatusToCompleted
  deleteEventTriggerLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
deleteEventTriggerLogs = SourceConfig ('Postgres 'Vanilla)
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
PGSourceConfig
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
Postgres.deleteEventTriggerLogs
  fetchEventLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> GetEventLogs ('Postgres 'Vanilla) -> m [EventLog]
fetchEventLogs = SourceConfig ('Postgres 'Vanilla)
-> GetEventLogs ('Postgres 'Vanilla) -> m [EventLog]
PGSourceConfig -> GetEventLogs ('Postgres 'Vanilla) -> m [EventLog]
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
PGSourceConfig -> GetEventLogs b -> m [EventLog]
Postgres.fetchEventLogs
  fetchEventInvocationLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> GetEventInvocations ('Postgres 'Vanilla)
-> m [EventInvocationLog]
fetchEventInvocationLogs = SourceConfig ('Postgres 'Vanilla)
-> GetEventInvocations ('Postgres 'Vanilla)
-> m [EventInvocationLog]
PGSourceConfig
-> GetEventInvocations ('Postgres 'Vanilla)
-> m [EventInvocationLog]
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
PGSourceConfig -> GetEventInvocations b -> m [EventInvocationLog]
Postgres.fetchEventInvocationLogs
  fetchEventById :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Vanilla)
-> GetEventById ('Postgres 'Vanilla) -> m EventLogWithInvocations
fetchEventById = SourceConfig ('Postgres 'Vanilla)
-> GetEventById ('Postgres 'Vanilla) -> m EventLogWithInvocations
PGSourceConfig
-> GetEventById ('Postgres 'Vanilla) -> m EventLogWithInvocations
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
PGSourceConfig -> GetEventById b -> m EventLogWithInvocations
Postgres.fetchEventById

instance BackendEventTrigger ('Postgres 'Citus) where
  insertManualEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> TableName ('Postgres 'Citus)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
insertManualEvent SourceConfig ('Postgres 'Citus)
_ TableName ('Postgres 'Citus)
_ TriggerName
_ Value
_ UserInfo
_ Maybe TraceContext
_ = Code -> Text -> m EventId
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m EventId) -> Text -> m EventId
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  fetchUndeliveredEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres 'Citus)]
fetchUndeliveredEvents SourceConfig ('Postgres 'Citus)
_ SourceName
_ [TriggerName]
_ MaintenanceMode ()
_ FetchBatchSize
_ = Code -> Text -> m [Event ('Postgres 'Citus)]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  setRetry :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> Event ('Postgres 'Citus)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry SourceConfig ('Postgres 'Citus)
_ Event ('Postgres 'Citus)
_ UTCTime
_ MaintenanceMode MaintenanceModeVersion
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  recordSuccess :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Citus)
-> Event ('Postgres 'Citus)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess SourceConfig ('Postgres 'Citus)
_ Event ('Postgres 'Citus)
_ Invocation 'EventType
_ MaintenanceMode MaintenanceModeVersion
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  getMaintenanceModeVersion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus) -> m MaintenanceModeVersion
getMaintenanceModeVersion SourceConfig ('Postgres 'Citus)
_ = Code -> Text -> m MaintenanceModeVersion
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  recordError :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Citus)
-> Event ('Postgres 'Citus)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError SourceConfig ('Postgres 'Citus)
_ Event ('Postgres 'Citus)
_ Invocation 'EventType
_ ProcessEventError
_ MaintenanceMode MaintenanceModeVersion
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  recordError' :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Citus)
-> Event ('Postgres 'Citus)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' SourceConfig ('Postgres 'Citus)
_ Event ('Postgres 'Citus)
_ Maybe (Invocation 'EventType)
_ ProcessEventError
_ MaintenanceMode MaintenanceModeVersion
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  dropTriggerAndArchiveEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> TriggerName -> TableName ('Postgres 'Citus) -> m ()
dropTriggerAndArchiveEvents SourceConfig ('Postgres 'Citus)
_ TriggerName
_ TableName ('Postgres 'Citus)
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  dropDanglingSQLTrigger :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> TriggerName
-> TableName ('Postgres 'Citus)
-> HashSet Ops
-> m ()
dropDanglingSQLTrigger SourceConfig ('Postgres 'Citus)
_ TriggerName
_ TableName ('Postgres 'Citus)
_ HashSet Ops
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  redeliverEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus) -> EventId -> m ()
redeliverEvent SourceConfig ('Postgres 'Citus)
_ EventId
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  unlockEventsInSource :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Citus)
-> NESet EventId -> m (Either QErr Int)
unlockEventsInSource SourceConfig ('Postgres 'Citus)
_ NESet EventId
_ = ExceptT QErr m Int -> m (Either QErr Int)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m Int -> m (Either QErr Int))
-> ExceptT QErr m Int -> m (Either QErr Int)
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m Int
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  createTableEventTrigger :: forall (m :: * -> *).
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
SQLGenCtx
-> SourceConfig ('Postgres 'Citus)
-> TableName ('Postgres 'Citus)
-> [ColumnInfo ('Postgres 'Citus)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Citus)
-> Maybe
     (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus)))
-> m (Either QErr ())
createTableEventTrigger SQLGenCtx
_ SourceConfig ('Postgres 'Citus)
_ TableName ('Postgres 'Citus)
_ [ColumnInfo ('Postgres 'Citus)]
_ TriggerName
_ TriggerOnReplication
_ TriggerOpsDef ('Postgres 'Citus)
_ Maybe
  (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus)))
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for Citus sources"
  createMissingSQLTriggers :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend ('Postgres 'Citus)) =>
SQLGenCtx
-> SourceConfig ('Postgres 'Citus)
-> TableName ('Postgres 'Citus)
-> ([ColumnInfo ('Postgres 'Citus)],
    Maybe
      (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Citus)
-> m ()
createMissingSQLTriggers SQLGenCtx
_ SourceConfig ('Postgres 'Citus)
_ TableName ('Postgres 'Citus)
_ ([ColumnInfo ('Postgres 'Citus)],
 Maybe
   (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus))))
_ TriggerName
_ TriggerOnReplication
_ TriggerOpsDef ('Postgres 'Citus)
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  checkIfTriggerExists :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists SourceConfig ('Postgres 'Citus)
_ TriggerName
_ HashSet Ops
_ = Code -> Text -> m Bool
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m Bool) -> Text -> m Bool
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  addCleanupSchedules :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
addCleanupSchedules SourceConfig ('Postgres 'Citus)
_ [(TriggerName, AutoTriggerLogCleanupConfig)]
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  deleteAllScheduledCleanups :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus) -> TriggerName -> m ()
deleteAllScheduledCleanups SourceConfig ('Postgres 'Citus)
_ TriggerName
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  getCleanupEventsForDeletion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus) -> m [(Text, TriggerName)]
getCleanupEventsForDeletion SourceConfig ('Postgres 'Citus)
_ = Code -> Text -> m [(Text, TriggerName)]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [(Text, TriggerName)])
-> Text -> m [(Text, TriggerName)]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  updateCleanupEventStatusToDead :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus) -> [Text] -> m ()
updateCleanupEventStatusToDead SourceConfig ('Postgres 'Citus)
_ [Text]
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  updateCleanupEventStatusToPaused :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus) -> Text -> m ()
updateCleanupEventStatusToPaused SourceConfig ('Postgres 'Citus)
_ Text
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  updateCleanupEventStatusToCompleted :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> Text -> DeletedEventLogStats -> m ()
updateCleanupEventStatusToCompleted SourceConfig ('Postgres 'Citus)
_ Text
_ DeletedEventLogStats
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  deleteEventTriggerLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
deleteEventTriggerLogs SourceConfig ('Postgres 'Citus)
_ TriggerLogCleanupConfig
_ IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
_ = Code -> Text -> m DeletedEventLogStats
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m DeletedEventLogStats) -> Text -> m DeletedEventLogStats
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  fetchEventLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> GetEventLogs ('Postgres 'Citus) -> m [EventLog]
fetchEventLogs SourceConfig ('Postgres 'Citus)
_ GetEventLogs ('Postgres 'Citus)
_ = Code -> Text -> m [EventLog]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [EventLog]) -> Text -> m [EventLog]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  fetchEventInvocationLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> GetEventInvocations ('Postgres 'Citus) -> m [EventInvocationLog]
fetchEventInvocationLogs SourceConfig ('Postgres 'Citus)
_ GetEventInvocations ('Postgres 'Citus)
_ = Code -> Text -> m [EventInvocationLog]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [EventInvocationLog]) -> Text -> m [EventInvocationLog]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"
  fetchEventById :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Citus)
-> GetEventById ('Postgres 'Citus) -> m EventLogWithInvocations
fetchEventById SourceConfig ('Postgres 'Citus)
_ GetEventById ('Postgres 'Citus)
_ = Code -> Text -> m EventLogWithInvocations
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m EventLogWithInvocations)
-> Text -> m EventLogWithInvocations
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Citus sources"

instance BackendEventTrigger ('Postgres 'Cockroach) where
  insertManualEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
insertManualEvent = SourceConfig ('Postgres Any)
-> TableName ('Postgres Any)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TableName ('Postgres pgKind)
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
Postgres.insertManualEvent
  fetchUndeliveredEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres 'Cockroach)]
fetchUndeliveredEvents = SourceConfig ('Postgres 'Cockroach)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres 'Cockroach)]
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event ('Postgres pgKind)]
Postgres.fetchUndeliveredEvents
  setRetry :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry = SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
Postgres.setRetry
  getMaintenanceModeVersion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach) -> m MaintenanceModeVersion
getMaintenanceModeVersion = SourceConfig ('Postgres Any) -> m MaintenanceModeVersion
SourceConfig ('Postgres 'Cockroach) -> m MaintenanceModeVersion
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> m MaintenanceModeVersion
Postgres.getMaintenanceModeVersion
  recordSuccess :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess = SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
Postgres.recordSuccess
  recordError :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError = SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
Postgres.recordError
  recordError' :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' = SourceConfig ('Postgres 'Cockroach)
-> Event ('Postgres 'Cockroach)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> Event ('Postgres pgKind)
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
Postgres.recordError'
  dropTriggerAndArchiveEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> TableName ('Postgres 'Cockroach) -> m ()
dropTriggerAndArchiveEvents = SourceConfig ('Postgres Any)
-> TriggerName -> QualifiedTable -> m ()
SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> TableName ('Postgres 'Cockroach) -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TriggerName -> QualifiedTable -> m ()
Postgres.dropTriggerAndArchiveEvents
  dropDanglingSQLTrigger :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> TriggerName
-> TableName ('Postgres 'Cockroach)
-> HashSet Ops
-> m ()
dropDanglingSQLTrigger = SourceConfig ('Postgres Any)
-> TriggerName -> QualifiedTable -> HashSet Ops -> m ()
SourceConfig ('Postgres 'Cockroach)
-> TriggerName
-> TableName ('Postgres 'Cockroach)
-> HashSet Ops
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TriggerName -> QualifiedTable -> HashSet Ops -> m ()
Postgres.dropDanglingSQLTrigger
  redeliverEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach) -> EventId -> m ()
redeliverEvent = SourceConfig ('Postgres Any) -> EventId -> m ()
SourceConfig ('Postgres 'Cockroach) -> EventId -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> EventId -> m ()
Postgres.redeliverEvent
  unlockEventsInSource :: forall (m :: * -> *).
MonadIO m =>
SourceConfig ('Postgres 'Cockroach)
-> NESet EventId -> m (Either QErr Int)
unlockEventsInSource = SourceConfig ('Postgres Any)
-> NESet EventId -> m (Either QErr Int)
SourceConfig ('Postgres 'Cockroach)
-> NESet EventId -> m (Either QErr Int)
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> NESet EventId -> m (Either QErr Int)
Postgres.unlockEventsInSource
  createTableEventTrigger :: forall (m :: * -> *).
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
SQLGenCtx
-> SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> [ColumnInfo ('Postgres 'Cockroach)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Cockroach)
-> Maybe
     (PrimaryKey
        ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach)))
-> m (Either QErr ())
createTableEventTrigger = SQLGenCtx
-> SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> [ColumnInfo ('Postgres 'Cockroach)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Cockroach)
-> Maybe
     (PrimaryKey
        ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach)))
-> m (Either QErr ())
SQLGenCtx
-> PGSourceConfig
-> QualifiedTable
-> [ColumnInfo ('Postgres 'Cockroach)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Cockroach)
-> Maybe
     (PrimaryKey
        ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach)))
-> m (Either QErr ())
forall (pgKind :: PostgresKind) (m :: * -> *).
(Backend ('Postgres pgKind), MonadIO m, MonadBaseControl IO m) =>
SQLGenCtx
-> PGSourceConfig
-> QualifiedTable
-> [ColumnInfo ('Postgres pgKind)]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres pgKind)
-> Maybe
     (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind)))
-> m (Either QErr ())
Postgres.createTableEventTrigger
  createMissingSQLTriggers :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend ('Postgres 'Cockroach)) =>
SQLGenCtx
-> SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> ([ColumnInfo ('Postgres 'Cockroach)],
    Maybe
      (PrimaryKey
         ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Cockroach)
-> m ()
createMissingSQLTriggers = SQLGenCtx
-> SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> ([ColumnInfo ('Postgres 'Cockroach)],
    Maybe
      (PrimaryKey
         ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Cockroach)
-> m ()
SQLGenCtx
-> PGSourceConfig
-> TableName ('Postgres 'Cockroach)
-> ([ColumnInfo ('Postgres 'Cockroach)],
    Maybe
      (PrimaryKey
         ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres 'Cockroach)
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend ('Postgres pgKind)) =>
SQLGenCtx
-> PGSourceConfig
-> TableName ('Postgres pgKind)
-> ([ColumnInfo ('Postgres pgKind)],
    Maybe
      (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind))))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef ('Postgres pgKind)
-> m ()
Postgres.createMissingSQLTriggers
  checkIfTriggerExists :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists = SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> HashSet Ops -> m Bool
PGSourceConfig -> TriggerName -> HashSet Ops -> m Bool
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> TriggerName -> HashSet Ops -> m Bool
Postgres.checkIfTriggerExists
  addCleanupSchedules :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
addCleanupSchedules = SourceConfig ('Postgres 'Cockroach)
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
PGSourceConfig
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
Postgres.addCleanupSchedules
  deleteAllScheduledCleanups :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach) -> TriggerName -> m ()
deleteAllScheduledCleanups = SourceConfig ('Postgres 'Cockroach) -> TriggerName -> m ()
PGSourceConfig -> TriggerName -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> TriggerName -> m ()
Postgres.deleteAllScheduledCleanups
  getCleanupEventsForDeletion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach) -> m [(Text, TriggerName)]
getCleanupEventsForDeletion = SourceConfig ('Postgres 'Cockroach) -> m [(Text, TriggerName)]
PGSourceConfig -> m [(Text, TriggerName)]
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> m [(Text, TriggerName)]
Postgres.getCleanupEventsForDeletion
  updateCleanupEventStatusToDead :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach) -> [Text] -> m ()
updateCleanupEventStatusToDead = SourceConfig ('Postgres 'Cockroach) -> [Text] -> m ()
PGSourceConfig -> [Text] -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> [Text] -> m ()
Postgres.updateCleanupEventStatusToDead
  updateCleanupEventStatusToPaused :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach) -> Text -> m ()
updateCleanupEventStatusToPaused = SourceConfig ('Postgres 'Cockroach) -> Text -> m ()
PGSourceConfig -> Text -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> Text -> m ()
Postgres.updateCleanupEventStatusToPaused
  updateCleanupEventStatusToCompleted :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> Text -> DeletedEventLogStats -> m ()
updateCleanupEventStatusToCompleted = SourceConfig ('Postgres 'Cockroach)
-> Text -> DeletedEventLogStats -> m ()
PGSourceConfig -> Text -> DeletedEventLogStats -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> Text -> DeletedEventLogStats -> m ()
Postgres.updateCleanupEventStatusToCompleted
  deleteEventTriggerLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
deleteEventTriggerLogs = SourceConfig ('Postgres 'Cockroach)
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
PGSourceConfig
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
Postgres.deleteEventTriggerLogs
  fetchEventLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> GetEventLogs ('Postgres 'Cockroach) -> m [EventLog]
fetchEventLogs = SourceConfig ('Postgres 'Cockroach)
-> GetEventLogs ('Postgres 'Cockroach) -> m [EventLog]
PGSourceConfig
-> GetEventLogs ('Postgres 'Cockroach) -> m [EventLog]
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
PGSourceConfig -> GetEventLogs b -> m [EventLog]
Postgres.fetchEventLogs
  fetchEventInvocationLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> GetEventInvocations ('Postgres 'Cockroach)
-> m [EventInvocationLog]
fetchEventInvocationLogs = SourceConfig ('Postgres 'Cockroach)
-> GetEventInvocations ('Postgres 'Cockroach)
-> m [EventInvocationLog]
PGSourceConfig
-> GetEventInvocations ('Postgres 'Cockroach)
-> m [EventInvocationLog]
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
PGSourceConfig -> GetEventInvocations b -> m [EventInvocationLog]
Postgres.fetchEventInvocationLogs
  fetchEventById :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres 'Cockroach)
-> GetEventById ('Postgres 'Cockroach) -> m EventLogWithInvocations
fetchEventById = SourceConfig ('Postgres 'Cockroach)
-> GetEventById ('Postgres 'Cockroach) -> m EventLogWithInvocations
PGSourceConfig
-> GetEventById ('Postgres 'Cockroach) -> m EventLogWithInvocations
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
PGSourceConfig -> GetEventById b -> m EventLogWithInvocations
Postgres.fetchEventById

instance BackendEventTrigger 'MSSQL where
  insertManualEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> TableName 'MSSQL
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
insertManualEvent = MSSQLSourceConfig
-> TableName
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
SourceConfig 'MSSQL
-> TableName 'MSSQL
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> TableName
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
MSSQL.insertManualEvent
  fetchUndeliveredEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'MSSQL]
fetchUndeliveredEvents = MSSQLSourceConfig
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'MSSQL]
SourceConfig 'MSSQL
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'MSSQL]
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'MSSQL]
MSSQL.fetchUndeliveredEvents
  setRetry :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> Event 'MSSQL
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry = MSSQLSourceConfig
-> Event 'MSSQL
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
SourceConfig 'MSSQL
-> Event 'MSSQL
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> Event 'MSSQL
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
MSSQL.setRetry
  recordSuccess :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'MSSQL
-> Event 'MSSQL
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess = MSSQLSourceConfig
-> Event 'MSSQL
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
SourceConfig 'MSSQL
-> Event 'MSSQL
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *).
MonadIO m =>
MSSQLSourceConfig
-> Event 'MSSQL
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
MSSQL.recordSuccess
  getMaintenanceModeVersion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> m MaintenanceModeVersion
getMaintenanceModeVersion = MSSQLSourceConfig -> m MaintenanceModeVersion
SourceConfig 'MSSQL -> m MaintenanceModeVersion
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> m MaintenanceModeVersion
MSSQL.getMaintenanceModeVersion
  recordError :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'MSSQL
-> Event 'MSSQL
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError = MSSQLSourceConfig
-> Event 'MSSQL
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
SourceConfig 'MSSQL
-> Event 'MSSQL
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *).
MonadIO m =>
MSSQLSourceConfig
-> Event 'MSSQL
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
MSSQL.recordError
  recordError' :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'MSSQL
-> Event 'MSSQL
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' = MSSQLSourceConfig
-> Event 'MSSQL
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
SourceConfig 'MSSQL
-> Event 'MSSQL
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
forall (m :: * -> *).
MonadIO m =>
MSSQLSourceConfig
-> Event 'MSSQL
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
MSSQL.recordError'
  dropTriggerAndArchiveEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> TriggerName -> TableName 'MSSQL -> m ()
dropTriggerAndArchiveEvents = MSSQLSourceConfig -> TriggerName -> TableName -> m ()
SourceConfig 'MSSQL -> TriggerName -> TableName 'MSSQL -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> TriggerName -> TableName -> m ()
MSSQL.dropTriggerAndArchiveEvents
  redeliverEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> EventId -> m ()
redeliverEvent = MSSQLSourceConfig -> EventId -> m ()
SourceConfig 'MSSQL -> EventId -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> EventId -> m ()
MSSQL.redeliverEvent
  unlockEventsInSource :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'MSSQL -> NESet EventId -> m (Either QErr Int)
unlockEventsInSource = MSSQLSourceConfig -> NESet EventId -> m (Either QErr Int)
SourceConfig 'MSSQL -> NESet EventId -> m (Either QErr Int)
forall (m :: * -> *).
MonadIO m =>
MSSQLSourceConfig -> NESet EventId -> m (Either QErr Int)
MSSQL.unlockEventsInSource
  dropDanglingSQLTrigger :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> TriggerName -> TableName 'MSSQL -> HashSet Ops -> m ()
dropDanglingSQLTrigger = MSSQLSourceConfig
-> TriggerName -> TableName -> HashSet Ops -> m ()
SourceConfig 'MSSQL
-> TriggerName -> TableName 'MSSQL -> HashSet Ops -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> TriggerName -> TableName -> HashSet Ops -> m ()
MSSQL.dropDanglingSQLTrigger
  createTableEventTrigger :: forall (m :: * -> *).
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
SQLGenCtx
-> SourceConfig 'MSSQL
-> TableName 'MSSQL
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
createTableEventTrigger = SQLGenCtx
-> MSSQLSourceConfig
-> TableName
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
SQLGenCtx
-> SourceConfig 'MSSQL
-> TableName 'MSSQL
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
forall (m :: * -> *).
MonadIO m =>
SQLGenCtx
-> MSSQLSourceConfig
-> TableName
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
MSSQL.createTableEventTrigger
  createMissingSQLTriggers :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend 'MSSQL) =>
SQLGenCtx
-> SourceConfig 'MSSQL
-> TableName 'MSSQL
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> m ()
createMissingSQLTriggers = SQLGenCtx
-> MSSQLSourceConfig
-> TableName
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> m ()
SQLGenCtx
-> SourceConfig 'MSSQL
-> TableName 'MSSQL
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m) =>
SQLGenCtx
-> MSSQLSourceConfig
-> TableName
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'MSSQL
-> m ()
MSSQL.createMissingSQLTriggers
  checkIfTriggerExists :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists = MSSQLSourceConfig -> TriggerName -> HashSet Ops -> m Bool
SourceConfig 'MSSQL -> TriggerName -> HashSet Ops -> m Bool
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> TriggerName -> HashSet Ops -> m Bool
MSSQL.checkIfTriggerExists
  addCleanupSchedules :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
addCleanupSchedules = MSSQLSourceConfig
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
SourceConfig 'MSSQL
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
MSSQL.addCleanupSchedules
  deleteAllScheduledCleanups :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> TriggerName -> m ()
deleteAllScheduledCleanups = MSSQLSourceConfig -> TriggerName -> m ()
SourceConfig 'MSSQL -> TriggerName -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> TriggerName -> m ()
MSSQL.deleteAllScheduledCleanups
  getCleanupEventsForDeletion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> m [(Text, TriggerName)]
getCleanupEventsForDeletion = MSSQLSourceConfig -> m [(Text, TriggerName)]
SourceConfig 'MSSQL -> m [(Text, TriggerName)]
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> m [(Text, TriggerName)]
MSSQL.getCleanupEventsForDeletion
  updateCleanupEventStatusToDead :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> [Text] -> m ()
updateCleanupEventStatusToDead = MSSQLSourceConfig -> [Text] -> m ()
SourceConfig 'MSSQL -> [Text] -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> [Text] -> m ()
MSSQL.updateCleanupEventStatusToDead
  updateCleanupEventStatusToPaused :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> Text -> m ()
updateCleanupEventStatusToPaused = MSSQLSourceConfig -> Text -> m ()
SourceConfig 'MSSQL -> Text -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> Text -> m ()
MSSQL.updateCleanupEventStatusToPaused
  updateCleanupEventStatusToCompleted :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> Text -> DeletedEventLogStats -> m ()
updateCleanupEventStatusToCompleted = MSSQLSourceConfig -> Text -> DeletedEventLogStats -> m ()
SourceConfig 'MSSQL -> Text -> DeletedEventLogStats -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> Text -> DeletedEventLogStats -> m ()
MSSQL.updateCleanupEventStatusToCompleted
  deleteEventTriggerLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
deleteEventTriggerLogs = MSSQLSourceConfig
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
SourceConfig 'MSSQL
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
MSSQL.deleteEventTriggerLogs
  fetchEventInvocationLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> GetEventInvocations 'MSSQL -> m [EventInvocationLog]
fetchEventInvocationLogs = MSSQLSourceConfig
-> GetEventInvocations 'MSSQL -> m [EventInvocationLog]
SourceConfig 'MSSQL
-> GetEventInvocations 'MSSQL -> m [EventInvocationLog]
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
MSSQLSourceConfig
-> GetEventInvocations b -> m [EventInvocationLog]
MSSQL.fetchEventInvocationLogs
  fetchEventLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL -> GetEventLogs 'MSSQL -> m [EventLog]
fetchEventLogs = MSSQLSourceConfig -> GetEventLogs 'MSSQL -> m [EventLog]
SourceConfig 'MSSQL -> GetEventLogs 'MSSQL -> m [EventLog]
forall (m :: * -> *) (b :: BackendType).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> GetEventLogs b -> m [EventLog]
MSSQL.fetchEventLogs
  fetchEventById :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'MSSQL
-> GetEventById 'MSSQL -> m EventLogWithInvocations
fetchEventById = MSSQLSourceConfig
-> GetEventById 'MSSQL -> m EventLogWithInvocations
SourceConfig 'MSSQL
-> GetEventById 'MSSQL -> m EventLogWithInvocations
forall (m :: * -> *) (b :: BackendType).
(MonadError QErr m, MonadIO m) =>
MSSQLSourceConfig -> GetEventById b -> m EventLogWithInvocations
MSSQL.fetchEventById

instance BackendEventTrigger 'BigQuery where
  insertManualEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> TableName 'BigQuery
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
insertManualEvent SourceConfig 'BigQuery
_ TableName 'BigQuery
_ TriggerName
_ Value
_ UserInfo
_ Maybe TraceContext
_ = Code -> Text -> m EventId
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m EventId) -> Text -> m EventId
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  fetchUndeliveredEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'BigQuery]
fetchUndeliveredEvents SourceConfig 'BigQuery
_ SourceName
_ [TriggerName]
_ MaintenanceMode ()
_ FetchBatchSize
_ = Code -> Text -> m [Event 'BigQuery]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  setRetry :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> Event 'BigQuery
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry SourceConfig 'BigQuery
_ Event 'BigQuery
_ UTCTime
_ MaintenanceMode MaintenanceModeVersion
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  recordSuccess :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'BigQuery
-> Event 'BigQuery
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess SourceConfig 'BigQuery
_ Event 'BigQuery
_ Invocation 'EventType
_ MaintenanceMode MaintenanceModeVersion
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  getMaintenanceModeVersion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> m MaintenanceModeVersion
getMaintenanceModeVersion SourceConfig 'BigQuery
_ = Code -> Text -> m MaintenanceModeVersion
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  recordError :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'BigQuery
-> Event 'BigQuery
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError SourceConfig 'BigQuery
_ Event 'BigQuery
_ Invocation 'EventType
_ ProcessEventError
_ MaintenanceMode MaintenanceModeVersion
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  recordError' :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'BigQuery
-> Event 'BigQuery
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' SourceConfig 'BigQuery
_ Event 'BigQuery
_ Maybe (Invocation 'EventType)
_ ProcessEventError
_ MaintenanceMode MaintenanceModeVersion
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  dropTriggerAndArchiveEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> TriggerName -> TableName 'BigQuery -> m ()
dropTriggerAndArchiveEvents SourceConfig 'BigQuery
_ TriggerName
_ TableName 'BigQuery
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  dropDanglingSQLTrigger :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> TriggerName -> TableName 'BigQuery -> HashSet Ops -> m ()
dropDanglingSQLTrigger SourceConfig 'BigQuery
_ TriggerName
_ TableName 'BigQuery
_ HashSet Ops
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  redeliverEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> EventId -> m ()
redeliverEvent SourceConfig 'BigQuery
_ EventId
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  unlockEventsInSource :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'BigQuery -> NESet EventId -> m (Either QErr Int)
unlockEventsInSource SourceConfig 'BigQuery
_ NESet EventId
_ = ExceptT QErr m Int -> m (Either QErr Int)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m Int -> m (Either QErr Int))
-> ExceptT QErr m Int -> m (Either QErr Int)
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m Int
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  createTableEventTrigger :: forall (m :: * -> *).
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
SQLGenCtx
-> SourceConfig 'BigQuery
-> TableName 'BigQuery
-> [ColumnInfo 'BigQuery]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'BigQuery
-> Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery))
-> m (Either QErr ())
createTableEventTrigger SQLGenCtx
_ SourceConfig 'BigQuery
_ TableName 'BigQuery
_ [ColumnInfo 'BigQuery]
_ TriggerName
_ TriggerOnReplication
_ TriggerOpsDef 'BigQuery
_ Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery))
_ = ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for BigQuery sources"
  createMissingSQLTriggers :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend 'BigQuery) =>
SQLGenCtx
-> SourceConfig 'BigQuery
-> TableName 'BigQuery
-> ([ColumnInfo 'BigQuery],
    Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery)))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'BigQuery
-> m ()
createMissingSQLTriggers SQLGenCtx
_ SourceConfig 'BigQuery
_ TableName 'BigQuery
_ ([ColumnInfo 'BigQuery],
 Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery)))
_ TriggerName
_ TriggerOnReplication
_ TriggerOpsDef 'BigQuery
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  checkIfTriggerExists :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists SourceConfig 'BigQuery
_ TriggerName
_ HashSet Ops
_ = Code -> Text -> m Bool
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m Bool) -> Text -> m Bool
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  addCleanupSchedules :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
addCleanupSchedules SourceConfig 'BigQuery
_ [(TriggerName, AutoTriggerLogCleanupConfig)]
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  deleteAllScheduledCleanups :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> TriggerName -> m ()
deleteAllScheduledCleanups SourceConfig 'BigQuery
_ TriggerName
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  getCleanupEventsForDeletion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> m [(Text, TriggerName)]
getCleanupEventsForDeletion SourceConfig 'BigQuery
_ = Code -> Text -> m [(Text, TriggerName)]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [(Text, TriggerName)])
-> Text -> m [(Text, TriggerName)]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  updateCleanupEventStatusToDead :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> [Text] -> m ()
updateCleanupEventStatusToDead SourceConfig 'BigQuery
_ [Text]
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  updateCleanupEventStatusToPaused :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> Text -> m ()
updateCleanupEventStatusToPaused SourceConfig 'BigQuery
_ Text
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  updateCleanupEventStatusToCompleted :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> Text -> DeletedEventLogStats -> m ()
updateCleanupEventStatusToCompleted SourceConfig 'BigQuery
_ Text
_ DeletedEventLogStats
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  deleteEventTriggerLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
deleteEventTriggerLogs SourceConfig 'BigQuery
_ TriggerLogCleanupConfig
_ IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
_ = Code -> Text -> m DeletedEventLogStats
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m DeletedEventLogStats) -> Text -> m DeletedEventLogStats
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  fetchEventLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery -> GetEventLogs 'BigQuery -> m [EventLog]
fetchEventLogs SourceConfig 'BigQuery
_ GetEventLogs 'BigQuery
_ = Code -> Text -> m [EventLog]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [EventLog]) -> Text -> m [EventLog]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  fetchEventInvocationLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> GetEventInvocations 'BigQuery -> m [EventInvocationLog]
fetchEventInvocationLogs SourceConfig 'BigQuery
_ GetEventInvocations 'BigQuery
_ = Code -> Text -> m [EventInvocationLog]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [EventInvocationLog]) -> Text -> m [EventInvocationLog]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"
  fetchEventById :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'BigQuery
-> GetEventById 'BigQuery -> m EventLogWithInvocations
fetchEventById SourceConfig 'BigQuery
_ GetEventById 'BigQuery
_ = Code -> Text -> m EventLogWithInvocations
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m EventLogWithInvocations)
-> Text -> m EventLogWithInvocations
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for BigQuery sources"

--------------------------------------------------------------------------------

-- TODO(jkachmar): See if there isn't a way to define the function that
-- implement these methods in the 'Hasura.Experimental.Adapters' module
-- hierarchy just to keep everything as tidy as possible for that section of
-- code.
instance BackendEventTrigger 'DataConnector where
  insertManualEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> TableName 'DataConnector
-> TriggerName
-> Value
-> UserInfo
-> Maybe TraceContext
-> m EventId
insertManualEvent SourceConfig 'DataConnector
_ TableName 'DataConnector
_ TriggerName
_ Value
_ UserInfo
_ Maybe TraceContext
_ =
    Code -> Text -> m EventId
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  fetchUndeliveredEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'DataConnector]
fetchUndeliveredEvents SourceConfig 'DataConnector
_ SourceName
_ [TriggerName]
_ MaintenanceMode ()
_ FetchBatchSize
_ =
    Code -> Text -> m [Event 'DataConnector]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  setRetry :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> Event 'DataConnector
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry SourceConfig 'DataConnector
_ Event 'DataConnector
_ UTCTime
_ MaintenanceMode MaintenanceModeVersion
_ =
    Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  recordSuccess :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'DataConnector
-> Event 'DataConnector
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess SourceConfig 'DataConnector
_ Event 'DataConnector
_ Invocation 'EventType
_ MaintenanceMode MaintenanceModeVersion
_ =
    ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  getMaintenanceModeVersion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> m MaintenanceModeVersion
getMaintenanceModeVersion SourceConfig 'DataConnector
_ =
    Code -> Text -> m MaintenanceModeVersion
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  recordError :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'DataConnector
-> Event 'DataConnector
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError SourceConfig 'DataConnector
_ Event 'DataConnector
_ Invocation 'EventType
_ ProcessEventError
_ MaintenanceMode MaintenanceModeVersion
_ =
    ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  recordError' :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'DataConnector
-> Event 'DataConnector
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' SourceConfig 'DataConnector
_ Event 'DataConnector
_ Maybe (Invocation 'EventType)
_ ProcessEventError
_ MaintenanceMode MaintenanceModeVersion
_ =
    ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  dropTriggerAndArchiveEvents :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> TriggerName -> TableName 'DataConnector -> m ()
dropTriggerAndArchiveEvents SourceConfig 'DataConnector
_ TriggerName
_ TableName 'DataConnector
_ =
    Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  dropDanglingSQLTrigger :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> TriggerName -> TableName 'DataConnector -> HashSet Ops -> m ()
dropDanglingSQLTrigger SourceConfig 'DataConnector
_ TriggerName
_ TableName 'DataConnector
_ HashSet Ops
_ =
    Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend"
  redeliverEvent :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> EventId -> m ()
redeliverEvent SourceConfig 'DataConnector
_ EventId
_ =
    Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  unlockEventsInSource :: forall (m :: * -> *).
MonadIO m =>
SourceConfig 'DataConnector -> NESet EventId -> m (Either QErr Int)
unlockEventsInSource SourceConfig 'DataConnector
_ NESet EventId
_ =
    ExceptT QErr m Int -> m (Either QErr Int)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m Int -> m (Either QErr Int))
-> ExceptT QErr m Int -> m (Either QErr Int)
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m Int
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  createTableEventTrigger :: forall (m :: * -> *).
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
SQLGenCtx
-> SourceConfig 'DataConnector
-> TableName 'DataConnector
-> [ColumnInfo 'DataConnector]
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'DataConnector
-> Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector))
-> m (Either QErr ())
createTableEventTrigger SQLGenCtx
_ SourceConfig 'DataConnector
_ TableName 'DataConnector
_ [ColumnInfo 'DataConnector]
_ TriggerName
_ TriggerOnReplication
_ TriggerOpsDef 'DataConnector
_ Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector))
_ =
    ExceptT QErr m () -> m (Either QErr ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m () -> m (Either QErr ()))
-> ExceptT QErr m () -> m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Code -> Text -> ExceptT QErr m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for the Data Connector backend."
  createMissingSQLTriggers :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 Backend 'DataConnector) =>
SQLGenCtx
-> SourceConfig 'DataConnector
-> TableName 'DataConnector
-> ([ColumnInfo 'DataConnector],
    Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector)))
-> TriggerName
-> TriggerOnReplication
-> TriggerOpsDef 'DataConnector
-> m ()
createMissingSQLTriggers SQLGenCtx
_ SourceConfig 'DataConnector
_ TableName 'DataConnector
_ ([ColumnInfo 'DataConnector],
 Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector)))
_ TriggerName
_ TriggerOnReplication
_ TriggerOpsDef 'DataConnector
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector backend."
  checkIfTriggerExists :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists SourceConfig 'DataConnector
_ TriggerName
_ HashSet Ops
_ = Code -> Text -> m Bool
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m Bool) -> Text -> m Bool
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector backend."
  addCleanupSchedules :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> [(TriggerName, AutoTriggerLogCleanupConfig)] -> m ()
addCleanupSchedules SourceConfig 'DataConnector
_ [(TriggerName, AutoTriggerLogCleanupConfig)]
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector backend."
  deleteAllScheduledCleanups :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> TriggerName -> m ()
deleteAllScheduledCleanups SourceConfig 'DataConnector
_ TriggerName
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector backend."
  getCleanupEventsForDeletion :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> m [(Text, TriggerName)]
getCleanupEventsForDeletion SourceConfig 'DataConnector
_ = Code -> Text -> m [(Text, TriggerName)]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [(Text, TriggerName)])
-> Text -> m [(Text, TriggerName)]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  updateCleanupEventStatusToDead :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> [Text] -> m ()
updateCleanupEventStatusToDead SourceConfig 'DataConnector
_ [Text]
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  updateCleanupEventStatusToPaused :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> Text -> m ()
updateCleanupEventStatusToPaused SourceConfig 'DataConnector
_ Text
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  updateCleanupEventStatusToCompleted :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector -> Text -> DeletedEventLogStats -> m ()
updateCleanupEventStatusToCompleted SourceConfig 'DataConnector
_ Text
_ DeletedEventLogStats
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  deleteEventTriggerLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> TriggerLogCleanupConfig
-> IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
-> m DeletedEventLogStats
deleteEventTriggerLogs SourceConfig 'DataConnector
_ TriggerLogCleanupConfig
_ IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus))
_ = Code -> Text -> m DeletedEventLogStats
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m DeletedEventLogStats) -> Text -> m DeletedEventLogStats
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  fetchEventLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> GetEventLogs 'DataConnector -> m [EventLog]
fetchEventLogs SourceConfig 'DataConnector
_ GetEventLogs 'DataConnector
_ = Code -> Text -> m [EventLog]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [EventLog]) -> Text -> m [EventLog]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  fetchEventInvocationLogs :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> GetEventInvocations 'DataConnector -> m [EventInvocationLog]
fetchEventInvocationLogs SourceConfig 'DataConnector
_ GetEventInvocations 'DataConnector
_ = Code -> Text -> m [EventInvocationLog]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m [EventInvocationLog]) -> Text -> m [EventInvocationLog]
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"
  fetchEventById :: forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
SourceConfig 'DataConnector
-> GetEventById 'DataConnector -> m EventLogWithInvocations
fetchEventById SourceConfig 'DataConnector
_ GetEventById 'DataConnector
_ = Code -> Text -> m EventLogWithInvocations
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported (Text -> m EventLogWithInvocations)
-> Text -> m EventLogWithInvocations
forall a b. (a -> b) -> a -> b
$ Text
"Event triggers are not supported for Data Connector sources"