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 (stderr, hPutStrLn)
data Settings s =
Settings
{ Settings s -> Codec s
codec :: !(Codec s),
Settings s -> String
endpointPath :: !String,
Settings s -> GeneralException -> IO ()
onGeneralException :: !(GeneralException -> IO ()),
Settings s -> Int
responseTimeout :: !Int,
Settings s -> Int
concurrency :: !Int,
Settings s -> Int
requestQueueSize :: !Int
}
defSettings :: Codec s -> Settings s
defSettings :: Codec s -> Settings s
defSettings Codec s
c = Settings :: forall s.
Codec s
-> String
-> (GeneralException -> IO ())
-> Int
-> Int
-> Int
-> Settings s
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 (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ GeneralException -> String
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 :: Settings s
defJSONSettings = Codec s -> Settings s
forall s. Codec s -> Settings s
defSettings Codec s
forall s. FromGraphSON s => Codec s
jsonCodec