module Network.Nakadi.EventTypes.ShiftedCursors
( cursorsShift'
, cursorsShift
) where
import Network.Nakadi.Internal.Prelude
import Network.Nakadi.Internal.Http
path :: EventTypeName -> ByteString
path eventTypeName =
"/event-types/"
<> encodeUtf8 (unEventTypeName eventTypeName)
<> "/shifted-cursors"
cursorsShift' ::
MonadNakadi b m
=> EventTypeName
-> [ShiftedCursor]
-> m [Cursor]
cursorsShift' eventTypeName cursors = do
config <- nakadiAsk
httpJsonBody ok200 [] $
(setRequestMethod "POST"
. includeFlowId config
. setRequestPath (path eventTypeName)
. setRequestBodyJSON cursors)
cursorsShift ::
MonadNakadi b m
=> EventTypeName
-> [Cursor]
-> Int64
-> m [Cursor]
cursorsShift eventTypeName cursors n = do
cursorsShift' eventTypeName (map makeShiftCursor cursors)
where makeShiftCursor Cursor { .. } =
ShiftedCursor { _partition = _partition
, _offset = _offset
, _shift = n }