2023-04-25 20:16:53 +03:00
|
|
|
module Hasura.Eventing.Backend
|
2021-11-04 19:08:33 +03:00
|
|
|
( BackendEventTrigger (..),
|
|
|
|
)
|
|
|
|
where
|
2021-09-06 14:15:36 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Control.Monad.Trans.Control (MonadBaseControl)
|
|
|
|
import Data.Aeson
|
2022-06-30 14:26:10 +03:00
|
|
|
import Data.Set.NonEmpty qualified as NE
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.Time.Clock qualified as Time
|
2022-03-03 12:52:48 +03:00
|
|
|
import Hasura.Backends.MSSQL.DDL.EventTrigger qualified as MSSQL
|
2022-09-21 14:34:39 +03:00
|
|
|
import Hasura.Backends.Postgres.DDL.EventTrigger qualified as Postgres
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.Base.Error
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.Types.Backend
|
2023-04-24 21:35:48 +03:00
|
|
|
import Hasura.RQL.Types.BackendType
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.RQL.Types.Column (ColumnInfo)
|
|
|
|
import Hasura.RQL.Types.Common
|
|
|
|
import Hasura.RQL.Types.EventTrigger
|
|
|
|
import Hasura.RQL.Types.Eventing
|
2023-04-25 18:55:33 +03:00
|
|
|
import Hasura.RQL.Types.Session (UserInfo)
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.RQL.Types.Source
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
import Hasura.Server.Types (MaintenanceMode)
|
2023-05-17 11:53:31 +03:00
|
|
|
import Hasura.Table.Cache (PrimaryKey)
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.Tracing qualified as Tracing
|
2021-09-06 14:15:36 +03:00
|
|
|
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | 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.
|
2023-05-17 11:53:31 +03:00
|
|
|
class (Backend b) => BackendEventTrigger (b :: BackendType) where
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | insertManualEvent inserts the specified event in the event log table,
|
|
|
|
-- note that this method should also set the trace context and session
|
2022-07-04 13:09:50 +03:00
|
|
|
-- variables in the source database context (if available).
|
2021-09-24 01:56:37 +03:00
|
|
|
insertManualEvent ::
|
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
TableName b ->
|
|
|
|
TriggerName ->
|
|
|
|
Value ->
|
|
|
|
UserInfo ->
|
Rewrite `Tracing` to allow for only one `TraceT` in the entire stack.
This PR is on top of #7789.
### Description
This PR entirely rewrites the API of the Tracing library, to make `interpTraceT` a thing of the past. Before this change, we ran traces by sticking a `TraceT` on top of whatever we were doing. This had several major drawbacks:
- we were carrying a bunch of `TraceT` across the codebase, and the entire codebase had to know about it
- we needed to carry a second class constraint around (`HasReporterM`) to be able to run all of those traces
- we kept having to do stack rewriting with `interpTraceT`, which went from inconvenient to horrible
- we had to declare several behavioral instances on `TraceT m`
This PR rewrite all of `Tracing` using a more conventional model: there is ONE `TraceT` at the bottom of the stack, and there is an associated class constraint `MonadTrace`: any part of the code that happens to satisfy `MonadTrace` is able to create new traces. We NEVER have to do stack rewriting, `interpTraceT` is gone, and `TraceT` and `Reporter` become implementation details that 99% of the code is blissfully unaware of: code that needs to do tracing only needs to declare that the monad in which it operates implements `MonadTrace`.
In doing so, this PR revealed **several bugs in the codebase**: places where we were expecting to trace something, but due to the default instance of `HasReporterM IO` we would actually not do anything. This PR also splits the code of `Tracing` in more byte-sized modules, with the goal of potentially moving to `server/lib` down the line.
### Remaining work
This PR is a draft; what's left to do is:
- [x] make Pro compile; i haven't updated `HasuraPro/Main` yet
- [x] document Tracing by writing a note that explains how to use the library, and the meaning of "reporter", "trace" and "span", as well as the pitfalls
- [x] discuss some of the trade-offs in the implementation, which is why i'm opening this PR already despite it not fully building yet
- [x] it depends on #7789 being merged first
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7791
GitOrigin-RevId: cadd32d039134c93ddbf364599a2f4dd988adea8
2023-03-13 20:37:16 +03:00
|
|
|
Maybe Tracing.TraceContext ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m EventId
|
2021-09-06 14:15:36 +03:00
|
|
|
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | @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.
|
2021-09-20 10:34:59 +03:00
|
|
|
--
|
2022-04-21 10:19:37 +03:00
|
|
|
-- 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.
|
2022-03-08 12:05:26 +03:00
|
|
|
--
|
2022-04-21 10:19:37 +03:00
|
|
|
-- 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.
|
2021-09-24 01:56:37 +03:00
|
|
|
fetchUndeliveredEvents ::
|
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
SourceName ->
|
2022-03-08 12:05:26 +03:00
|
|
|
-- | List of trigger names which exist in the metadata
|
|
|
|
[TriggerName] ->
|
2022-04-28 23:55:13 +03:00
|
|
|
MaintenanceMode () ->
|
2021-09-24 01:56:37 +03:00
|
|
|
FetchBatchSize ->
|
|
|
|
m [Event b]
|
2021-09-20 10:34:59 +03:00
|
|
|
|
|
|
|
-- | Ad-hoc function to set a retry for an undelivered event
|
2021-09-24 01:56:37 +03:00
|
|
|
setRetry ::
|
2022-05-05 16:43:50 +03:00
|
|
|
(MonadIO m, MonadError QErr m) =>
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
Event b ->
|
|
|
|
Time.UTCTime ->
|
2022-04-28 23:55:13 +03:00
|
|
|
MaintenanceMode MaintenanceModeVersion ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m ()
|
2021-09-06 14:15:36 +03:00
|
|
|
|
2021-09-20 10:34:59 +03:00
|
|
|
-- | @getMaintenanceModeVersion@ gets the source catalog version from the
|
|
|
|
-- source
|
2021-09-24 01:56:37 +03:00
|
|
|
getMaintenanceModeVersion ::
|
2022-05-05 16:43:50 +03:00
|
|
|
(MonadIO m, MonadError QErr m) =>
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
m MaintenanceModeVersion
|
2021-09-20 10:34:59 +03:00
|
|
|
|
|
|
|
-- | @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
|
2021-09-24 01:56:37 +03:00
|
|
|
recordSuccess ::
|
2023-05-17 11:53:31 +03:00
|
|
|
(MonadIO m) =>
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
Event b ->
|
|
|
|
Invocation 'EventType ->
|
2022-04-28 23:55:13 +03:00
|
|
|
MaintenanceMode MaintenanceModeVersion ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m (Either QErr ())
|
2021-09-20 10:34:59 +03:00
|
|
|
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | @recordError@ records an erronous event invocation, it does a couple of
|
|
|
|
-- things,
|
2021-09-20 10:34:59 +03:00
|
|
|
--
|
|
|
|
-- 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'
|
2021-09-24 01:56:37 +03:00
|
|
|
recordError ::
|
2023-05-17 11:53:31 +03:00
|
|
|
(MonadIO m) =>
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
Event b ->
|
|
|
|
Invocation 'EventType ->
|
|
|
|
ProcessEventError ->
|
2022-04-28 23:55:13 +03:00
|
|
|
MaintenanceMode MaintenanceModeVersion ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m (Either QErr ())
|
2021-09-20 10:34:59 +03:00
|
|
|
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | @recordError'@ records an erronous event invocation, it does a couple of
|
|
|
|
-- things,
|
2021-09-29 11:13:30 +03:00
|
|
|
--
|
|
|
|
-- 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' ::
|
2023-05-17 11:53:31 +03:00
|
|
|
(MonadIO m) =>
|
2021-09-29 11:13:30 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
Event b ->
|
|
|
|
Maybe (Invocation 'EventType) ->
|
|
|
|
ProcessEventError ->
|
2022-04-28 23:55:13 +03:00
|
|
|
MaintenanceMode MaintenanceModeVersion ->
|
2021-09-29 11:13:30 +03:00
|
|
|
m (Either QErr ())
|
|
|
|
|
2021-09-09 14:54:19 +03:00
|
|
|
-- | @dropTriggerAndArchiveEvents@ drops the database trigger and
|
|
|
|
-- marks all the events related to the event trigger as archived.
|
|
|
|
-- See Note [Cleanup for dropped triggers]
|
2021-09-24 01:56:37 +03:00
|
|
|
dropTriggerAndArchiveEvents ::
|
2022-05-05 16:43:50 +03:00
|
|
|
(MonadIO m, MonadError QErr m) =>
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
TriggerName ->
|
2022-04-21 10:19:37 +03:00
|
|
|
TableName b ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m ()
|
|
|
|
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | @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.
|
2022-03-15 11:41:03 +03:00
|
|
|
dropDanglingSQLTrigger ::
|
2022-05-05 16:43:50 +03:00
|
|
|
(MonadIO m, MonadError QErr m) =>
|
2022-03-15 11:41:03 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
TriggerName ->
|
2022-04-21 10:19:37 +03:00
|
|
|
TableName b ->
|
2022-03-15 11:41:03 +03:00
|
|
|
HashSet Ops ->
|
|
|
|
m ()
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
redeliverEvent ::
|
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
EventId ->
|
|
|
|
m ()
|
2021-09-20 10:34:59 +03:00
|
|
|
|
2022-04-21 10:19:37 +03:00
|
|
|
-- | @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.
|
2021-09-24 01:56:37 +03:00
|
|
|
unlockEventsInSource ::
|
2023-05-17 11:53:31 +03:00
|
|
|
(MonadIO m) =>
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
2022-06-30 14:26:10 +03:00
|
|
|
NE.NESet EventId ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m (Either QErr Int)
|
|
|
|
|
2022-07-04 13:09:50 +03:00
|
|
|
-- | @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 ::
|
Remove `HasServerConfigCtx` from the schema cache build.
## Description
This PR is a incremental step towards achieving the goal of #8344. It is a less ambitious version of #8484.
This PR removes all references to `HasServerConfigCtx` from the cache build and removes `ServerConfigCtx` from `CacheBuildParams`, making `ServerConfigCtx` an argument being passed around manually instead. This has several benefits: by making it an arrow argument, we now properly integrate the fields that change over time in the dependency framework, as they should be, and we can clean up some of the top-level app code.
## Implementation
In practice, this PR introduces a `HasServerConfigCtx` instance for `CacheRWT`, the monad we use to build the cache, so we can retrieve the `ServerConfigCtx` in the implementation of `CacheRWM`. This contributes to reducing the amount of `HasServerConfigCtx` in the code: we can remove `SchemaUpdateT` altogether, and we can remove the `HasServerConfigCtx` instance of `Handler`. This makes `HasServerConfigCtx` almost **an implementation detail of the Metadata API**.
This first step is enough to achieve the goal of #8344: we can now build the schema cache in the app monad, since we no longer rely on `HasServerConfigCtx` to build it.
## Drawbacks
This PR does not attempt to remove the use of `ServerConfigCtx` itself in the schema cache build: doing so would make this PR much much bigger. Ideally, to avoid having all the static fields given as arrow-ish arguments to the cache, we could depend on `HasAppEnv` in the cache build, and use `AppContext` as an arrow argument. But making the cache build depend on the full `AppEnv` and `AppContext` creates a lot of circular imports; and since removing `ServerConfigCtx` itself isn't required to achieve #8344, this PR keeps it wholesale and defers cleaning it to a future PR.
A negative consequence of this is that we need an `Eq` instance on `ServerConfigCtx`, and that instance is inelegant.
## Future work
There are several further steps we can take in parallel after this is merged. First, again, we can make a new version of #8344, removing `CacheBuild`, FINALLY. As for `ServerConfigCtx`, we can split it / rename it to make ad-hoc structures. If it turns out that `ServerConfigCtx` is only ever used for the schema cache build, we could split it between `CacheBuildEnv` and `CacheBuildContext`, which will be subsets of `AppEnv` and `AppContext`, avoiding import loops.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8509
GitOrigin-RevId: 01b37cc3fd3490d6b117701e22fc4ac88b62b6b5
2023-03-27 20:42:37 +03:00
|
|
|
(MonadIO m, MonadError QErr m, MonadBaseControl IO m, Backend b) =>
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
SQLGenCtx ->
|
2022-07-04 13:09:50 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
TableName b ->
|
|
|
|
([ColumnInfo b], Maybe (PrimaryKey b (ColumnInfo b))) ->
|
|
|
|
TriggerName ->
|
2022-11-29 20:41:41 +03:00
|
|
|
TriggerOnReplication ->
|
2022-07-04 13:09:50 +03:00
|
|
|
TriggerOpsDef b ->
|
|
|
|
m ()
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
createTableEventTrigger ::
|
2022-03-03 12:52:48 +03:00
|
|
|
(MonadBaseControl IO m, MonadIO m, MonadError QErr m) =>
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
SQLGenCtx ->
|
2021-09-24 01:56:37 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
TableName b ->
|
|
|
|
[ColumnInfo b] ->
|
|
|
|
TriggerName ->
|
2022-11-29 20:41:41 +03:00
|
|
|
TriggerOnReplication ->
|
2021-09-24 01:56:37 +03:00
|
|
|
TriggerOpsDef b ->
|
2022-03-03 12:52:48 +03:00
|
|
|
-- 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)) ->
|
2021-09-24 01:56:37 +03:00
|
|
|
m (Either QErr ())
|
2021-09-20 10:34:59 +03:00
|
|
|
|
2022-08-23 11:49:51 +03:00
|
|
|
checkIfTriggerExists ::
|
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
TriggerName ->
|
|
|
|
HashSet Ops ->
|
|
|
|
m Bool
|
|
|
|
|
2022-09-15 14:45:14 +03:00
|
|
|
-- | @addCleanupSchedules@ adds cleanup logs for given trigger names and cleanup configs.
|
2022-09-13 11:33:44 +03:00
|
|
|
-- 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
|
2022-09-15 14:45:14 +03:00
|
|
|
addCleanupSchedules ::
|
2022-09-13 11:33:44 +03:00
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
[(TriggerName, AutoTriggerLogCleanupConfig)] ->
|
|
|
|
m ()
|
|
|
|
|
2022-09-15 14:45:14 +03:00
|
|
|
-- | @deleteAllScheduledCleanups@ deletes all scheduled cleanup logs for a given event trigger
|
|
|
|
deleteAllScheduledCleanups ::
|
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
TriggerName ->
|
|
|
|
m ()
|
|
|
|
|
2022-09-13 11:33:44 +03:00
|
|
|
-- | @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.
|
2022-09-09 11:26:44 +03:00
|
|
|
deleteEventTriggerLogs ::
|
|
|
|
(MonadIO m, MonadError QErr m) =>
|
|
|
|
SourceConfig b ->
|
|
|
|
TriggerLogCleanupConfig ->
|
2022-10-11 22:26:38 +03:00
|
|
|
IO (Maybe (TriggerLogCleanupConfig, EventTriggerCleanupStatus)) ->
|
2022-09-13 11:33:44 +03:00
|
|
|
m DeletedEventLogStats
|
2022-09-09 11:26:44 +03:00
|
|
|
|
2023-04-25 14:22:27 +03:00
|
|
|
-- | @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)
|
|
|
|
|
2022-05-05 16:43:50 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- 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.
|
|
|
|
|
2021-09-06 14:15:36 +03:00
|
|
|
instance BackendEventTrigger ('Postgres 'Vanilla) where
|
2022-09-21 14:34:39 +03:00
|
|
|
insertManualEvent = Postgres.insertManualEvent
|
|
|
|
fetchUndeliveredEvents = Postgres.fetchUndeliveredEvents
|
|
|
|
setRetry = Postgres.setRetry
|
|
|
|
getMaintenanceModeVersion = Postgres.getMaintenanceModeVersion
|
|
|
|
recordSuccess = Postgres.recordSuccess
|
|
|
|
recordError = Postgres.recordError
|
|
|
|
recordError' = Postgres.recordError'
|
|
|
|
dropTriggerAndArchiveEvents = Postgres.dropTriggerAndArchiveEvents
|
|
|
|
dropDanglingSQLTrigger = Postgres.dropDanglingSQLTrigger
|
|
|
|
redeliverEvent = Postgres.redeliverEvent
|
|
|
|
unlockEventsInSource = Postgres.unlockEventsInSource
|
|
|
|
createTableEventTrigger = Postgres.createTableEventTrigger
|
|
|
|
createMissingSQLTriggers = Postgres.createMissingSQLTriggers
|
|
|
|
checkIfTriggerExists = Postgres.checkIfTriggerExists
|
|
|
|
addCleanupSchedules = Postgres.addCleanupSchedules
|
|
|
|
deleteAllScheduledCleanups = Postgres.deleteAllScheduledCleanups
|
|
|
|
getCleanupEventsForDeletion = Postgres.getCleanupEventsForDeletion
|
|
|
|
updateCleanupEventStatusToDead = Postgres.updateCleanupEventStatusToDead
|
|
|
|
updateCleanupEventStatusToPaused = Postgres.updateCleanupEventStatusToPaused
|
|
|
|
updateCleanupEventStatusToCompleted = Postgres.updateCleanupEventStatusToCompleted
|
|
|
|
deleteEventTriggerLogs = Postgres.deleteEventTriggerLogs
|
2023-04-25 14:22:27 +03:00
|
|
|
fetchEventLogs = Postgres.fetchEventLogs
|
|
|
|
fetchEventInvocationLogs = Postgres.fetchEventInvocationLogs
|
|
|
|
fetchEventById = Postgres.fetchEventById
|
2021-09-06 14:15:36 +03:00
|
|
|
|
|
|
|
instance BackendEventTrigger ('Postgres 'Citus) where
|
2021-09-24 01:56:37 +03:00
|
|
|
insertManualEvent _ _ _ _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2022-03-08 12:05:26 +03:00
|
|
|
fetchUndeliveredEvents _ _ _ _ _ = throw400 NotSupported "Event triggers are not supported for Citus sources"
|
2021-09-24 01:56:37 +03:00
|
|
|
setRetry _ _ _ _ = throw400 NotSupported "Event triggers are not supported for Citus sources"
|
|
|
|
recordSuccess _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for Citus sources"
|
|
|
|
getMaintenanceModeVersion _ = throw400 NotSupported "Event triggers are not supported for Citus sources"
|
|
|
|
recordError _ _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for Citus sources"
|
2021-09-29 11:13:30 +03:00
|
|
|
recordError' _ _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for Citus sources"
|
2022-04-21 10:19:37 +03:00
|
|
|
dropTriggerAndArchiveEvents _ _ _ = throw400 NotSupported "Event triggers are not supported for Citus sources"
|
|
|
|
dropDanglingSQLTrigger _ _ _ _ = throw400 NotSupported "Event triggers are not supported for Citus sources"
|
2021-09-24 01:56:37 +03:00
|
|
|
redeliverEvent _ _ = throw400 NotSupported "Event triggers are not supported for Citus sources"
|
|
|
|
unlockEventsInSource _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for Citus sources"
|
2022-11-29 20:41:41 +03:00
|
|
|
createTableEventTrigger _ _ _ _ _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for Citus sources"
|
Remove `HasServerConfigCtx` from the schema cache build.
## Description
This PR is a incremental step towards achieving the goal of #8344. It is a less ambitious version of #8484.
This PR removes all references to `HasServerConfigCtx` from the cache build and removes `ServerConfigCtx` from `CacheBuildParams`, making `ServerConfigCtx` an argument being passed around manually instead. This has several benefits: by making it an arrow argument, we now properly integrate the fields that change over time in the dependency framework, as they should be, and we can clean up some of the top-level app code.
## Implementation
In practice, this PR introduces a `HasServerConfigCtx` instance for `CacheRWT`, the monad we use to build the cache, so we can retrieve the `ServerConfigCtx` in the implementation of `CacheRWM`. This contributes to reducing the amount of `HasServerConfigCtx` in the code: we can remove `SchemaUpdateT` altogether, and we can remove the `HasServerConfigCtx` instance of `Handler`. This makes `HasServerConfigCtx` almost **an implementation detail of the Metadata API**.
This first step is enough to achieve the goal of #8344: we can now build the schema cache in the app monad, since we no longer rely on `HasServerConfigCtx` to build it.
## Drawbacks
This PR does not attempt to remove the use of `ServerConfigCtx` itself in the schema cache build: doing so would make this PR much much bigger. Ideally, to avoid having all the static fields given as arrow-ish arguments to the cache, we could depend on `HasAppEnv` in the cache build, and use `AppContext` as an arrow argument. But making the cache build depend on the full `AppEnv` and `AppContext` creates a lot of circular imports; and since removing `ServerConfigCtx` itself isn't required to achieve #8344, this PR keeps it wholesale and defers cleaning it to a future PR.
A negative consequence of this is that we need an `Eq` instance on `ServerConfigCtx`, and that instance is inelegant.
## Future work
There are several further steps we can take in parallel after this is merged. First, again, we can make a new version of #8344, removing `CacheBuild`, FINALLY. As for `ServerConfigCtx`, we can split it / rename it to make ad-hoc structures. If it turns out that `ServerConfigCtx` is only ever used for the schema cache build, we could split it between `CacheBuildEnv` and `CacheBuildContext`, which will be subsets of `AppEnv` and `AppContext`, avoiding import loops.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8509
GitOrigin-RevId: 01b37cc3fd3490d6b117701e22fc4ac88b62b6b5
2023-03-27 20:42:37 +03:00
|
|
|
createMissingSQLTriggers _ _ _ _ _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2022-08-23 11:49:51 +03:00
|
|
|
checkIfTriggerExists _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2022-09-15 14:45:14 +03:00
|
|
|
addCleanupSchedules _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
|
|
|
deleteAllScheduledCleanups _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2022-09-13 11:33:44 +03:00
|
|
|
getCleanupEventsForDeletion _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
|
|
|
updateCleanupEventStatusToDead _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
|
|
|
updateCleanupEventStatusToPaused _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
|
|
|
updateCleanupEventStatusToCompleted _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2022-10-11 22:26:38 +03:00
|
|
|
deleteEventTriggerLogs _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2023-04-25 14:22:27 +03:00
|
|
|
fetchEventLogs _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
|
|
|
fetchEventInvocationLogs _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
|
|
|
fetchEventById _ _ = throw400 NotSupported $ "Event triggers are not supported for Citus sources"
|
2021-09-06 14:15:36 +03:00
|
|
|
|
2022-08-19 17:19:54 +03:00
|
|
|
instance BackendEventTrigger ('Postgres 'Cockroach) where
|
2022-09-21 14:34:39 +03:00
|
|
|
insertManualEvent = Postgres.insertManualEvent
|
|
|
|
fetchUndeliveredEvents = Postgres.fetchUndeliveredEvents
|
|
|
|
setRetry = Postgres.setRetry
|
|
|
|
getMaintenanceModeVersion = Postgres.getMaintenanceModeVersion
|
|
|
|
recordSuccess = Postgres.recordSuccess
|
|
|
|
recordError = Postgres.recordError
|
|
|
|
recordError' = Postgres.recordError'
|
|
|
|
dropTriggerAndArchiveEvents = Postgres.dropTriggerAndArchiveEvents
|
|
|
|
dropDanglingSQLTrigger = Postgres.dropDanglingSQLTrigger
|
|
|
|
redeliverEvent = Postgres.redeliverEvent
|
|
|
|
unlockEventsInSource = Postgres.unlockEventsInSource
|
|
|
|
createTableEventTrigger = Postgres.createTableEventTrigger
|
|
|
|
createMissingSQLTriggers = Postgres.createMissingSQLTriggers
|
|
|
|
checkIfTriggerExists = Postgres.checkIfTriggerExists
|
|
|
|
addCleanupSchedules = Postgres.addCleanupSchedules
|
|
|
|
deleteAllScheduledCleanups = Postgres.deleteAllScheduledCleanups
|
|
|
|
getCleanupEventsForDeletion = Postgres.getCleanupEventsForDeletion
|
|
|
|
updateCleanupEventStatusToDead = Postgres.updateCleanupEventStatusToDead
|
|
|
|
updateCleanupEventStatusToPaused = Postgres.updateCleanupEventStatusToPaused
|
|
|
|
updateCleanupEventStatusToCompleted = Postgres.updateCleanupEventStatusToCompleted
|
|
|
|
deleteEventTriggerLogs = Postgres.deleteEventTriggerLogs
|
2023-04-25 14:22:27 +03:00
|
|
|
fetchEventLogs = Postgres.fetchEventLogs
|
|
|
|
fetchEventInvocationLogs = Postgres.fetchEventInvocationLogs
|
|
|
|
fetchEventById = Postgres.fetchEventById
|
2022-08-19 17:19:54 +03:00
|
|
|
|
2021-09-06 14:15:36 +03:00
|
|
|
instance BackendEventTrigger 'MSSQL where
|
2022-04-21 10:19:37 +03:00
|
|
|
insertManualEvent = MSSQL.insertManualEvent
|
|
|
|
fetchUndeliveredEvents = MSSQL.fetchUndeliveredEvents
|
|
|
|
setRetry = MSSQL.setRetry
|
|
|
|
recordSuccess = MSSQL.recordSuccess
|
|
|
|
getMaintenanceModeVersion = MSSQL.getMaintenanceModeVersion
|
|
|
|
recordError = MSSQL.recordError
|
|
|
|
recordError' = MSSQL.recordError'
|
|
|
|
dropTriggerAndArchiveEvents = MSSQL.dropTriggerAndArchiveEvents
|
|
|
|
redeliverEvent = MSSQL.redeliverEvent
|
|
|
|
unlockEventsInSource = MSSQL.unlockEventsInSource
|
|
|
|
dropDanglingSQLTrigger = MSSQL.dropDanglingSQLTrigger
|
2022-03-03 12:52:48 +03:00
|
|
|
createTableEventTrigger = MSSQL.createTableEventTrigger
|
2022-07-04 13:09:50 +03:00
|
|
|
createMissingSQLTriggers = MSSQL.createMissingSQLTriggers
|
2022-08-23 11:49:51 +03:00
|
|
|
checkIfTriggerExists = MSSQL.checkIfTriggerExists
|
2022-09-15 14:45:14 +03:00
|
|
|
addCleanupSchedules = MSSQL.addCleanupSchedules
|
|
|
|
deleteAllScheduledCleanups = MSSQL.deleteAllScheduledCleanups
|
2022-09-13 11:33:44 +03:00
|
|
|
getCleanupEventsForDeletion = MSSQL.getCleanupEventsForDeletion
|
|
|
|
updateCleanupEventStatusToDead = MSSQL.updateCleanupEventStatusToDead
|
|
|
|
updateCleanupEventStatusToPaused = MSSQL.updateCleanupEventStatusToPaused
|
|
|
|
updateCleanupEventStatusToCompleted = MSSQL.updateCleanupEventStatusToCompleted
|
2022-09-09 11:26:44 +03:00
|
|
|
deleteEventTriggerLogs = MSSQL.deleteEventTriggerLogs
|
2023-04-25 14:22:27 +03:00
|
|
|
fetchEventInvocationLogs = MSSQL.fetchEventInvocationLogs
|
|
|
|
fetchEventLogs = MSSQL.fetchEventLogs
|
|
|
|
fetchEventById = MSSQL.fetchEventById
|
2021-09-06 14:15:36 +03:00
|
|
|
|
|
|
|
instance BackendEventTrigger 'BigQuery where
|
2021-09-24 01:56:37 +03:00
|
|
|
insertManualEvent _ _ _ _ _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2022-03-08 12:05:26 +03:00
|
|
|
fetchUndeliveredEvents _ _ _ _ _ = throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
2021-09-24 01:56:37 +03:00
|
|
|
setRetry _ _ _ _ = throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
|
|
|
recordSuccess _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
|
|
|
getMaintenanceModeVersion _ = throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
|
|
|
recordError _ _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
2021-09-29 11:13:30 +03:00
|
|
|
recordError' _ _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
2022-04-21 10:19:37 +03:00
|
|
|
dropTriggerAndArchiveEvents _ _ _ = throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
|
|
|
dropDanglingSQLTrigger _ _ _ _ = throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
2021-09-24 01:56:37 +03:00
|
|
|
redeliverEvent _ _ = throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
|
|
|
unlockEventsInSource _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
2022-11-29 20:41:41 +03:00
|
|
|
createTableEventTrigger _ _ _ _ _ _ _ _ = runExceptT $ throw400 NotSupported "Event triggers are not supported for BigQuery sources"
|
Remove `HasServerConfigCtx` from the schema cache build.
## Description
This PR is a incremental step towards achieving the goal of #8344. It is a less ambitious version of #8484.
This PR removes all references to `HasServerConfigCtx` from the cache build and removes `ServerConfigCtx` from `CacheBuildParams`, making `ServerConfigCtx` an argument being passed around manually instead. This has several benefits: by making it an arrow argument, we now properly integrate the fields that change over time in the dependency framework, as they should be, and we can clean up some of the top-level app code.
## Implementation
In practice, this PR introduces a `HasServerConfigCtx` instance for `CacheRWT`, the monad we use to build the cache, so we can retrieve the `ServerConfigCtx` in the implementation of `CacheRWM`. This contributes to reducing the amount of `HasServerConfigCtx` in the code: we can remove `SchemaUpdateT` altogether, and we can remove the `HasServerConfigCtx` instance of `Handler`. This makes `HasServerConfigCtx` almost **an implementation detail of the Metadata API**.
This first step is enough to achieve the goal of #8344: we can now build the schema cache in the app monad, since we no longer rely on `HasServerConfigCtx` to build it.
## Drawbacks
This PR does not attempt to remove the use of `ServerConfigCtx` itself in the schema cache build: doing so would make this PR much much bigger. Ideally, to avoid having all the static fields given as arrow-ish arguments to the cache, we could depend on `HasAppEnv` in the cache build, and use `AppContext` as an arrow argument. But making the cache build depend on the full `AppEnv` and `AppContext` creates a lot of circular imports; and since removing `ServerConfigCtx` itself isn't required to achieve #8344, this PR keeps it wholesale and defers cleaning it to a future PR.
A negative consequence of this is that we need an `Eq` instance on `ServerConfigCtx`, and that instance is inelegant.
## Future work
There are several further steps we can take in parallel after this is merged. First, again, we can make a new version of #8344, removing `CacheBuild`, FINALLY. As for `ServerConfigCtx`, we can split it / rename it to make ad-hoc structures. If it turns out that `ServerConfigCtx` is only ever used for the schema cache build, we could split it between `CacheBuildEnv` and `CacheBuildContext`, which will be subsets of `AppEnv` and `AppContext`, avoiding import loops.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8509
GitOrigin-RevId: 01b37cc3fd3490d6b117701e22fc4ac88b62b6b5
2023-03-27 20:42:37 +03:00
|
|
|
createMissingSQLTriggers _ _ _ _ _ _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2022-08-23 11:49:51 +03:00
|
|
|
checkIfTriggerExists _ _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2022-09-15 14:45:14 +03:00
|
|
|
addCleanupSchedules _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
|
|
|
deleteAllScheduledCleanups _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2022-09-13 11:33:44 +03:00
|
|
|
getCleanupEventsForDeletion _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
|
|
|
updateCleanupEventStatusToDead _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
|
|
|
updateCleanupEventStatusToPaused _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
|
|
|
updateCleanupEventStatusToCompleted _ _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2022-10-11 22:26:38 +03:00
|
|
|
deleteEventTriggerLogs _ _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2023-04-25 14:22:27 +03:00
|
|
|
fetchEventLogs _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
|
|
|
fetchEventInvocationLogs _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
|
|
|
fetchEventById _ _ = throw400 NotSupported $ "Event triggers are not supported for BigQuery sources"
|
2021-09-06 14:15:36 +03:00
|
|
|
|
2021-12-22 03:10:28 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- 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.
|
2022-05-02 08:03:12 +03:00
|
|
|
instance BackendEventTrigger 'DataConnector where
|
2021-12-22 03:10:28 +03:00
|
|
|
insertManualEvent _ _ _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2022-03-08 12:05:26 +03:00
|
|
|
fetchUndeliveredEvents _ _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2021-12-22 03:10:28 +03:00
|
|
|
setRetry _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2021-12-22 03:10:28 +03:00
|
|
|
recordSuccess _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2021-12-22 03:10:28 +03:00
|
|
|
getMaintenanceModeVersion _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2021-12-22 03:10:28 +03:00
|
|
|
recordError _ _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2021-12-22 03:10:28 +03:00
|
|
|
recordError' _ _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2022-04-21 10:19:37 +03:00
|
|
|
dropTriggerAndArchiveEvents _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2022-04-21 10:19:37 +03:00
|
|
|
dropDanglingSQLTrigger _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend"
|
2021-12-22 03:10:28 +03:00
|
|
|
redeliverEvent _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2021-12-22 03:10:28 +03:00
|
|
|
unlockEventsInSource _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
2022-11-29 20:41:41 +03:00
|
|
|
createTableEventTrigger _ _ _ _ _ _ _ _ =
|
2022-05-02 08:03:12 +03:00
|
|
|
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
Remove `HasServerConfigCtx` from the schema cache build.
## Description
This PR is a incremental step towards achieving the goal of #8344. It is a less ambitious version of #8484.
This PR removes all references to `HasServerConfigCtx` from the cache build and removes `ServerConfigCtx` from `CacheBuildParams`, making `ServerConfigCtx` an argument being passed around manually instead. This has several benefits: by making it an arrow argument, we now properly integrate the fields that change over time in the dependency framework, as they should be, and we can clean up some of the top-level app code.
## Implementation
In practice, this PR introduces a `HasServerConfigCtx` instance for `CacheRWT`, the monad we use to build the cache, so we can retrieve the `ServerConfigCtx` in the implementation of `CacheRWM`. This contributes to reducing the amount of `HasServerConfigCtx` in the code: we can remove `SchemaUpdateT` altogether, and we can remove the `HasServerConfigCtx` instance of `Handler`. This makes `HasServerConfigCtx` almost **an implementation detail of the Metadata API**.
This first step is enough to achieve the goal of #8344: we can now build the schema cache in the app monad, since we no longer rely on `HasServerConfigCtx` to build it.
## Drawbacks
This PR does not attempt to remove the use of `ServerConfigCtx` itself in the schema cache build: doing so would make this PR much much bigger. Ideally, to avoid having all the static fields given as arrow-ish arguments to the cache, we could depend on `HasAppEnv` in the cache build, and use `AppContext` as an arrow argument. But making the cache build depend on the full `AppEnv` and `AppContext` creates a lot of circular imports; and since removing `ServerConfigCtx` itself isn't required to achieve #8344, this PR keeps it wholesale and defers cleaning it to a future PR.
A negative consequence of this is that we need an `Eq` instance on `ServerConfigCtx`, and that instance is inelegant.
## Future work
There are several further steps we can take in parallel after this is merged. First, again, we can make a new version of #8344, removing `CacheBuild`, FINALLY. As for `ServerConfigCtx`, we can split it / rename it to make ad-hoc structures. If it turns out that `ServerConfigCtx` is only ever used for the schema cache build, we could split it between `CacheBuildEnv` and `CacheBuildContext`, which will be subsets of `AppEnv` and `AppContext`, avoiding import loops.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8509
GitOrigin-RevId: 01b37cc3fd3490d6b117701e22fc4ac88b62b6b5
2023-03-27 20:42:37 +03:00
|
|
|
createMissingSQLTriggers _ _ _ _ _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector backend."
|
2022-08-23 11:49:51 +03:00
|
|
|
checkIfTriggerExists _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector backend."
|
2022-09-15 14:45:14 +03:00
|
|
|
addCleanupSchedules _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector backend."
|
|
|
|
deleteAllScheduledCleanups _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector backend."
|
2022-09-13 11:33:44 +03:00
|
|
|
getCleanupEventsForDeletion _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
|
|
|
updateCleanupEventStatusToDead _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
|
|
|
updateCleanupEventStatusToPaused _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
|
|
|
updateCleanupEventStatusToCompleted _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
2022-10-11 22:26:38 +03:00
|
|
|
deleteEventTriggerLogs _ _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
2023-04-25 14:22:27 +03:00
|
|
|
fetchEventLogs _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
|
|
|
fetchEventInvocationLogs _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|
|
|
|
fetchEventById _ _ = throw400 NotSupported $ "Event triggers are not supported for Data Connector sources"
|