2022-03-16 03:39:21 +03:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
2021-09-24 01:56:37 +03:00
|
|
|
{-# OPTIONS_GHC -O0 #-}
|
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
-- | Arg and Env Parsing for initialisation of the engine along with
|
|
|
|
-- corresponding logging and other helper functionality.
|
|
|
|
--
|
|
|
|
-- This module is intended as the interface for options parsing and
|
|
|
|
-- its submodules should not need to be imported directly.
|
2020-04-24 10:55:51 +03:00
|
|
|
module Hasura.Server.Init
|
2022-08-04 06:21:55 +03:00
|
|
|
( -- * Option Fetching and Merging
|
|
|
|
mkHGEOptions,
|
|
|
|
mkServeOptions,
|
|
|
|
processPostgresConnInfo,
|
|
|
|
|
|
|
|
-- * Metadata DB
|
|
|
|
getDbId,
|
|
|
|
getPgVersion,
|
|
|
|
|
|
|
|
-- * Re-exports
|
2021-09-24 01:56:37 +03:00
|
|
|
module Hasura.Server.Init.Config,
|
2022-07-15 11:54:27 +03:00
|
|
|
module Hasura.Server.Init.Env,
|
|
|
|
module Hasura.Server.Init.Arg,
|
|
|
|
module Hasura.Server.Init.Logging,
|
2021-09-24 01:56:37 +03:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2022-08-04 06:21:55 +03:00
|
|
|
import Data.HashSet qualified as HashSet
|
|
|
|
import Data.Text qualified as Text
|
|
|
|
import Database.PG.Query qualified as Query
|
|
|
|
import Hasura.Backends.Postgres.Connection qualified as Connection
|
2022-07-15 11:54:27 +03:00
|
|
|
import Hasura.Base.Error qualified as Error
|
2022-08-05 03:28:49 +03:00
|
|
|
import Hasura.GraphQL.Execute.Subscription.Options qualified as Subscription.Options
|
2022-07-14 20:57:28 +03:00
|
|
|
import Hasura.GraphQL.Schema.Options qualified as Options
|
2022-08-17 04:07:44 +03:00
|
|
|
import Hasura.Logging qualified as Logging
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.Prelude
|
2022-08-04 06:21:55 +03:00
|
|
|
import Hasura.RQL.Types.Common qualified as Common
|
2022-07-15 11:54:27 +03:00
|
|
|
import Hasura.Server.Auth qualified as Auth
|
|
|
|
import Hasura.Server.Cors qualified as Cors
|
|
|
|
import Hasura.Server.Init.Arg
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.Server.Init.Config
|
2022-07-15 11:54:27 +03:00
|
|
|
import Hasura.Server.Init.Env
|
|
|
|
import Hasura.Server.Init.Logging
|
2022-08-04 06:21:55 +03:00
|
|
|
import Hasura.Server.Logging qualified as Server.Logging
|
2022-07-15 11:54:27 +03:00
|
|
|
import Hasura.Server.Types qualified as Types
|
2022-08-04 06:21:55 +03:00
|
|
|
import Network.WebSockets qualified as WebSockets
|
2022-09-21 21:01:48 +03:00
|
|
|
import Refined (unrefine)
|
2022-07-15 11:54:27 +03:00
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- TODO(SOLOMON): Where does this note belong?
|
|
|
|
|
|
|
|
{- Note [ReadOnly Mode]
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
This mode starts the server in a (database) read-only mode. That is, only
|
|
|
|
read-only queries are allowed on users' database sources, and write
|
|
|
|
queries throw a runtime error. The use-case is for failsafe operations.
|
|
|
|
Metadata APIs are also disabled.
|
|
|
|
|
|
|
|
Following is the precise behaviour -
|
|
|
|
1. For any GraphQL API (relay/hasura; http/websocket) - disable execution of
|
|
|
|
mutations
|
|
|
|
2. Metadata API is disabled
|
|
|
|
3. /v2/query API - insert, delete, update, run_sql are disabled
|
|
|
|
4. /v1/query API - insert, delete, update, run_sql are disabled
|
|
|
|
5. No source catalog migrations are run
|
|
|
|
6. During build schema cache phase, building event triggers are disabled (as
|
|
|
|
they create corresponding database triggers)
|
|
|
|
-}
|
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
--------------------------------------------------------------------------------
|
2021-12-08 09:26:46 +03:00
|
|
|
|
2022-08-04 06:21:55 +03:00
|
|
|
-- | Query the Metadata DB for the Metadata DB UUID.
|
|
|
|
-- TODO: Move into a dedicated Metadata module (ala Pro).
|
2022-08-17 04:07:44 +03:00
|
|
|
getDbId :: Query.TxE Error.QErr Types.MetadataDbId
|
2019-11-26 15:14:21 +03:00
|
|
|
getDbId =
|
2022-08-04 06:21:55 +03:00
|
|
|
Types.MetadataDbId . runIdentity . Query.getRow
|
|
|
|
<$> Query.withQE
|
|
|
|
Connection.defaultTxErrorHandler
|
|
|
|
[Query.sql|
|
2019-11-26 15:14:21 +03:00
|
|
|
SELECT (hasura_uuid :: text) FROM hdb_catalog.hdb_version
|
2021-09-24 01:56:37 +03:00
|
|
|
|]
|
|
|
|
()
|
|
|
|
False
|
2019-11-26 15:14:21 +03:00
|
|
|
|
2022-08-04 06:21:55 +03:00
|
|
|
getPgVersion :: Query.TxE Error.QErr Types.PGVersion
|
|
|
|
getPgVersion = Types.PGVersion <$> Query.serverVersion
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
--------------------------------------------------------------------------------
|
2019-07-11 08:37:06 +03:00
|
|
|
|
2022-08-01 22:35:13 +03:00
|
|
|
-- | Given the 'ServeOptionsRaw' parsed from the arg parser,
|
2022-07-15 11:54:27 +03:00
|
|
|
-- postprocess the db url and fetch env vars associated with the main
|
|
|
|
-- command parser, then process the subcommand raw values if
|
|
|
|
-- necessary.
|
2021-09-24 01:56:37 +03:00
|
|
|
mkHGEOptions ::
|
2022-08-17 04:07:44 +03:00
|
|
|
Logging.EnabledLogTypes impl => HGEOptionsRaw (ServeOptionsRaw impl) -> WithEnv (HGEOptions (ServeOptions impl))
|
2022-07-01 06:39:39 +03:00
|
|
|
mkHGEOptions (HGEOptionsRaw rawDbUrl rawMetadataDbUrl rawCmd) = do
|
|
|
|
dbUrl <- processPostgresConnInfo rawDbUrl
|
2022-08-05 03:28:49 +03:00
|
|
|
metadataDbUrl <- withOption rawMetadataDbUrl metadataDbUrlOption
|
2022-07-01 06:39:39 +03:00
|
|
|
cmd <- case rawCmd of
|
|
|
|
HCServe rso -> HCServe <$> mkServeOptions rso
|
|
|
|
HCExport -> pure HCExport
|
|
|
|
HCClean -> pure HCClean
|
|
|
|
HCVersion -> pure HCVersion
|
|
|
|
HCDowngrade tgt -> pure (HCDowngrade tgt)
|
|
|
|
pure $ HGEOptions dbUrl metadataDbUrl cmd
|
2018-12-19 14:38:33 +03:00
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
-- | 'PostressConnInfo' is a a tuple of some @a@ with a 'Maybe Int'
|
|
|
|
-- representing the retries setting. This function thus takes a
|
2022-08-01 22:35:13 +03:00
|
|
|
-- retries setting and a 'PostgresConnInfoRaw' from the arg parser and
|
2022-07-15 11:54:27 +03:00
|
|
|
-- merges those results with the contents of their corresponding env
|
|
|
|
-- vars.
|
2021-09-24 01:56:37 +03:00
|
|
|
processPostgresConnInfo ::
|
2022-08-01 22:35:13 +03:00
|
|
|
PostgresConnInfo (Maybe PostgresConnInfoRaw) ->
|
2022-08-17 04:07:44 +03:00
|
|
|
WithEnv (PostgresConnInfo (Maybe Common.UrlConf))
|
2021-09-24 01:56:37 +03:00
|
|
|
processPostgresConnInfo PostgresConnInfo {..} = do
|
2022-08-05 03:28:49 +03:00
|
|
|
withEnvRetries <- withOption _pciRetries retriesNumOption
|
2020-12-28 15:56:00 +03:00
|
|
|
databaseUrl <- rawConnInfoToUrlConf _pciDatabaseConn
|
|
|
|
pure $ PostgresConnInfo databaseUrl withEnvRetries
|
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
-- | A helper function for 'processPostgresConnInfo' which fetches
|
|
|
|
-- postgres connection info from the 'WithEnv' and merges it with the
|
|
|
|
-- arg parser result.
|
2022-08-17 04:07:44 +03:00
|
|
|
rawConnInfoToUrlConf :: Maybe PostgresConnInfoRaw -> WithEnv (Maybe Common.UrlConf)
|
2020-12-28 15:56:00 +03:00
|
|
|
rawConnInfoToUrlConf maybeRawConnInfo = do
|
|
|
|
env <- ask
|
2022-08-05 03:28:49 +03:00
|
|
|
let databaseUrlEnvVar = _envVar databaseUrlOption
|
2020-12-28 15:56:00 +03:00
|
|
|
hasDatabaseUrlEnv = any ((== databaseUrlEnvVar) . fst) env
|
|
|
|
|
2021-01-07 12:04:22 +03:00
|
|
|
pure $ case maybeRawConnInfo of
|
2020-12-28 15:56:00 +03:00
|
|
|
-- If no --database-url or connection options provided in CLI command
|
2021-09-24 01:56:37 +03:00
|
|
|
Nothing ->
|
|
|
|
if hasDatabaseUrlEnv
|
|
|
|
then -- Consider env variable as is in order to store it as @`UrlConf`
|
|
|
|
-- in default source configuration in metadata
|
2022-08-04 06:21:55 +03:00
|
|
|
Just $ Common.UrlFromEnv $ Text.pack databaseUrlEnvVar
|
2021-09-24 01:56:37 +03:00
|
|
|
else Nothing
|
2020-12-28 15:56:00 +03:00
|
|
|
Just databaseConn ->
|
2022-08-04 06:21:55 +03:00
|
|
|
Just . Common.UrlValue . Common.InputWebhook $ case databaseConn of
|
2021-09-24 01:56:37 +03:00
|
|
|
PGConnDatabaseUrl urlTemplate -> urlTemplate
|
|
|
|
PGConnDetails connDetails -> rawConnDetailsToUrl connDetails
|
2018-12-19 14:38:33 +03:00
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- | Merge the results of the serve subcommmand arg parser with
|
|
|
|
-- corresponding values from the 'WithEnv' context.
|
2022-08-17 04:07:44 +03:00
|
|
|
mkServeOptions :: forall impl. Logging.EnabledLogTypes impl => ServeOptionsRaw impl -> WithEnv (ServeOptions impl)
|
2022-08-05 03:28:49 +03:00
|
|
|
mkServeOptions ServeOptionsRaw {..} = do
|
|
|
|
soPort <- withOptionDefault rsoPort servePortOption
|
|
|
|
soHost <- withOptionDefault rsoHost serveHostOption
|
|
|
|
soConnParams <- mkConnParams rsoConnParams
|
|
|
|
soTxIso <- withOptionDefault rsoTxIso txIsolationOption
|
|
|
|
soAdminSecret <- maybe mempty (HashSet.singleton) <$> withOptions rsoAdminSecret [adminSecretOption, accessKeyOption]
|
|
|
|
soAuthHook <- mkAuthHook rsoAuthHook
|
|
|
|
soJwtSecret <- maybeToList <$> withOption rsoJwtSecret jwtSecretOption
|
|
|
|
soUnAuthRole <- withOption rsoUnAuthRole unAuthRoleOption
|
|
|
|
soCorsConfig <- mkCorsConfig rsoCorsConfig
|
|
|
|
soEnableConsole <- withOptionSwitch rsoEnableConsole enableConsoleOption
|
|
|
|
soConsoleAssetsDir <- withOption rsoConsoleAssetsDir consoleAssetsDirOption
|
2022-09-27 17:50:32 +03:00
|
|
|
soConsoleSentryDsn <- withOption rsoConsoleSentryDsn consoleSentryDsnOption
|
2022-08-05 03:28:49 +03:00
|
|
|
soEnableTelemetry <- withOptionDefault rsoEnableTelemetry enableTelemetryOption
|
|
|
|
soStringifyNum <-
|
|
|
|
case rsoStringifyNum of
|
|
|
|
Options.Don'tStringifyNumbers -> withOptionDefault Nothing stringifyNumOption
|
2022-07-29 03:45:51 +03:00
|
|
|
stringifyNums -> pure stringifyNums
|
2022-08-05 03:28:49 +03:00
|
|
|
soDangerousBooleanCollapse <- withOptionDefault rsoDangerousBooleanCollapse dangerousBooleanCollapseOption
|
|
|
|
soEnabledAPIs <- withOptionDefault rsoEnabledAPIs enabledAPIsOption
|
|
|
|
soLiveQueryOpts <- do
|
|
|
|
_lqoRefetchInterval <- withOptionDefault rsoMxRefetchInt mxRefetchDelayOption
|
|
|
|
_lqoBatchSize <- withOptionDefault rsoMxBatchSize mxBatchSizeOption
|
|
|
|
pure $ Subscription.Options.SubscriptionsOptions {..}
|
|
|
|
soStreamingQueryOpts <- do
|
|
|
|
_lqoRefetchInterval <- withOptionDefault rsoStreamingMxRefetchInt streamingMxRefetchDelayOption
|
|
|
|
_lqoBatchSize <- withOptionDefault rsoStreamingMxBatchSize streamingMxBatchSizeOption
|
|
|
|
pure $ Subscription.Options.SubscriptionsOptions {..}
|
|
|
|
soEnableAllowlist <- withOptionSwitch rsoEnableAllowlist enableAllowlistOption
|
|
|
|
soEnabledLogTypes <- withOptionDefault rsoEnabledLogTypes (enabledLogsOption @impl)
|
|
|
|
soLogLevel <- withOptionDefault rsoLogLevel logLevelOption
|
|
|
|
soDevMode <- withOptionSwitch rsoDevMode graphqlDevModeOption
|
|
|
|
soResponseInternalErrorsConfig <- mkResponseInternalErrorsConfig soDevMode
|
2022-08-10 22:17:05 +03:00
|
|
|
soEventsHttpPoolSize <- withOptionDefault rsoEventsHttpPoolSize graphqlEventsHttpPoolSizeOption
|
|
|
|
soEventsFetchInterval <- withOptionDefault rsoEventsFetchInterval graphqlEventsFetchIntervalOption
|
2022-08-05 03:28:49 +03:00
|
|
|
soAsyncActionsFetchInterval <- withOptionDefault rsoAsyncActionsFetchInterval asyncActionsFetchIntervalOption
|
|
|
|
soEnableRemoteSchemaPermissions <-
|
|
|
|
case rsoEnableRemoteSchemaPermissions of
|
|
|
|
Options.DisableRemoteSchemaPermissions -> withOptionDefault Nothing enableRemoteSchemaPermsOption
|
2022-07-29 03:45:51 +03:00
|
|
|
enableRemoteSchemaPermissions -> pure enableRemoteSchemaPermissions
|
2022-08-05 03:28:49 +03:00
|
|
|
soConnectionOptions <- mkConnectionOptions
|
|
|
|
soWebSocketKeepAlive <- withOptionDefault rsoWebSocketKeepAlive webSocketKeepAliveOption
|
|
|
|
soInferFunctionPermissions <- withOptionDefault rsoInferFunctionPermissions inferFunctionPermsOption
|
|
|
|
soEnableMaintenanceMode <- case rsoEnableMaintenanceMode of
|
|
|
|
Types.MaintenanceModeDisabled -> withOptionDefault Nothing enableMaintenanceModeOption
|
2022-07-29 03:45:51 +03:00
|
|
|
maintenanceModeEnabled -> pure maintenanceModeEnabled
|
2022-08-05 03:28:49 +03:00
|
|
|
soSchemaPollInterval <- withOptionDefault rsoSchemaPollInterval schemaPollIntervalOption
|
|
|
|
soExperimentalFeatures <- withOptionDefault rsoExperimentalFeatures experimentalFeaturesOption
|
|
|
|
soEventsFetchBatchSize <- withOptionDefault rsoEventsFetchBatchSize eventsFetchBatchSizeOption
|
|
|
|
soGracefulShutdownTimeout <- withOptionDefault rsoGracefulShutdownTimeout gracefulShutdownOption
|
|
|
|
soWebSocketConnectionInitTimeout <- withOptionDefault rsoWebSocketConnectionInitTimeout webSocketConnectionInitTimeoutOption
|
|
|
|
let soEventingMode = Types.EventingEnabled
|
|
|
|
let soReadOnlyMode = Types.ReadOnlyModeDisabled
|
|
|
|
soEnableMetadataQueryLogging <- case rsoEnableMetadataQueryLoggingEnv of
|
|
|
|
Server.Logging.MetadataQueryLoggingDisabled -> withOptionDefault Nothing enableMetadataQueryLoggingOption
|
2022-07-29 03:45:51 +03:00
|
|
|
metadataQueryLoggingEnabled -> pure metadataQueryLoggingEnabled
|
2022-08-05 03:28:49 +03:00
|
|
|
soDefaultNamingConvention <- withOption rsoDefaultNamingConvention defaultNamingConventionOption
|
2022-10-20 15:45:31 +03:00
|
|
|
soMetadataDefaults <- withOptionDefault rsoMetadataDefaults metadataDefaultsOption
|
2022-08-09 14:42:12 +03:00
|
|
|
soExtensionsSchema <- withOptionDefault rsoExtensionsSchema metadataDBExtensionsSchemaOption
|
2022-05-26 14:54:30 +03:00
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
pure ServeOptions {..}
|
2018-12-19 14:38:33 +03:00
|
|
|
where
|
2022-08-05 03:28:49 +03:00
|
|
|
mkConnParams ConnParamsRaw {..} = do
|
2022-09-21 21:01:48 +03:00
|
|
|
cpStripes <- unrefine <$> withOptionDefault rcpStripes pgStripesOption
|
2019-12-12 23:10:04 +03:00
|
|
|
-- Note: by Little's Law we can expect e.g. (with 50 max connections) a
|
|
|
|
-- hard throughput cap at 1000RPS when db queries take 50ms on average:
|
2022-09-21 21:01:48 +03:00
|
|
|
cpConns <- unrefine <$> withOptionDefault rcpConns pgConnsOption
|
|
|
|
cpIdleTime <- unrefine <$> withOptionDefault rcpIdleTime pgTimeoutOption
|
2022-08-05 03:28:49 +03:00
|
|
|
cpAllowPrepare <- withOptionDefault rcpAllowPrepare pgUsePreparedStatementsOption
|
|
|
|
-- TODO: Add newtype to allow this:
|
|
|
|
cpMbLifetime <- do
|
2022-09-21 21:01:48 +03:00
|
|
|
lifetime <- unrefine <$> withOptionDefault rcpConnLifetime pgConnLifetimeOption
|
2022-08-05 03:28:49 +03:00
|
|
|
if lifetime == 0
|
|
|
|
then pure Nothing
|
|
|
|
else pure (Just lifetime)
|
2022-09-21 21:01:48 +03:00
|
|
|
cpTimeout <- fmap unrefine <$> withOption rcpPoolTimeout pgPoolTimeoutOption
|
2022-08-05 03:28:49 +03:00
|
|
|
let cpCancel = True
|
2021-09-24 01:56:37 +03:00
|
|
|
return $
|
2022-08-05 03:28:49 +03:00
|
|
|
Query.ConnParams {..}
|
2018-12-19 14:38:33 +03:00
|
|
|
|
2022-08-04 05:24:35 +03:00
|
|
|
mkAuthHook (AuthHookRaw mUrl mType) = do
|
2022-08-05 03:28:49 +03:00
|
|
|
mUrlEnv <- withOption mUrl authHookOption
|
|
|
|
-- Also support HASURA_GRAPHQL_AUTH_HOOK_TYPE
|
2022-08-17 04:07:44 +03:00
|
|
|
-- TODO (from master):- drop this in next major update <--- (NOTE: This comment is from 2020-08-21)
|
2022-08-05 03:28:49 +03:00
|
|
|
authMode <-
|
2022-08-09 14:42:12 +03:00
|
|
|
onNothing
|
|
|
|
mType
|
|
|
|
( fromMaybe (_default authHookModeOption)
|
|
|
|
<$> considerEnvs
|
|
|
|
[_envVar authHookModeOption, "HASURA_GRAPHQL_AUTH_HOOK_TYPE"]
|
|
|
|
)
|
2022-08-05 03:28:49 +03:00
|
|
|
pure $ (`Auth.AuthHook` authMode) <$> mUrlEnv
|
2019-01-04 09:42:36 +03:00
|
|
|
|
2019-03-04 10:46:53 +03:00
|
|
|
mkCorsConfig mCfg = do
|
2022-08-05 03:28:49 +03:00
|
|
|
corsCfg <- do
|
|
|
|
corsDisabled <- withOptionDefault Nothing disableCorsOption
|
2021-09-24 01:56:37 +03:00
|
|
|
if corsDisabled
|
2022-08-05 03:28:49 +03:00
|
|
|
then pure (Cors.CCDisabled $ _default disableCorsOption)
|
|
|
|
else withOptionDefault mCfg corsDomainOption
|
2020-02-03 14:13:03 +03:00
|
|
|
|
2022-08-05 03:28:49 +03:00
|
|
|
readCookVal <-
|
|
|
|
case rsoWsReadCookie of
|
|
|
|
False -> withOptionDefault Nothing wsReadCookieOption
|
|
|
|
p -> pure p
|
2022-07-15 11:54:27 +03:00
|
|
|
wsReadCookie <- case (Cors.isCorsDisabled corsCfg, readCookVal) of
|
2022-08-05 03:28:49 +03:00
|
|
|
(True, _) -> pure readCookVal
|
2021-09-24 01:56:37 +03:00
|
|
|
(False, True) ->
|
|
|
|
throwError $
|
2022-08-05 03:28:49 +03:00
|
|
|
_envVar wsReadCookieOption
|
2021-09-24 01:56:37 +03:00
|
|
|
<> " can only be used when CORS is disabled"
|
2019-03-04 10:46:53 +03:00
|
|
|
(False, False) -> return False
|
2022-08-05 03:28:49 +03:00
|
|
|
pure $ case corsCfg of
|
2022-07-15 11:54:27 +03:00
|
|
|
Cors.CCDisabled _ -> Cors.CCDisabled wsReadCookie
|
2021-09-24 01:56:37 +03:00
|
|
|
_ -> corsCfg
|
2019-03-04 10:46:53 +03:00
|
|
|
|
2022-08-05 03:28:49 +03:00
|
|
|
mkResponseInternalErrorsConfig devMode = do
|
|
|
|
adminInternalErrors <- withOptionDefault rsoAdminInternalErrors graphqlAdminInternalErrorsOption
|
2022-04-07 17:41:43 +03:00
|
|
|
|
2022-08-05 03:28:49 +03:00
|
|
|
if
|
|
|
|
| devMode -> pure InternalErrorsAllRequests
|
|
|
|
| adminInternalErrors -> pure InternalErrorsAdminOnly
|
|
|
|
| otherwise -> pure InternalErrorsDisabled
|
2019-04-17 12:48:41 +03:00
|
|
|
|
2022-08-05 03:28:49 +03:00
|
|
|
mkConnectionOptions = do
|
|
|
|
webSocketCompressionFromEnv <- withOptionSwitch rsoWebSocketCompression webSocketCompressionOption
|
|
|
|
pure $
|
|
|
|
WebSockets.defaultConnectionOptions
|
|
|
|
{ WebSockets.connectionCompressionOptions =
|
|
|
|
if webSocketCompressionFromEnv
|
|
|
|
then WebSockets.PermessageDeflateCompression WebSockets.defaultPermessageDeflate
|
|
|
|
else WebSockets.NoCompression
|
|
|
|
}
|