当进程即将关闭时,我想关闭商店连接(添加close eventStoreConnection
之类的功能):
main = do
eventStoreConnection <- EventStore.connect EventStore.defaultSettings (EventStore.Static "127.0.0.1" 1113)
scotty 3000 $ do
get "/health/liveness" $ do html "OK"
post "/introduceIdea" $ do
command <- jsonData
liftIO $ persist eventStoreConnection command
html "OK"
答案 0 :(得分:3)
您可以使用bracket。喜欢:
let connect = EventStore.connect EventStore.defaultSettings (EventStore.Static "127.0.0.1" 1113))
bracket connect close $ \eventStoreConnection ->
scotty 3000 $ ...