feat: dump schema cache through admin API (#3233)
This commit is contained in:
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- #3171, Add an ability to dump config via admin API - @skywriter
|
- #3171, Add an ability to dump config via admin API - @skywriter
|
||||||
- #3061, Apply all function settings as transaction-scoped settings - @taimoorzaeem
|
- #3061, Apply all function settings as transaction-scoped settings - @taimoorzaeem
|
||||||
- #3171, Log schema cache stats to stderr - @steve-chavez
|
- #3171, Log schema cache stats to stderr - @steve-chavez
|
||||||
|
- #3210, Dump schema cache through admin API - @taimoorzaeem
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module PostgREST.Admin
|
|||||||
( runAdmin
|
( runAdmin
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import qualified Data.Aeson as JSON
|
||||||
import qualified Hasql.Session as SQL
|
import qualified Hasql.Session as SQL
|
||||||
import qualified Network.HTTP.Types.Status as HTTP
|
import qualified Network.HTTP.Types.Status as HTTP
|
||||||
import qualified Network.Wai as Wai
|
import qualified Network.Wai as Wai
|
||||||
@@ -51,6 +52,9 @@ admin appState appConfig req respond = do
|
|||||||
["config"] -> do
|
["config"] -> do
|
||||||
config <- AppState.getConfig appState
|
config <- AppState.getConfig appState
|
||||||
respond $ Wai.responseLBS HTTP.status200 [] (LBS.fromStrict $ encodeUtf8 $ Config.toText config)
|
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
|
respond $ Wai.responseLBS HTTP.status404 [] mempty
|
||||||
|
|
||||||
|
|||||||
@@ -642,6 +642,15 @@ def test_admin_config(defaultenv):
|
|||||||
assert "admin-server-port" in response.text
|
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):
|
def test_admin_ready_w_channel(defaultenv):
|
||||||
"Should get a success response from the admin server ready endpoint when the LISTEN channel is enabled"
|
"Should get a success response from the admin server ready endpoint when the LISTEN channel is enabled"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user