module Network.Nakadi.EventTypes.ShiftedCursors
( cursorsShift'
, cursorsShiftR'
, cursorsShift
, cursorsShiftR
) where
import Network.Nakadi.Internal.Prelude
import Control.Lens
import Network.Nakadi.Internal.Http
import qualified Network.Nakadi.Internal.Lenses as L
path :: EventTypeName -> ByteString
path eventTypeName =
"/event-types/"
<> encodeUtf8 (unEventTypeName eventTypeName)
<> "/shifted-cursors"
cursorsShift' ::
MonadNakadi m
=> Config
-> EventTypeName
-> [ShiftedCursor]
-> m [Cursor]
cursorsShift' config eventTypeName cursors =
httpJsonBody config ok200 []
(setRequestMethod "POST"
. setRequestPath (path eventTypeName)
. setRequestBodyJSON cursors)
cursorsShiftR' ::
MonadNakadiEnv r m
=> EventTypeName
-> [ShiftedCursor]
-> m [Cursor]
cursorsShiftR' eventTypeName cursors = do
config <- asks (view L.nakadiConfig)
cursorsShift' config eventTypeName cursors
cursorsShift ::
MonadNakadi m
=> Config
-> EventTypeName
-> [Cursor]
-> Int64
-> m [Cursor]
cursorsShift config eventTypeName cursors n =
cursorsShift' config eventTypeName (map makeShiftCursor cursors)
where makeShiftCursor Cursor { .. } =
ShiftedCursor { _partition = _partition
, _offset = _offset
, _shift = n }
cursorsShiftR ::
MonadNakadiEnv r m
=> EventTypeName
-> [Cursor]
-> Int64
-> m [Cursor]
cursorsShiftR eventTypeName cursors n = do
config <- asks (view L.nakadiConfig)
cursorsShift config eventTypeName cursors n