module Hasura.RQL.Types.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 PG
import Hasura.Base.Error
import Hasura.Prelude
import Hasura.RQL.Types.Backend
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.Source
import Hasura.RQL.Types.Table (PrimaryKey)
import Hasura.SQL.Backend
import Hasura.Server.Types (HasServerConfigCtx, MaintenanceMode, ServerConfigCtx)
import Hasura.Session (UserInfo)
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 ->
    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, HasServerConfigCtx m) =>
    SourceConfig b ->
    TableName b ->
    ([ColumnInfo b], Maybe (PrimaryKey b (ColumnInfo b))) ->
    TriggerName ->
    TriggerOpsDef b ->
    m ()

  createTableEventTrigger ::
    (MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
    ServerConfigCtx ->
    SourceConfig b ->
    TableName b ->
    [ColumnInfo b] ->
    TriggerName ->
    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

--------------------------------------------------------------------------------
-- 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 :: SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent = SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TableName ('Postgres pgKind)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
PG.insertManualEvent
  fetchUndeliveredEvents :: 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)]
PG.fetchUndeliveredEvents
  setRetry :: 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 ()
PG.setRetry
  getMaintenanceModeVersion :: SourceConfig ('Postgres 'Vanilla) -> m MaintenanceModeVersion
getMaintenanceModeVersion = SourceConfig ('Postgres 'Vanilla) -> m MaintenanceModeVersion
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> m MaintenanceModeVersion
PG.getMaintenanceModeVersion
  recordSuccess :: 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 ())
PG.recordSuccess
  recordError :: 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 ())
PG.recordError
  recordError' :: 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 ())
PG.recordError'
  dropTriggerAndArchiveEvents :: SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> TableName ('Postgres 'Vanilla) -> m ()
dropTriggerAndArchiveEvents = SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> TableName ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TriggerName -> QualifiedTable -> m ()
PG.dropTriggerAndArchiveEvents
  dropDanglingSQLTrigger :: SourceConfig ('Postgres 'Vanilla)
-> TriggerName
-> TableName ('Postgres 'Vanilla)
-> HashSet Ops
-> m ()
dropDanglingSQLTrigger = 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 ()
PG.dropDanglingSQLTrigger
  redeliverEvent :: SourceConfig ('Postgres 'Vanilla) -> EventId -> m ()
redeliverEvent = SourceConfig ('Postgres 'Vanilla) -> EventId -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> EventId -> m ()
PG.redeliverEvent
  unlockEventsInSource :: SourceConfig ('Postgres 'Vanilla)
-> NESet EventId -> m (Either QErr Int)
unlockEventsInSource = SourceConfig ('Postgres 'Vanilla)
-> NESet EventId -> m (Either QErr Int)
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> NESet EventId -> m (Either QErr Int)
PG.unlockEventsInSource
  createTableEventTrigger :: ServerConfigCtx
-> SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> [ColumnInfo ('Postgres 'Vanilla)]
-> TriggerName
-> TriggerOpsDef ('Postgres 'Vanilla)
-> Maybe
     (PrimaryKey ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla)))
-> m (Either QErr ())
createTableEventTrigger = ServerConfigCtx
-> SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> [ColumnInfo ('Postgres 'Vanilla)]
-> TriggerName
-> 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) =>
ServerConfigCtx
-> PGSourceConfig
-> QualifiedTable
-> [ColumnInfo ('Postgres pgKind)]
-> TriggerName
-> TriggerOpsDef ('Postgres pgKind)
-> Maybe
     (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind)))
-> m (Either QErr ())
PG.createTableEventTrigger
  createMissingSQLTriggers :: SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> ([ColumnInfo ('Postgres 'Vanilla)],
    Maybe
      (PrimaryKey
         ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla))))
-> TriggerName
-> TriggerOpsDef ('Postgres 'Vanilla)
-> m ()
createMissingSQLTriggers = SourceConfig ('Postgres 'Vanilla)
-> TableName ('Postgres 'Vanilla)
-> ([ColumnInfo ('Postgres 'Vanilla)],
    Maybe
      (PrimaryKey
         ('Postgres 'Vanilla) (ColumnInfo ('Postgres 'Vanilla))))
-> TriggerName
-> TriggerOpsDef ('Postgres 'Vanilla)
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 HasServerConfigCtx m, Backend ('Postgres pgKind)) =>
PGSourceConfig
-> TableName ('Postgres pgKind)
-> ([ColumnInfo ('Postgres pgKind)],
    Maybe
      (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind))))
-> TriggerName
-> TriggerOpsDef ('Postgres pgKind)
-> m ()
PG.createMissingSQLTriggers
  checkIfTriggerExists :: SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists = SourceConfig ('Postgres 'Vanilla)
-> TriggerName -> HashSet Ops -> m Bool
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> TriggerName -> HashSet Ops -> m Bool
PG.checkIfTriggerExists

instance BackendEventTrigger ('Postgres 'Citus) where
  insertManualEvent :: SourceConfig ('Postgres 'Citus)
-> TableName ('Postgres 'Citus)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent SourceConfig ('Postgres 'Citus)
_ TableName ('Postgres 'Citus)
_ TriggerName
_ Value
_ UserInfo
_ 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 :: 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 :: 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 :: 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 :: 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 :: 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' :: 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 :: 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 :: 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 :: 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 :: 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 :: ServerConfigCtx
-> SourceConfig ('Postgres 'Citus)
-> TableName ('Postgres 'Citus)
-> [ColumnInfo ('Postgres 'Citus)]
-> TriggerName
-> TriggerOpsDef ('Postgres 'Citus)
-> Maybe
     (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus)))
-> m (Either QErr ())
createTableEventTrigger ServerConfigCtx
_ SourceConfig ('Postgres 'Citus)
_ TableName ('Postgres 'Citus)
_ [ColumnInfo ('Postgres 'Citus)]
_ TriggerName
_ 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 :: SourceConfig ('Postgres 'Citus)
-> TableName ('Postgres 'Citus)
-> ([ColumnInfo ('Postgres 'Citus)],
    Maybe
      (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus))))
-> TriggerName
-> TriggerOpsDef ('Postgres 'Citus)
-> m ()
createMissingSQLTriggers SourceConfig ('Postgres 'Citus)
_ TableName ('Postgres 'Citus)
_ ([ColumnInfo ('Postgres 'Citus)],
 Maybe
   (PrimaryKey ('Postgres 'Citus) (ColumnInfo ('Postgres 'Citus))))
_ TriggerName
_ 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 :: 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"

instance BackendEventTrigger ('Postgres 'Cockroach) where
  insertManualEvent :: SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent = SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TableName ('Postgres pgKind)
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
PG.insertManualEvent
  fetchUndeliveredEvents :: 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)]
PG.fetchUndeliveredEvents
  setRetry :: 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 ()
PG.setRetry
  getMaintenanceModeVersion :: SourceConfig ('Postgres 'Cockroach) -> m MaintenanceModeVersion
getMaintenanceModeVersion = SourceConfig ('Postgres 'Cockroach) -> m MaintenanceModeVersion
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> m MaintenanceModeVersion
PG.getMaintenanceModeVersion
  recordSuccess :: 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 ())
PG.recordSuccess
  recordError :: 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 ())
PG.recordError
  recordError' :: 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 ())
PG.recordError'
  dropTriggerAndArchiveEvents :: SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> TableName ('Postgres 'Cockroach) -> m ()
dropTriggerAndArchiveEvents = SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> TableName ('Postgres 'Cockroach) -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind)
-> TriggerName -> QualifiedTable -> m ()
PG.dropTriggerAndArchiveEvents
  dropDanglingSQLTrigger :: SourceConfig ('Postgres 'Cockroach)
-> TriggerName
-> TableName ('Postgres 'Cockroach)
-> HashSet Ops
-> m ()
dropDanglingSQLTrigger = 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 ()
PG.dropDanglingSQLTrigger
  redeliverEvent :: SourceConfig ('Postgres 'Cockroach) -> EventId -> m ()
redeliverEvent = SourceConfig ('Postgres 'Cockroach) -> EventId -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m) =>
SourceConfig ('Postgres pgKind) -> EventId -> m ()
PG.redeliverEvent
  unlockEventsInSource :: SourceConfig ('Postgres 'Cockroach)
-> NESet EventId -> m (Either QErr Int)
unlockEventsInSource = SourceConfig ('Postgres 'Cockroach)
-> NESet EventId -> m (Either QErr Int)
forall (m :: * -> *) (pgKind :: PostgresKind).
MonadIO m =>
SourceConfig ('Postgres pgKind)
-> NESet EventId -> m (Either QErr Int)
PG.unlockEventsInSource
  createTableEventTrigger :: ServerConfigCtx
-> SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> [ColumnInfo ('Postgres 'Cockroach)]
-> TriggerName
-> TriggerOpsDef ('Postgres 'Cockroach)
-> Maybe
     (PrimaryKey
        ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach)))
-> m (Either QErr ())
createTableEventTrigger = ServerConfigCtx
-> SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> [ColumnInfo ('Postgres 'Cockroach)]
-> TriggerName
-> 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) =>
ServerConfigCtx
-> PGSourceConfig
-> QualifiedTable
-> [ColumnInfo ('Postgres pgKind)]
-> TriggerName
-> TriggerOpsDef ('Postgres pgKind)
-> Maybe
     (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind)))
-> m (Either QErr ())
PG.createTableEventTrigger
  createMissingSQLTriggers :: SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> ([ColumnInfo ('Postgres 'Cockroach)],
    Maybe
      (PrimaryKey
         ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach))))
-> TriggerName
-> TriggerOpsDef ('Postgres 'Cockroach)
-> m ()
createMissingSQLTriggers = SourceConfig ('Postgres 'Cockroach)
-> TableName ('Postgres 'Cockroach)
-> ([ColumnInfo ('Postgres 'Cockroach)],
    Maybe
      (PrimaryKey
         ('Postgres 'Cockroach) (ColumnInfo ('Postgres 'Cockroach))))
-> TriggerName
-> TriggerOpsDef ('Postgres 'Cockroach)
-> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m,
 HasServerConfigCtx m, Backend ('Postgres pgKind)) =>
PGSourceConfig
-> TableName ('Postgres pgKind)
-> ([ColumnInfo ('Postgres pgKind)],
    Maybe
      (PrimaryKey ('Postgres pgKind) (ColumnInfo ('Postgres pgKind))))
-> TriggerName
-> TriggerOpsDef ('Postgres pgKind)
-> m ()
PG.createMissingSQLTriggers
  checkIfTriggerExists :: SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists = SourceConfig ('Postgres 'Cockroach)
-> TriggerName -> HashSet Ops -> m Bool
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
PGSourceConfig -> TriggerName -> HashSet Ops -> m Bool
PG.checkIfTriggerExists

instance BackendEventTrigger 'MSSQL where
  insertManualEvent :: SourceConfig 'MSSQL
-> TableName 'MSSQL
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent = SourceConfig 'MSSQL
-> TableName 'MSSQL
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> TableName
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
MSSQL.insertManualEvent
  fetchUndeliveredEvents :: SourceConfig 'MSSQL
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'MSSQL]
fetchUndeliveredEvents = 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 :: SourceConfig 'MSSQL
-> Event 'MSSQL
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry = 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 :: SourceConfig 'MSSQL
-> Event 'MSSQL
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess = 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 :: SourceConfig 'MSSQL -> m MaintenanceModeVersion
getMaintenanceModeVersion = SourceConfig 'MSSQL -> m MaintenanceModeVersion
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> m MaintenanceModeVersion
MSSQL.getMaintenanceModeVersion
  recordError :: SourceConfig 'MSSQL
-> Event 'MSSQL
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError = 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' :: SourceConfig 'MSSQL
-> Event 'MSSQL
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' = 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 :: SourceConfig 'MSSQL -> TriggerName -> TableName 'MSSQL -> m ()
dropTriggerAndArchiveEvents = SourceConfig 'MSSQL -> TriggerName -> TableName 'MSSQL -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> TriggerName -> TableName -> m ()
MSSQL.dropTriggerAndArchiveEvents
  redeliverEvent :: SourceConfig 'MSSQL -> EventId -> m ()
redeliverEvent = SourceConfig 'MSSQL -> EventId -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> EventId -> m ()
MSSQL.redeliverEvent
  unlockEventsInSource :: SourceConfig 'MSSQL -> NESet EventId -> m (Either QErr Int)
unlockEventsInSource = SourceConfig 'MSSQL -> NESet EventId -> m (Either QErr Int)
forall (m :: * -> *).
MonadIO m =>
MSSQLSourceConfig -> NESet EventId -> m (Either QErr Int)
MSSQL.unlockEventsInSource
  dropDanglingSQLTrigger :: SourceConfig 'MSSQL
-> TriggerName -> TableName 'MSSQL -> HashSet Ops -> m ()
dropDanglingSQLTrigger = SourceConfig 'MSSQL
-> TriggerName -> TableName 'MSSQL -> HashSet Ops -> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig
-> TriggerName -> TableName -> HashSet Ops -> m ()
MSSQL.dropDanglingSQLTrigger
  createTableEventTrigger :: ServerConfigCtx
-> SourceConfig 'MSSQL
-> TableName 'MSSQL
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
createTableEventTrigger = ServerConfigCtx
-> SourceConfig 'MSSQL
-> TableName 'MSSQL
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
forall (m :: * -> *).
MonadIO m =>
ServerConfigCtx
-> MSSQLSourceConfig
-> TableName
-> [ColumnInfo 'MSSQL]
-> TriggerName
-> TriggerOpsDef 'MSSQL
-> Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL))
-> m (Either QErr ())
MSSQL.createTableEventTrigger
  createMissingSQLTriggers :: SourceConfig 'MSSQL
-> TableName 'MSSQL
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOpsDef 'MSSQL
-> m ()
createMissingSQLTriggers = SourceConfig 'MSSQL
-> TableName 'MSSQL
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOpsDef 'MSSQL
-> m ()
forall (m :: * -> *).
(MonadIO m, MonadError QErr m, MonadBaseControl IO m) =>
MSSQLSourceConfig
-> TableName
-> ([ColumnInfo 'MSSQL],
    Maybe (PrimaryKey 'MSSQL (ColumnInfo 'MSSQL)))
-> TriggerName
-> TriggerOpsDef 'MSSQL
-> m ()
MSSQL.createMissingSQLTriggers
  checkIfTriggerExists :: SourceConfig 'MSSQL -> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists = SourceConfig 'MSSQL -> TriggerName -> HashSet Ops -> m Bool
forall (m :: * -> *).
(MonadIO m, MonadError QErr m) =>
MSSQLSourceConfig -> TriggerName -> HashSet Ops -> m Bool
MSSQL.checkIfTriggerExists

instance BackendEventTrigger 'BigQuery where
  insertManualEvent :: SourceConfig 'BigQuery
-> TableName 'BigQuery
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent SourceConfig 'BigQuery
_ TableName 'BigQuery
_ TriggerName
_ Value
_ UserInfo
_ 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 :: 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 :: 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 :: 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 :: 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 :: 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' :: 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 :: 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 :: 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 :: 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 :: 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 :: ServerConfigCtx
-> SourceConfig 'BigQuery
-> TableName 'BigQuery
-> [ColumnInfo 'BigQuery]
-> TriggerName
-> TriggerOpsDef 'BigQuery
-> Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery))
-> m (Either QErr ())
createTableEventTrigger ServerConfigCtx
_ SourceConfig 'BigQuery
_ TableName 'BigQuery
_ [ColumnInfo 'BigQuery]
_ TriggerName
_ 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 :: SourceConfig 'BigQuery
-> TableName 'BigQuery
-> ([ColumnInfo 'BigQuery],
    Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery)))
-> TriggerName
-> TriggerOpsDef 'BigQuery
-> m ()
createMissingSQLTriggers SourceConfig 'BigQuery
_ TableName 'BigQuery
_ ([ColumnInfo 'BigQuery],
 Maybe (PrimaryKey 'BigQuery (ColumnInfo 'BigQuery)))
_ TriggerName
_ 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 :: 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"

instance BackendEventTrigger 'MySQL where
  insertManualEvent :: SourceConfig 'MySQL
-> TableName 'MySQL
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent SourceConfig 'MySQL
_ TableName 'MySQL
_ TriggerName
_ Value
_ UserInfo
_ 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 MySQL sources"
  fetchUndeliveredEvents :: SourceConfig 'MySQL
-> SourceName
-> [TriggerName]
-> MaintenanceMode ()
-> FetchBatchSize
-> m [Event 'MySQL]
fetchUndeliveredEvents SourceConfig 'MySQL
_ SourceName
_ [TriggerName]
_ MaintenanceMode ()
_ FetchBatchSize
_ = Code -> Text -> m [Event 'MySQL]
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for MySQL sources"
  setRetry :: SourceConfig 'MySQL
-> Event 'MySQL
-> UTCTime
-> MaintenanceMode MaintenanceModeVersion
-> m ()
setRetry SourceConfig 'MySQL
_ Event 'MySQL
_ 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 MySQL sources"
  recordSuccess :: SourceConfig 'MySQL
-> Event 'MySQL
-> Invocation 'EventType
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordSuccess SourceConfig 'MySQL
_ Event 'MySQL
_ 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 MySQL sources"
  getMaintenanceModeVersion :: SourceConfig 'MySQL -> m MaintenanceModeVersion
getMaintenanceModeVersion SourceConfig 'MySQL
_ = Code -> Text -> m MaintenanceModeVersion
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for MySQL sources"
  recordError :: SourceConfig 'MySQL
-> Event 'MySQL
-> Invocation 'EventType
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError SourceConfig 'MySQL
_ Event 'MySQL
_ 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 MySQL sources"
  recordError' :: SourceConfig 'MySQL
-> Event 'MySQL
-> Maybe (Invocation 'EventType)
-> ProcessEventError
-> MaintenanceMode MaintenanceModeVersion
-> m (Either QErr ())
recordError' SourceConfig 'MySQL
_ Event 'MySQL
_ 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 MySQL sources"
  dropTriggerAndArchiveEvents :: SourceConfig 'MySQL -> TriggerName -> TableName 'MySQL -> m ()
dropTriggerAndArchiveEvents SourceConfig 'MySQL
_ TriggerName
_ TableName 'MySQL
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for MySQL sources"
  dropDanglingSQLTrigger :: SourceConfig 'MySQL
-> TriggerName -> TableName 'MySQL -> HashSet Ops -> m ()
dropDanglingSQLTrigger SourceConfig 'MySQL
_ TriggerName
_ TableName 'MySQL
_ HashSet Ops
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for MySQL sources"
  redeliverEvent :: SourceConfig 'MySQL -> EventId -> m ()
redeliverEvent SourceConfig 'MySQL
_ EventId
_ = Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported Text
"Event triggers are not supported for MySQL sources"
  unlockEventsInSource :: SourceConfig 'MySQL -> NESet EventId -> m (Either QErr Int)
unlockEventsInSource SourceConfig 'MySQL
_ 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 MySQL sources"
  createTableEventTrigger :: ServerConfigCtx
-> SourceConfig 'MySQL
-> TableName 'MySQL
-> [ColumnInfo 'MySQL]
-> TriggerName
-> TriggerOpsDef 'MySQL
-> Maybe (PrimaryKey 'MySQL (ColumnInfo 'MySQL))
-> m (Either QErr ())
createTableEventTrigger ServerConfigCtx
_ SourceConfig 'MySQL
_ TableName 'MySQL
_ [ColumnInfo 'MySQL]
_ TriggerName
_ TriggerOpsDef 'MySQL
_ Maybe (PrimaryKey 'MySQL (ColumnInfo 'MySQL))
_ = 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 MySQL sources"
  createMissingSQLTriggers :: SourceConfig 'MySQL
-> TableName 'MySQL
-> ([ColumnInfo 'MySQL],
    Maybe (PrimaryKey 'MySQL (ColumnInfo 'MySQL)))
-> TriggerName
-> TriggerOpsDef 'MySQL
-> m ()
createMissingSQLTriggers SourceConfig 'MySQL
_ TableName 'MySQL
_ ([ColumnInfo 'MySQL],
 Maybe (PrimaryKey 'MySQL (ColumnInfo 'MySQL)))
_ TriggerName
_ TriggerOpsDef 'MySQL
_ = 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 MySQL sources"
  checkIfTriggerExists :: SourceConfig 'MySQL -> TriggerName -> HashSet Ops -> m Bool
checkIfTriggerExists SourceConfig 'MySQL
_ 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 MySQL 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 :: SourceConfig 'DataConnector
-> TableName 'DataConnector
-> TriggerName
-> Value
-> UserInfo
-> TraceContext
-> m EventId
insertManualEvent SourceConfig 'DataConnector
_ TableName 'DataConnector
_ TriggerName
_ Value
_ UserInfo
_ 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 :: 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 :: 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 :: 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 :: 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 :: 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' :: 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 :: 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 :: 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 :: 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 :: 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 :: ServerConfigCtx
-> SourceConfig 'DataConnector
-> TableName 'DataConnector
-> [ColumnInfo 'DataConnector]
-> TriggerName
-> TriggerOpsDef 'DataConnector
-> Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector))
-> m (Either QErr ())
createTableEventTrigger ServerConfigCtx
_ SourceConfig 'DataConnector
_ TableName 'DataConnector
_ [ColumnInfo 'DataConnector]
_ TriggerName
_ 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 :: SourceConfig 'DataConnector
-> TableName 'DataConnector
-> ([ColumnInfo 'DataConnector],
    Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector)))
-> TriggerName
-> TriggerOpsDef 'DataConnector
-> m ()
createMissingSQLTriggers SourceConfig 'DataConnector
_ TableName 'DataConnector
_ ([ColumnInfo 'DataConnector],
 Maybe (PrimaryKey 'DataConnector (ColumnInfo 'DataConnector)))
_ TriggerName
_ 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 :: 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."