module Network.Greskell.WebSocket.Connection.Settings
(
Settings
, defSettings
, defJSONSettings
, codec
, endpointPath
, onGeneralException
, responseTimeout
, concurrency
, requestQueueSize
) where
import Data.Greskell.GraphSON (FromGraphSON)
import Network.Greskell.WebSocket.Codec (Codec)
import Network.Greskell.WebSocket.Codec.JSON (jsonCodec)
import Network.Greskell.WebSocket.Connection.Type (GeneralException)
import System.IO (hPutStrLn, stderr)
data Settings s
= Settings
{ forall s. Settings s -> Codec s
codec :: !(Codec s)
, forall s. Settings s -> String
endpointPath :: !String
, forall s. Settings s -> GeneralException -> IO ()
onGeneralException :: !(GeneralException -> IO ())
, forall s. Settings s -> Int
responseTimeout :: !Int
, forall s. Settings s -> Int
concurrency :: !Int
, forall s. Settings s -> Int
requestQueueSize :: !Int
}
defSettings :: Codec s -> Settings s
defSettings :: forall s. Codec s -> Settings s
defSettings Codec s
c = Settings
{ codec :: Codec s
codec = Codec s
c,
endpointPath :: String
endpointPath = String
"/gremlin",
onGeneralException :: GeneralException -> IO ()
onGeneralException = \GeneralException
e -> Handle -> String -> IO ()
hPutStrLn Handle
stderr forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show GeneralException
e,
responseTimeout :: Int
responseTimeout = Int
60,
concurrency :: Int
concurrency = Int
4,
requestQueueSize :: Int
requestQueueSize = Int
8
}
defJSONSettings :: FromGraphSON s => Settings s
defJSONSettings :: forall s. FromGraphSON s => Settings s
defJSONSettings = forall s. Codec s -> Settings s
defSettings forall s. FromGraphSON s => Codec s
jsonCodec