Copyright | (c) 2011 MailRank Inc. |
---|---|
License | Apache |
Maintainer | Mark Hibberd <mark@hibberd.id.au>, Nathan Hunter <nhunter@janrain.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Basic support for the Riak decentralized data store.
When storing and retrieving data, the functions in this module do not perform any encoding or decoding of data, nor do they resolve conflicts.
Synopsis
- type ClientID = ByteString
- data Client = Client {}
- defaultClient :: Client
- data Connection = Connection {}
- connect :: Client -> IO Connection
- disconnect :: Connection -> IO ()
- ping :: Connection -> IO ()
- getClientID :: Connection -> IO ClientID
- setClientID :: Connection -> ClientID -> IO ()
- getServerInfo :: Connection -> IO RpbGetServerInfoResp
- data Quorum
- get :: Connection -> Maybe BucketType -> Bucket -> Key -> R -> IO (Maybe ([RpbContent], VClock))
- put :: Connection -> Maybe BucketType -> Bucket -> Key -> Maybe VClock -> RpbContent -> W -> DW -> IO ([RpbContent], VClock)
- put_ :: Connection -> Maybe BucketType -> Bucket -> Key -> Maybe VClock -> RpbContent -> W -> DW -> IO ()
- delete :: Connection -> Maybe BucketType -> Bucket -> Key -> RW -> IO ()
- listBuckets :: Connection -> Maybe BucketType -> IO [Bucket]
- foldKeys :: MonadIO m => Connection -> Maybe BucketType -> Bucket -> (a -> Key -> m a) -> a -> m a
- getBucket :: Connection -> Maybe BucketType -> Bucket -> IO RpbBucketProps
- setBucket :: Connection -> Maybe BucketType -> Bucket -> RpbBucketProps -> IO ()
- getBucketType :: Connection -> BucketType -> IO RpbBucketProps
- mapReduce :: Connection -> Job -> (a -> RpbMapRedResp -> a) -> a -> IO a
Client configuration and identification
type ClientID = ByteString Source #
A client identifier. This is used by the Riak cluster when logging vector clock changes, and should be unique for each client.
defaultClient :: Client Source #
Default client configuration. Talks to localhost, port 8087, with a randomly chosen client ID.
Connection management
data Connection Source #
A connection to a Riak server.
Connection | |
|
Instances
Eq Connection Source # | |
Defined in Network.Riak.Types.Internal (==) :: Connection -> Connection -> Bool # (/=) :: Connection -> Connection -> Bool # | |
Show Connection Source # | |
Defined in Network.Riak.Types.Internal showsPrec :: Int -> Connection -> ShowS # show :: Connection -> String # showList :: [Connection] -> ShowS # |
disconnect :: Connection -> IO () Source #
Disconnect from a server.
ping :: Connection -> IO () Source #
Check to see if the connection to the server is alive.
getClientID :: Connection -> IO ClientID Source #
Find out from the server what client ID this connection is using.
setClientID :: Connection -> ClientID -> IO () Source #
Tell the server our client ID.
getServerInfo :: Connection -> IO RpbGetServerInfoResp Source #
Retrieve information about the server.
Data management
A read/write quorum. The quantity of replicas that must respond
to a read or write request before it is considered successful. This
is defined as a bucket property or as one of the relevant
parameters to a single request (R
,W
,DW
,RW
).
Default | Use the default quorum settings for the bucket. |
One | Success after one server has responded. |
Quorum | Success after a quorum of servers has responded. |
All | Success after all servers have responded. |
get :: Connection -> Maybe BucketType -> Bucket -> Key -> R -> IO (Maybe ([RpbContent], VClock)) Source #
Retrieve a value. This may return multiple conflicting siblings. Choosing among them is your responsibility.
put :: Connection -> Maybe BucketType -> Bucket -> Key -> Maybe VClock -> RpbContent -> W -> DW -> IO ([RpbContent], VClock) Source #
Store a single value. This may return multiple conflicting siblings. Choosing among them, and storing a new value, is your responsibility.
You should only supply Nothing
as a VClock
if you are sure
that the given type+bucket+key combination does not already exist.
If you omit a VClock
but the type+bucket+key does exist, your
value will not be stored.
put_ :: Connection -> Maybe BucketType -> Bucket -> Key -> Maybe VClock -> RpbContent -> W -> DW -> IO () Source #
Store a single value, without the possibility of conflict resolution.
You should only supply Nothing
as a VClock
if you are sure
that the given type+bucket+key combination does not already exist.
If you omit a VClock
but the type+bucket+key does exist, your
value will not be stored, and you will not be notified.
delete :: Connection -> Maybe BucketType -> Bucket -> Key -> RW -> IO () Source #
Delete a value.
Metadata
listBuckets :: Connection -> Maybe BucketType -> IO [Bucket] Source #
List the buckets in the cluster.
Note: this operation is expensive. Do not use it in production.
foldKeys :: MonadIO m => Connection -> Maybe BucketType -> Bucket -> (a -> Key -> m a) -> a -> m a Source #
Fold over the keys in a bucket.
Note: this operation is expensive. Do not use it in production.
getBucket :: Connection -> Maybe BucketType -> Bucket -> IO RpbBucketProps Source #
Retrieve the properties of a bucket.
setBucket :: Connection -> Maybe BucketType -> Bucket -> RpbBucketProps -> IO () Source #
Store new properties for a bucket.
getBucketType :: Connection -> BucketType -> IO RpbBucketProps Source #
Gets the bucket properties associated with a bucket type.
Map/reduce
mapReduce :: Connection -> Job -> (a -> RpbMapRedResp -> a) -> a -> IO a Source #
Run a MapReduce
job. Its result is consumed via a strict left
fold.