Description Usage Arguments publish queue name Examples
Create redis progress bar
1 2 3 4 5 6 7 8 9 |
name |
character string used to create the queue name (with predefined prefix). |
redis |
redis_client object used to hold connection parameters |
publish |
how to publish the generated key name, name of key or value returned by |
debug |
print debug information |
unique.name |
ensure queue has unique name, add a random generated string (useful with publish) |
append |
queue name (fully qualified) already exists, it will be reused |
verbose |
show information message |
Publish argument allows to set the current queue name into another redis entry. Use publish_queue()
to configure it.
The queue name will be used to create an Hash set structure in Redis. To avoid collision between progress bars, 2 mechanisms are used :
passing unique.name=TRUE will add a unique suffix to the queue name, ensuring uniqueness of the queue name.
Previous progress bar with the same name will be deleted unless append
parameter is TRUE
Provided name is prefixed using redis_queue_name function, ensuring a dedicated keyspace for progress bar. the prefix string can be configured in R options. It is defined once in the session of the creator of the progress bar instance. So it has only to be defined in the R instance creating the jobs. If R instances are created independently and the progress object is not propagated you have to be sure the same prefix is used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # create a redis client (using mock to make this example runnable without a redis server)
client = redis_client("mock")
# Create the progress bar
progress = create_redis_progress("queue01", redis=client)
progress$start('first-task', steps=5) # Start my first task, declaring 10 steps to finish
# Do something
progress$incr() # first step complete
# Do something else
progress$incr()
# Log Message can also be sent
progress$message("My task is running well")
progress$incr(3) # Increase the progress counter by a value
# Create a progress with a random name and publish under in "myjobs" key
publish_to = publish_queue("myjobs", type="key")
progress = create_redis_progress("queue01", redis=client, publish=publish_to, unique.name=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.