eventstore: EventStore TCP Client

[ bsd3, database, library ] [ Propose Tags ]

EventStore TCP Client http://geteventstore.com


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.1.2.0, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.3.1.0, 0.4.0.0, 0.5.0.0, 0.5.0.1, 0.6.0.0, 0.6.0.1, 0.7.0.0, 0.7.0.1, 0.7.1.0, 0.7.2.0, 0.7.2.1, 0.8.0.0, 0.9.0.0, 0.9.1.0, 0.9.1.1, 0.9.1.2, 0.9.1.3, 0.10.0.0, 0.10.0.1, 0.10.0.2, 0.11.0.0, 0.12.0.0, 0.13.0.0, 0.13.0.1, 0.13.1.0, 0.13.1.1, 0.13.1.2, 0.13.1.3, 0.13.1.4, 0.13.1.5, 0.13.1.6, 0.13.1.7, 0.14.0.0, 0.14.0.1, 0.14.0.2, 0.15.0.0, 0.15.0.1, 0.15.0.2, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.3.0, 1.3.1, 1.3.2, 1.3.3 (info)
Change log CHANGELOG.markdown
Dependencies aeson (>=0.8 && <0.12), async (>=2.0 && <2.2), base (>=4.7 && <5), bytestring (>=0.10.4 && <0.11), cereal (>=0.4 && <0.6), containers (==0.5.*), network (==2.6.*), protobuf (==0.2.*), random (==1.*), stm, text (>=1.1.1 && <1.3), time (>=1.4 && <1.6), unordered-containers, uuid (==1.3.*) [details]
License BSD-3-Clause
Author Yorick Laupa
Maintainer yo.eight@gmail.com
Category Database
Home page http://github.com/YoEight/eventstore
Bug tracker http://github.com/YoEight/eventstore/issues
Source repo head: git clone git://github.com/YoEight/eventstore.git
Uploaded by YorickLaupa at Tue Feb 9 11:25:33 UTC 2016
Distributions LTSHaskell:1.2.4, NixOS:1.3.3, Stackage:1.3.0
Downloads 21822 total (2218 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2016-02-12 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for eventstore-0.10.0.2

[back to package description]

EventStore Haskell TCP client

Join the chat at <a href="https://gitter.im/YoEight/eventstore">https://gitter.im/YoEight/eventstore</a> Build Status

That driver supports:

  • Read event(s) from regular or $all stream (forward or backward).
  • Write event(s) to regular stream.
  • Delete regular stream.
  • Transactional writes to regular stream.
  • Volatile subscriptions to regular or $all stream.
  • Catch-up subscriptions to regular or $all stream.
  • Competing consumers (a.k.a Persistent subscriptions) to regular stream.
  • Authenticated communication with EventStore server.
  • Read stream metadata (ACL and custom properties).
  • Write stream metadata (ACL and custom properties).

Not implemented yet

  • Secured connection with the server (SSL).

Requirements

  • GHC >= 7.8.3
  • Cabal >= 1.18
  • EventStore >= 3.0.0 (>= 3.1.0 if you want competing consumers)

Install

$ cabal update
$ cabal install eventstore
  • From source
$ git clone https://github.com/YoEight/eventstore.git
$ cd eventstore
$ cabal install --only-dependencies
$ cabal configure 
$ cabal install

How to test

Tests are available. Those assume a server is running on 127.0.0.1 and 1113 port.

$ cabal install --only-dependencies --enable-tests
$ cabal configure --enable-tests
$ cabal test

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 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 import also re-exports 'Control.Concurrent.Async' module, allowing the use of 'wait'
-- function for instance.

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 "127.0.0.1" 1113
    let js  = "isHaskellTheBest" .= True -- (.=) comes from Data.Aeson module.
        evt = createEvent "programming" Nothing (withJson js)
    
    -- Appends an event to a stream named `languages`.    
    as <- sendEvent conn "languages" anyVersion evt
    
    -- 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

Notes

That library was tested on Linux and OSX Yosemite.

Contributions and bug reports are welcome!

BSD3 License

-Yorick Laupa