mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
79b50add5e
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6945 GitOrigin-RevId: cad67b121090d4100330067d3d50f575292b4584
29 lines
1.0 KiB
Haskell
29 lines
1.0 KiB
Haskell
module Hasura.Backends.Postgres.Instances.PingSource
|
|
( runCockroachDBPing,
|
|
)
|
|
where
|
|
|
|
import Data.Text qualified as T
|
|
import Database.PG.Query qualified as PG
|
|
import Hasura.Backends.Postgres.Connection qualified as PG
|
|
import Hasura.Backends.Postgres.Connection.Connect (withPostgresDB)
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Common (SourceName, sourceNameToText)
|
|
import Hasura.Server.Version
|
|
|
|
runCockroachDBPing ::
|
|
(String -> IO ()) ->
|
|
SourceName ->
|
|
PG.PostgresConnConfiguration ->
|
|
IO ()
|
|
runCockroachDBPing pingLog sourceName sourceConnection = do
|
|
let versionMessage = "hasura-graphql-engine-version=" <> tshow currentVersion
|
|
query = PG.fromText ("select 1 /* " <> versionMessage <> " */")
|
|
result <- withPostgresDB sourceConnection $ do
|
|
PG.discardQE PG.dmlTxErrorHandler query () False
|
|
case result of
|
|
Left _ ->
|
|
pingLog ("Ping for " <> T.unpack (sourceNameToText sourceName) <> " failed")
|
|
Right _ ->
|
|
pingLog ("Ping for " <> T.unpack (sourceNameToText sourceName) <> " succeeded")
|