eventstore 0.6.0.1 → 0.7.0.0
raw patch · 5 files changed
+71/−17 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Database.EventStore: Any :: ExpectedVersion
- Database.EventStore: EmptyStream :: ExpectedVersion
- Database.EventStore: NoStream :: ExpectedVersion
- Database.EventStore: recordedEventCreatedEpoch :: RecordedEvent -> !(Maybe Integer)
+ Database.EventStore: anyStream :: ExpectedVersion
+ Database.EventStore: emptyStream :: ExpectedVersion
+ Database.EventStore: exactStream :: Int32 -> ExpectedVersion
+ Database.EventStore: hasCaughtUp :: Catchup -> IO Bool
+ Database.EventStore: noStream :: ExpectedVersion
+ Database.EventStore: waitTillCatchup :: Catchup -> IO ()
- Database.EventStore: RecordedEvent :: !Text -> !UUID -> !Int32 -> !Text -> !ByteString -> !(Maybe ByteString) -> !Bool -> !(Maybe UTCTime) -> !(Maybe Integer) -> RecordedEvent
+ Database.EventStore: RecordedEvent :: !Text -> !UUID -> !Int32 -> !Text -> !ByteString -> !(Maybe ByteString) -> !Bool -> !(Maybe UTCTime) -> RecordedEvent
Files
- CHANGELOG.markdown +8/−0
- Database/EventStore.hs +7/−1
- Database/EventStore/Catchup.hs +20/−1
- Database/EventStore/Internal/Types.hs +35/−14
- eventstore.cabal +1/−1
CHANGELOG.markdown view
@@ -1,3 +1,11 @@+0.7.0.0+-------+* Fix date conversion. `recordedEventCreateEpoch` is no longer exposed.+* Add `waitTillCatchup` and `hasCaughtUp` functions.+* Add `exactStream` `ExpectedVersion` smart constructor. As the result,+`ExpectedVersion` constructors are no longer exposed. You have to use+`anyStream`, `noStream`, `emptyStream` or `exactStream` instead.+ 0.6.0.1 ------- No changes
Database/EventStore.hs view
@@ -65,6 +65,8 @@ , catchupAwait , catchupStream , catchupUnsubscribe+ , waitTillCatchup+ , hasCaughtUp -- * Results , AllEventsSlice(..) , DeleteResult(..)@@ -85,7 +87,11 @@ , positionStart , positionEnd -- * Misc- , ExpectedVersion(..)+ , ExpectedVersion+ , anyStream+ , noStream+ , emptyStream+ , exactStream -- * Re-export , module Control.Concurrent.Async ) where
Database/EventStore/Catchup.hs view
@@ -19,6 +19,8 @@ , catchupAllStart , catchupStream , catchupUnsubscribe+ , waitTillCatchup+ , hasCaughtUp ) where --------------------------------------------------------------------------------@@ -58,7 +60,8 @@ = Catchup { catchupStream :: Text -- ^ The name of the stream to which the subscription is subscribed.- , catchupChan :: Chan (Either CatchupError ResolvedEvent)+ , catchupChan :: Chan (Either CatchupError ResolvedEvent)+ , catchupSubMVar :: MVar Subscription , catchupUnsubscribe :: IO () -- ^ Asynchronously unsubscribes from the stream. }@@ -101,6 +104,7 @@ let catchup = Catchup { catchupStream = stream_id , catchupChan = chan+ , catchupSubMVar = var , catchupUnsubscribe = do cancel as sub_m <- tryTakeMVar var@@ -136,6 +140,7 @@ let catchup = Catchup { catchupStream = "" , catchupChan = chan+ , catchupSubMVar = var , catchupUnsubscribe = do cancel as sub_m <- tryTakeMVar var@@ -214,3 +219,17 @@ writeChan chan (Left e) throwIO e++--------------------------------------------------------------------------------+-- | Waits until 'Catchup' subscription catch-up its stream.+waitTillCatchup :: Catchup -> IO ()+waitTillCatchup c = do+ _ <- readMVar $ catchupSubMVar c+ return ()++--------------------------------------------------------------------------------+-- | Non blocking version of `waitTillCatchup`.+hasCaughtUp :: Catchup -> IO Bool+hasCaughtUp c = do+ res <- tryReadMVar $ catchupSubMVar c+ return $ isJust res
Database/EventStore/Internal/Types.hs view
@@ -15,7 +15,7 @@ module Database.EventStore.Internal.Types where ---------------------------------------------------------------------------------import Control.Applicative ((<|>))+import Control.Applicative import Control.Exception import Data.ByteString (ByteString) import Data.ByteString.Lazy (fromStrict, toStrict)@@ -23,6 +23,7 @@ import Data.Maybe import Data.Typeable import Data.Word+import Foreign.C.Types (CTime(..)) import GHC.Generics (Generic) --------------------------------------------------------------------------------@@ -120,18 +121,13 @@ -- idempotency assurances given by the EventStore. -- -- The EventStore will assure idempotency for all operations using any value--- in 'ExpectedVersion' except for 'Any'. When using 'Any' the EventStore will+-- in 'ExpectedVersion' except for 'anyStream'. When using 'anyStream' the EventStore will -- do its best to assure idempotency but will not guarantee idempotency. data ExpectedVersion = Any- -- ^ This write should not conflict with anything and should always- -- succeed. | NoStream- -- ^ The stream being written to should not yet exist. If it does exist- -- treat that as a concurrency problem. | EmptyStream- -- ^ The stream should exist and should be empty. If it does not exist or- -- is not empty, treat that as a concurrency problem.+ | Exact Int32 deriving Show --------------------------------------------------------------------------------@@ -139,8 +135,34 @@ expVersionInt32 Any = -2 expVersionInt32 NoStream = -1 expVersionInt32 EmptyStream = 0+expVersionInt32 (Exact i) = i --------------------------------------------------------------------------------+-- | This write should not conflict with anything and should always succeed.+anyStream :: ExpectedVersion+anyStream = Any++--------------------------------------------------------------------------------+-- | The stream being written to should not yet exist. If it does exist+-- treat that as a concurrency problem.+noStream :: ExpectedVersion+noStream = NoStream++--------------------------------------------------------------------------------+-- | The stream should exist and should be empty. If it does not exist or+-- is not empty, treat that as a concurrency problem.+emptyStream :: ExpectedVersion+emptyStream =EmptyStream++--------------------------------------------------------------------------------+-- | States that the last event written to the stream should have a+-- sequence number matching your expected value.+exactStream :: Int32 -> ExpectedVersion+exactStream i+ | i < 0 = error $ "expected version must be >= 0, but is " ++ show i+ | otherwise = Exact i++-------------------------------------------------------------------------------- -- EventStore Messages -------------------------------------------------------------------------------- data OpResult@@ -396,22 +418,22 @@ -- ^ Indicates whether the content is internally marked as json. , recordedEventCreated :: !(Maybe UTCTime) -- ^ Representing when this event was created in the system.- , recordedEventCreatedEpoch :: !(Maybe Integer)- -- ^ Representing the milliseconds since the epoch when the event was- -- created in the system. } deriving Show --------------------------------------------------------------------------------+toUTC :: Int64 -> UTCTime+toUTC = posixSecondsToUTCTime . (/1000) . realToFrac . CTime++-------------------------------------------------------------------------------- newRecordedEvent :: EventRecord -> RecordedEvent newRecordedEvent er = re where evt_id = getField $ eventRecordId er evt_uuid = fromJust $ fromByteString $ fromStrict evt_id data_type = getField $ eventRecordDataType er- created = getField $ eventRecordCreated er epoch = getField $ eventRecordCreatedEpoch er- utc_created = fmap (posixSecondsToUTCTime . fromInteger . toInteger) created+ utc_created = fmap toUTC epoch re = RecordedEvent { recordedEventStreamId = getField $ eventRecordStreamId er@@ -422,7 +444,6 @@ , recordedEventMetadata = getField $ eventRecordMetadata er , recordedEventIsJson = data_type == 1 , recordedEventCreated = utc_created- , recordedEventCreatedEpoch = fmap toInteger epoch } --------------------------------------------------------------------------------
eventstore.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.6.0.1+version: 0.7.0.0 -- A short (one-line) description of the package. synopsis: EventStore TCP Client