Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHEOPSDEV-5905 Add the ability to run internal logic #1

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Network/K8s/Application.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ defConfig = Config 10120 30
data K8sChecks = K8sChecks
{ runReadynessCheck :: IO Bool -- ^ Checks that application can receive requests
, runLivenessCheck :: IO Bool -- ^ Checks that application running (should not be restarted)
, internalLogic :: Maybe Application -- ^ Internal application logic to run
}

-- | Application state.
Expand Down Expand Up @@ -278,8 +279,11 @@ runK8sServiceEndpoint port teardown_time_seconds K8sChecks{..} state_box server
killThread $ asyncThreadId server
resp $ responseLBS status200 [(hContentType, "text/plain")] "tearing down"
["_metrics"] -> metricsApp req resp
-- If it's any other path then we simply return 404
_ -> resp $ Wai.responseLBS status404 [(hContentType, "text/plain")] "Not found"
_ -> case internalLogic of
-- If it's any other path then we simply return 404
Nothing -> resp $ Wai.responseLBS status404 [(hContentType, "text/plain")] "Not found"
-- If internal logic set - run it
Just application -> application req resp

-- | Switches the application to the tearing down state.
--
Expand Down
Loading