Struct riak::Client
[−]
[src]
pub struct Client { /* fields omitted */ }
Client
Represents a connection to a Riak server's Protocol Buffers API.
For more information: https://docs.basho.com/riak/kv/latest/developing/api/protocol-buffers/
Methods
impl Client
[src]
fn new<A: ToSocketAddrs>(addr: A) -> Result<Client, RiakError>
Constructs a new Client
.
Examples
use riak::Client; let mut riak = Client::new("10.0.0.2:8087").unwrap(); riak.ping().unwrap();
Errors
TODO
fn reconnect(&mut self) -> Result<(), RiakError>
Reconnect to the Riak server originally connected to when this client was initiated.
Examples
use riak::Client; let mut riak = Client::new("10.0.0.2:8087").unwrap(); riak.reconnect().unwrap();
Errors
TODO
fn ping(&mut self) -> Result<(), RiakError>
Sends a ping message to Riak and returns a Result.
Examples
use riak::Client; let mut riak = Client::new("10.0.0.2:8087").unwrap(); riak.ping().unwrap();
Errors
TODO
fn list_buckets(&mut self) -> Result<Vec<String>, RiakError>
Produces a list of bucket names.
Note: This operation is expensive for the Riak server and should be used as rarely as possible.
Examples
use riak::Client; let mut riak = Client::new("10.0.0.2:8087").unwrap(); let buckets = riak.list_buckets().unwrap(); for bucket in buckets.iter() { println!("found bucket named {}", bucket); }
Errors
TODO
fn set_bucket_properties(&mut self,
bucket_name: &str,
bucket_props: &BucketProps)
-> Result<(), RiakError>
bucket_name: &str,
bucket_props: &BucketProps)
-> Result<(), RiakError>
Sets the properties for a bucket given a bucket name.
Examples
use riak::Client; use riak::bucket::BucketProps; let mut riak = Client::new("10.0.0.2:8087").unwrap(); let mut bucket_props = BucketProps::new(); bucket_props.set_backend("bitcask"); riak.set_bucket_properties("superheroes", &bucket_props).unwrap();
Errors
TODO
fn get_bucket_properties(&mut self,
bucket_name: &str)
-> Result<BucketProps, RiakError>
bucket_name: &str)
-> Result<BucketProps, RiakError>
Retrieves bucket properties for a bucket given a bucket name.
Examples
use riak::Client; let mut riak = Client::new("10.0.0.2:8087").unwrap(); let bucket_props = riak.get_bucket_properties("superheroes").unwrap(); println!("bucket properties for superheroes: {:?}", bucket_props);
Errors
TODO
fn store_object(&mut self, req: &StoreObjectReq) -> Result<(), RiakError>
Stores an object on the Riak server.
Examples
use riak::Client; use riak::object::{ObjectContent, StoreObjectReq}; let mut riak = Client::new("10.0.0.2:8087").unwrap(); let contents = ObjectContent::new("I am the night, I am Batman!".as_bytes()); let mut req = StoreObjectReq::new("superheroes", &contents); req.set_key("batman"); riak.store_object(&req).unwrap();
Errors
TODO
fn fetch_object(&mut self,
req: &FetchObjectReq)
-> Result<FetchObjectResp, RiakError>
req: &FetchObjectReq)
-> Result<FetchObjectResp, RiakError>
Fetches an object from the Riak server.
Examples
use riak::Client; use riak::object::FetchObjectReq; let mut riak = Client::new("10.0.0.2:8087").unwrap(); let req = FetchObjectReq::new("superheroes", "batman"); let object = riak.fetch_object(&req).unwrap(); println!("batman object contained: {:?}", object);
Errors
TODO