Portability | portable |
---|---|
Stability | experimental |
Maintainer | Bryan O'Sullivan <bos@mailrank.com> |
A client for the Riak decentralized data store.
The functions in this module use JSON as the storage representation, and automatically perform conflict resolution during storage and retrieval.
This library is organized to allow a tradeoff between power and ease of use. If you would like a different degree of automation with storage and conflict resolution, you may want to use one of the following modules (ranked from easiest to most tricky to use):
- Network.Riak.JSON.Resolvable
- JSON for storage, automatic conflict resolution. (This module actually re-exports its definitions.) This is the easiest module to work with.
- Network.Riak.JSON
- JSON for storage, manual conflict resolution.
- Network.Riak.Value.Resolvable
- More complex (but still automatic) storage, automatic conflict resolution.
- Network.Riak.Value
- More complex (but still automatic) storage, manual conflict resolution.
- Network.Riak.Basic
- manual storage, manual conflict resolution. This is the most demanding module to work with, as you must encode and decode data yourself, and handle all conflict resolution yourself.
- type ClientID = ByteString
- data Client = Client {}
- defaultClient :: Client
- getClientID :: Connection -> IO ClientID
- data Connection = Connection {}
- connect :: Client -> IO Connection
- disconnect :: Connection -> IO ()
- ping :: Connection -> IO ()
- getServerInfo :: Connection -> IO ServerInfo
- data Quorum
- get :: (FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> Key -> R -> IO (Maybe (c, VClock))
- getMany :: (FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> [Key] -> R -> IO [Maybe (c, VClock)]
- put :: (Eq c, FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> Key -> Maybe VClock -> c -> W -> DW -> IO (c, VClock)
- putMany :: (Eq c, FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> [(Key, Maybe VClock, c)] -> W -> DW -> IO [(c, VClock)]
- delete :: Connection -> Bucket -> Key -> RW -> IO ()
- listBuckets :: Connection -> IO (Seq Bucket)
- foldKeys :: Connection -> Bucket -> (a -> Key -> IO a) -> a -> IO a
- getBucket :: Connection -> Bucket -> IO BucketProps
- setBucket :: Connection -> Bucket -> BucketProps -> IO ()
- mapReduce :: Connection -> Job -> IO MapReduce
Client configuration and identification
type ClientID = ByteStringSource
A client identifier. This is used by the Riak cluster when logging vector clock changes, and should be unique for each client.
Default client configuration. Talks to localhost, port 8087, with a randomly chosen client ID.
getClientID :: Connection -> IO ClientIDSource
Find out from the server what client ID this connection is using.
Connection management
data Connection Source
A connection to a Riak server.
Connection | |
|
connect :: Client -> IO ConnectionSource
Connect to a server.
disconnect :: Connection -> IO ()Source
Disconnect from a server.
ping :: Connection -> IO ()Source
Check to see if the connection to the server is alive.
getServerInfo :: Connection -> IO ServerInfoSource
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
).
get :: (FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> Key -> R -> IO (Maybe (c, VClock))Source
Retrieve a single value. If conflicting values are returned, the
Resolvable
is used to choose a winner.
getMany :: (FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> [Key] -> R -> IO [Maybe (c, VClock)]Source
Retrieve multiple values. If conflicting values are returned for
a key, the Resolvable
is used to choose a winner.
put :: (Eq c, FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> Key -> Maybe VClock -> c -> W -> DW -> IO (c, VClock)Source
Store a single value, automatically resolving any vector clock conflicts that arise. A single invocation of this function may involve several roundtrips to the server to resolve conflicts.
If a conflict arises, a winner will be chosen using mconcat
, and
the winner will be stored; this will be repeated until no conflict
occurs.
The final value to be stored at the end of any conflict resolution is returned.
putMany :: (Eq c, FromJSON c, ToJSON c, Resolvable c) => Connection -> Bucket -> [(Key, Maybe VClock, c)] -> W -> DW -> IO [(c, VClock)]Source
Store multiple values, resolving any vector clock conflicts that arise. A single invocation of this function may involve several roundtrips to the server to resolve conflicts.
If any conflicts arise, a winner will be chosen in each case using
mconcat
, and the winners will be stored; this will be repeated
until no conflicts occur.
For each original value to be stored, the final value that was stored at the end of any conflict resolution is returned.
Metadata
listBuckets :: Connection -> IO (Seq Bucket)Source
getBucket :: Connection -> Bucket -> IO BucketPropsSource
Retrieve the properties of a bucket.
setBucket :: Connection -> Bucket -> BucketProps -> IO ()Source
Store new properties for a bucket.