-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
129 lines (87 loc) · 3.1 KB
/
README.Rmd
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
error = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rrq
<!-- badges: start -->
[![Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![R-CMD-check](https://github.com/mrc-ide/rrq/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mrc-ide/rrq/actions/workflows/R-CMD-check.yaml)
[![codecov.io](https://codecov.io/github/mrc-ide/rrq/coverage.svg?branch=master)](https://codecov.io/github/mrc-ide/rrq?branch=master)
[![CodeFactor](https://www.codefactor.io/repository/github/mrc-ide/rrq/badge)](https://www.codefactor.io/repository/github/mrc-ide/rrq)
<!-- badges: end -->
Task queues for R, implemented using Redis.
## Getting started
```{r}
library(rrq)
```
Create an `rrq_controller` object
```{r}
obj <- rrq_controller("rrq:readme")
rrq_default_controller_set(obj)
```
Submit work to the queue:
```{r}
t <- rrq_task_create_expr(runif(10))
t
```
Query task process:
```{r}
rrq_task_status(t)
```
Run tasks on workers in the background
```{r}
rrq_worker_spawn()
```
Wait for tasks to complete
```{r}
rrq_task_wait(t)
```
Retrieve results from a task
```{r}
rrq_task_result(t)
```
Query what workers have done
```{r}
rrq_worker_log_tail(n = Inf)
```
For more information, see `vignette("rrq")`
```{r, include = FALSE}
rrq_destroy(timeout_worker_stop = 10)
```
## Installation
Install from the mrc-ide R universe package repository:
```r
install.packages(
"rrq",
repos = c("https://mrc-ide.r-universe.dev", "https://cloud.r-project.org"))
```
Alternatively, install with `remotes`:
```r
remotes::install_github("mrc-ide/rrq", upgrade = FALSE)
```
## Testing
To test, we need a redis server that can be automatically connected to using the `redux` defaults. This is satisfied if you have an unauthenticated redis server running on localhost, otherwise you should update the environment variable `REDIS_URL` to point at a redis server. Do not use a production server, as the package will create and delete a lot of keys.
A suitable redis server can be started using docker with
```
./scripts/redis start
```
(and stopped with `./scripts/redis stop`)
Alternatively, on Windows, a native (i.e., not depending on CygWin, MSys, or WSL) port of Redis 5.0.14.1 can be installed from [here](https://github.com/tporadowski/redis/releases), and will run out of the box.
## Testing the pkgdown site with examples
The documentation includes many executed code examples. To preview the documentation with the results of these, you'll need a Redis server running, and the rrq package installed. Then, in an R terminal:-
```
rrq::rrq_worker$new("rrq:example")$loop()
```
to run a worker. Then in another R terminal,
```
pkgdown::build_site()
```
and the pkgdown site will be built in the `docs/` folder.
## License
MIT © Imperial College of Science, Technology and Medicine