feat: dump schema cache through admin API (#3233)

This commit is contained in:
Taimoor Zaeem
2024-02-19 21:20:29 -05:00
committed by GitHub
parent fac7acafa3
commit 32e1900370
3 changed files with 14 additions and 0 deletions
+1
View File
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #3171, Add an ability to dump config via admin API - @skywriter
- #3061, Apply all function settings as transaction-scoped settings - @taimoorzaeem
- #3171, Log schema cache stats to stderr - @steve-chavez
- #3210, Dump schema cache through admin API - @taimoorzaeem
### Fixed
+4
View File
@@ -4,6 +4,7 @@ module PostgREST.Admin
( runAdmin
) where
import qualified Data.Aeson as JSON
import qualified Hasql.Session as SQL
import qualified Network.HTTP.Types.Status as HTTP
import qualified Network.Wai as Wai
@@ -51,6 +52,9 @@ admin appState appConfig req respond = do
["config"] -> do
config <- AppState.getConfig appState
respond $ Wai.responseLBS HTTP.status200 [] (LBS.fromStrict $ encodeUtf8 $ Config.toText config)
["schema_cache"] -> do
sCache <- AppState.getSchemaCache appState
respond $ Wai.responseLBS HTTP.status200 [] (maybe mempty JSON.encode sCache)
_ ->
respond $ Wai.responseLBS HTTP.status404 [] mempty
+9
View File
@@ -642,6 +642,15 @@ def test_admin_config(defaultenv):
assert "admin-server-port" in response.text
def test_admin_schema_cache(defaultenv):
"Should get a success response from the admin server containing current schema cache"
with run(env=defaultenv) as postgrest:
response = postgrest.admin.get("/schema_cache")
assert response.status_code == 200
assert '"dbTables":[[{"qiName":"authors_only"' in response.text
def test_admin_ready_w_channel(defaultenv):
"Should get a success response from the admin server ready endpoint when the LISTEN channel is enabled"