module Network.Riak.CRDT.Request (
get
, counterUpdate
, setUpdate
, mapUpdate
) where
import Data.ByteString (ByteString)
import qualified Data.Riak.Proto as Proto
import Network.Riak.CRDT.Ops
import qualified Network.Riak.CRDT.Types as CRDT
import Network.Riak.Lens
import Network.Riak.Types
counterUpdate :: [CRDT.CounterOp]
-> BucketType -> Bucket -> Key
-> Proto.DtUpdateReq
counterUpdate :: [CounterOp]
-> BucketType -> BucketType -> BucketType -> DtUpdateReq
counterUpdate [CounterOp]
ops = DtOp -> BucketType -> BucketType -> BucketType -> DtUpdateReq
update ([CounterOp] -> DtOp
counterUpdateOp [CounterOp]
ops)
setUpdate :: [CRDT.SetOp]
-> BucketType -> Bucket -> Key
-> Proto.DtUpdateReq
setUpdate :: [SetOp] -> BucketType -> BucketType -> BucketType -> DtUpdateReq
setUpdate [SetOp]
ops = DtOp -> BucketType -> BucketType -> BucketType -> DtUpdateReq
update ([SetOp] -> DtOp
setUpdateOp [SetOp]
ops)
mapUpdate :: [CRDT.MapOp]
-> BucketType -> Bucket -> Key
-> Proto.DtUpdateReq
mapUpdate :: [MapOp] -> BucketType -> BucketType -> BucketType -> DtUpdateReq
mapUpdate [MapOp]
ops = DtOp -> BucketType -> BucketType -> BucketType -> DtUpdateReq
update ([MapOp] -> DtOp
mapUpdateOp [MapOp]
ops)
update :: Proto.DtOp -> BucketType -> Bucket -> Key -> Proto.DtUpdateReq
update :: DtOp -> BucketType -> BucketType -> BucketType -> DtUpdateReq
update DtOp
op BucketType
t BucketType
b BucketType
k = DtUpdateReq
forall msg. Message msg => msg
Proto.defMessage
DtUpdateReq -> (DtUpdateReq -> DtUpdateReq) -> DtUpdateReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtUpdateReq BucketType
forall (f :: * -> *) s a.
(Functor f, HasField s "bucket" a) =>
LensLike' f s a
Proto.bucket LensLike' Identity DtUpdateReq BucketType
-> BucketType -> DtUpdateReq -> DtUpdateReq
forall s a. Setter s a -> a -> s -> s
.~ BucketType
b
DtUpdateReq -> (DtUpdateReq -> DtUpdateReq) -> DtUpdateReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtUpdateReq BucketType
forall (f :: * -> *) s a.
(Functor f, HasField s "key" a) =>
LensLike' f s a
Proto.key LensLike' Identity DtUpdateReq BucketType
-> BucketType -> DtUpdateReq -> DtUpdateReq
forall s a. Setter s a -> a -> s -> s
.~ BucketType
k
DtUpdateReq -> (DtUpdateReq -> DtUpdateReq) -> DtUpdateReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtUpdateReq DtOp
forall (f :: * -> *) s a.
(Functor f, HasField s "op" a) =>
LensLike' f s a
Proto.op LensLike' Identity DtUpdateReq DtOp
-> DtOp -> DtUpdateReq -> DtUpdateReq
forall s a. Setter s a -> a -> s -> s
.~ DtOp
op
DtUpdateReq -> (DtUpdateReq -> DtUpdateReq) -> DtUpdateReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtUpdateReq BucketType
forall (f :: * -> *) s a.
(Functor f, HasField s "type'" a) =>
LensLike' f s a
Proto.type' LensLike' Identity DtUpdateReq BucketType
-> BucketType -> DtUpdateReq -> DtUpdateReq
forall s a. Setter s a -> a -> s -> s
.~ BucketType
t
get :: ByteString -> ByteString -> ByteString -> Proto.DtFetchReq
get :: BucketType -> BucketType -> BucketType -> DtFetchReq
get BucketType
t BucketType
b BucketType
k = DtFetchReq
forall msg. Message msg => msg
Proto.defMessage
DtFetchReq -> (DtFetchReq -> DtFetchReq) -> DtFetchReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtFetchReq BucketType
forall (f :: * -> *) s a.
(Functor f, HasField s "bucket" a) =>
LensLike' f s a
Proto.bucket LensLike' Identity DtFetchReq BucketType
-> BucketType -> DtFetchReq -> DtFetchReq
forall s a. Setter s a -> a -> s -> s
.~ BucketType
b
DtFetchReq -> (DtFetchReq -> DtFetchReq) -> DtFetchReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtFetchReq BucketType
forall (f :: * -> *) s a.
(Functor f, HasField s "key" a) =>
LensLike' f s a
Proto.key LensLike' Identity DtFetchReq BucketType
-> BucketType -> DtFetchReq -> DtFetchReq
forall s a. Setter s a -> a -> s -> s
.~ BucketType
k
DtFetchReq -> (DtFetchReq -> DtFetchReq) -> DtFetchReq
forall a b. a -> (a -> b) -> b
& LensLike' Identity DtFetchReq BucketType
forall (f :: * -> *) s a.
(Functor f, HasField s "type'" a) =>
LensLike' f s a
Proto.type' LensLike' Identity DtFetchReq BucketType
-> BucketType -> DtFetchReq -> DtFetchReq
forall s a. Setter s a -> a -> s -> s
.~ BucketType
t