This repository has been archived by the owner on May 10, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 46a6d51
Showing
12 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
README.Rmd | ||
.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Package: etseed | ||
Title: etcd R client | ||
Description: etcd R client | ||
Version: 0.0.1.99 | ||
Date: 2015-02-05 | ||
License: MIT + file LICENSE | ||
URL: https://github.com/sckott/etseed | ||
BugReports: https://github.com/sckott/etseed/issues | ||
Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"), | ||
email = "myrmecocystus@gmail.com")) | ||
License: MIT + file LICENSE | ||
LazyData: true | ||
Imports: | ||
httr, | ||
jsonlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Generated by roxygen2 (4.1.0): do not edit by hand | ||
|
||
export(key) | ||
export(keys) | ||
import(httr) | ||
import(jsonlite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#' Ping urls to time requests | ||
#' | ||
#' @name etseed-package | ||
#' @aliases etseed | ||
#' @docType package | ||
#' @title etcd R client | ||
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} | ||
#' @keywords package | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' List a key or all keys | ||
#' | ||
#' @import httr jsonlite | ||
#' @name keys | ||
#' | ||
#' @param key (character) A key name. Optional. | ||
#' @param ... Further args passed on to \code{\link[httr]{GET}} | ||
#' | ||
#' @examples \dontrun{ | ||
#' # List all keys | ||
#' keys() | ||
#' | ||
#' # A single key | ||
#' key("mykey") | ||
#' } | ||
|
||
#' @export | ||
#' @rdname keys | ||
keys <- function(...) { | ||
etseed_GET(sprintf("%s%s/", etcdbase(), "keys"), ...) | ||
} | ||
|
||
#' @export | ||
#' @rdname keys | ||
key <- function(key, ...) { | ||
etseed_GET(sprintf("%s%s/%s/", etcdbase(), "keys", key), ...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
etseed_GET <- function(url, ...){ | ||
res <- GET(url, ...) | ||
stop_for_status(res) | ||
tt <- content(res, "text") | ||
jsonlite::fromJSON(tt, FALSE) | ||
} | ||
|
||
etcdbase <- function() "http://127.0.0.1:4001/v2/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
etseed | ||
======== | ||
|
||
```{r echo=FALSE} | ||
knitr::opts_chunk$set( | ||
warning = FALSE, | ||
message = FALSE, | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
__etcd R client__ | ||
|
||
## Installation | ||
|
||
Install `etseed` | ||
|
||
```{r eval=FALSE} | ||
install.packages("devtools") | ||
devtools::install_github("sckott/etseed") | ||
``` | ||
|
||
```{r} | ||
library("etseed") | ||
``` | ||
|
||
## Start etcd | ||
|
||
at the command line on OSX | ||
|
||
```sh | ||
brew install etcd | ||
etcd | ||
``` | ||
|
||
done. | ||
|
||
## Get version | ||
|
||
```{r} | ||
version() | ||
``` | ||
|
||
## List keys | ||
|
||
```{r} | ||
keys() | ||
``` | ||
|
||
## List a key | ||
|
||
```{r} | ||
key("mykey") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
etseed | ||
======== | ||
|
||
|
||
|
||
__etcd R client__ | ||
|
||
## Installation | ||
|
||
Install `etseed` | ||
|
||
|
||
```r | ||
install.packages("devtools") | ||
devtools::install_github("sckott/etseed") | ||
``` | ||
|
||
|
||
```r | ||
library("etseed") | ||
``` | ||
|
||
## Start etcd | ||
|
||
at the command line on OSX | ||
|
||
```sh | ||
brew install etcd | ||
etcd | ||
``` | ||
|
||
done. | ||
|
||
## Get version | ||
|
||
|
||
```r | ||
version() | ||
#> Error in eval(expr, envir, enclos): could not find function "version" | ||
``` | ||
|
||
## List keys | ||
|
||
|
||
```r | ||
keys() | ||
#> $action | ||
#> [1] "get" | ||
#> | ||
#> $node | ||
#> $node$key | ||
#> [1] "/" | ||
#> | ||
#> $node$dir | ||
#> [1] TRUE | ||
#> | ||
#> $node$nodes | ||
#> $node$nodes[[1]] | ||
#> $node$nodes[[1]]$key | ||
#> [1] "/mykey" | ||
#> | ||
#> $node$nodes[[1]]$value | ||
#> [1] "this is awesome" | ||
#> | ||
#> $node$nodes[[1]]$modifiedIndex | ||
#> [1] 3 | ||
#> | ||
#> $node$nodes[[1]]$createdIndex | ||
#> [1] 3 | ||
``` | ||
|
||
## List a key | ||
|
||
|
||
```r | ||
key("mykey") | ||
#> $action | ||
#> [1] "get" | ||
#> | ||
#> $node | ||
#> $node$key | ||
#> [1] "/mykey" | ||
#> | ||
#> $node$value | ||
#> [1] "this is awesome" | ||
#> | ||
#> $node$modifiedIndex | ||
#> [1] 3 | ||
#> | ||
#> $node$createdIndex | ||
#> [1] 3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: No | ||
SaveWorkspace: No | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: knitr | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,collate,namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
% Generated by roxygen2 (4.1.0): do not edit by hand | ||
% Please edit documentation in R/etseed-package.R | ||
\docType{package} | ||
\name{etseed-package} | ||
\alias{etseed} | ||
\alias{etseed-package} | ||
\title{etcd R client} | ||
\description{ | ||
Ping urls to time requests | ||
} | ||
\author{ | ||
Scott Chamberlain \email{myrmecocystus@gmail.com} | ||
} | ||
\keyword{package} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
% Generated by roxygen2 (4.1.0): do not edit by hand | ||
% Please edit documentation in R/keys.R | ||
\name{keys} | ||
\alias{key} | ||
\alias{keys} | ||
\title{List a key or all keys} | ||
\usage{ | ||
keys(...) | ||
|
||
key(key, ...) | ||
} | ||
\arguments{ | ||
\item{...}{Further args passed on to \code{\link[httr]{GET}}} | ||
|
||
\item{key}{(character) A key name. Optional.} | ||
} | ||
\description{ | ||
List a key or all keys | ||
} | ||
\examples{ | ||
\dontrun{ | ||
# List all keys | ||
keys() | ||
|
||
# A single key | ||
key("mykey") | ||
} | ||
} | ||
|