在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):YoEight/eventstore开源软件地址(OpenSource Url):https://github.com/YoEight/eventstore开源编程语言(OpenSource Language):Haskell 100.0%开源软件介绍(OpenSource Introduction):REPO HAS MOVED!https://github.com/EventStore/EventStoreDB-Client-HaskellThis client is now officiallly supported by EventStore Ltd. The code is now hosted here:EventStore Haskell TCP clientTalk and exchange ideas in our dedicated Discord Server That driver supports 100% of EventStore features ! More information about the GetEventStore database can be found there: https://eventstore.com/ Requirements
Note: If you use this client version >= to Install
How to testTests are available. Those assume a server is running on
How to use{-# LANGUAGE OverloadedStrings #-} -- That library uses `Text` pervasively. This pragma permits to use
-- String literal when a Text is needed.
module Main where
import Control.Concurrent.Async (wait)
import Data.Aeson
-- It requires to have `aeson` package installed. Note that EventStore doesn't constraint you to JSON
-- format but putting common use aside, by doing so you'll be able to use some interesting EventStore
-- features like its Complex Event Processing (CEP) capabality.
import Database.EventStore
-- Note that imports 'NonEmpty' data constructor and 'nonEmpty' function from
-- 'Data.List.NonEmpty'.
main :: IO ()
main = do
-- A common pattern with an EventStore connection is to create a single instance only and pass it
-- wherever you need it (it's threadsafe). It's very important to not consider an EventStore connection like
-- its regular SQL counterpart. An EventStore connection will try its best to reconnect
-- automatically to the server if the connection dropped. Of course that behavior can be tuned
-- through some settings.
conn <- connect defaultSettings (Static "127.0.0.1" 1113)
let js = object ["isHaskellTheBest" .= True] -- (.=) comes from Data.Aeson module.
evt = createEvent "programming" Nothing (withJson js)
-- Appends an event to a stream named `languages`.
as <- sendEvent conn (StreamName "languages") anyVersion evt Nothing
-- EventStore interactions are fundamentally asynchronous. Nothing requires you to wait
-- for the completion of an operation, but it's good to know if something went wrong.
_ <- wait as
-- Again, if you decide to `shutdown` an EventStore connection, it means your application is
-- about to terminate.
shutdown conn
-- Make sure the EventStore connection completes every ongoing operation. For instance, if
-- at the moment we call `shutdown` and some operations (or subscriptions) were still pending,
-- the connection aborted all of them.
waitTillClosed conn NotesThat library was tested on Linux and OSX. Contributions and bug reports are welcome! BSD3 License -Yorick Laupa |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论