Skip to content

Expose WaitUntilReady constructors #46

@crypticmind

Description

@crypticmind

I'd like to add a custom check, a real connection to the database with a test query. Something like this:

mariaDBReady :: TestDBInfo -> WaitUntilReady
mariaDBReady db = WaitReady $ \container -> do
    withFrozenCallStack $ do
        let (endpointHost, endpointPort) = containerAddress container db.dbPort
            ci =
                defaultConnectInfo
                    { connectHost = unpack endpointHost
                    , connectPort = fromIntegral endpointPort
                    , connectUser = unpack db.dbUsername
                    , connectPassword = unpack db.dbPassword
                    , connectDatabase = unpack db.dbName
                    }
            wait = do
                r <- try (connect ci >>= flip query_ "select 2 + 3")
                case r of
                    Right [Only (i :: Int)] -> do
                        pure ()
                    Left (ex :: IOException) -> do
                        threadDelay 500000
                        wait
        liftIO wait

This is currently not possible since WaitReady is not public.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions