riak: reeack connection client

Description Arguments Details Value Examples

View source: R/client.R

Description

reeack connection client

Arguments

host

(character) A base URL (without the transport), e.g., localhost, 127.0.0.1, or foobar.cloudant.com

port

(numeric) Port. Remember that if you don't want a port set, set this parameter to NULL. Default: 5984

path

(character) context path that is appended to the end of the url. e.g., bar in http://foo.com/bar. Default: NULL, ignored

transport

(character) http or https. Default: http

user

(character) A user name

pwd

(character) A password

headers

headers, a named list

Details

Methods

ping()

Ping the Riak server

stats()

Get Riak server stats

keys()

Get keys

buckets()

Get buckets

bucket_set()

Set bucket properties

bucket_get()

Get bucket properties

create()

Create an object

fetch()

Fetch an object

delete()

Delete an object

Value

An object of class riak_client, with variables accessible for host, port, path, transport, user, pwd, and headers. Functions are callable to get headers, and to make the base url sent with all requests.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## Not run: 
# Create a Riak client
(x <- riak())

## metadata
x$host
x$path
x$port

## ping the Riak server
x$ping()

## stats
x$stats()

## keys
### list keys
x$keys()
### in a specific bucket
x$keys("test")

## buckets
### list buckets
x$buckets()

## bucket properties
### set
x$bucket_set("test", n_val = 3, verbose=TRUE)

### get
props <- x$bucket_get("test")
props$props$n_val

## create ~ store
### plain text
x$create(body = "foo bar", content_type = "text/plain")
### json
x$create(body = '{"foo": "bar"}', content_type = "application/json")
### a data.frame
x$create(body = riak_serialize(iris), content_type = "text/plain")

#### with a key
x$create(key = "doc", body = "foo bar", content_type = "text/plain")

## fetch from store
### plain text
res <- x$create(body = "foo bar", content_type = "text/plain")
x$fetch(key = res$key)
### json
res <- x$create(body = '{"foo": "bar"}', content_type = "application/json")
jsonlite::fromJSON(x$fetch(key = res$key))
### a data.frame
res <- x$create(body = riak_serialize(iris), content_type = "text/plain")
head(
  riak_unserialize(x$fetch(key = res$key))
)

## delete from store
(res <- x$keys("test")$keys)
x$delete(key = res[1])
res[1] %in% x$keys("test")$keys

## End(Not run)

ropensci/reeack documentation built on Dec. 11, 2019, 3:13 p.m.