Learn R Programming

plumber2 (version 0.2.0)

async_evaluators: Async evaluators provided by plumber

Description

These functions support async request handling. You can register your own as well using register_async().

Usage

mirai_async(...)

Value

A function taking expr and envir. The former is the expression to evaluate and the latter is an environment with additional variables that should be made available during evaluation

Arguments

...

Further argument passed on to the internal async function. See Details for information on which function handles the formatting internally in each async evaluator

Provided evaluators

  • mirai_async() uses mirai::mirai(). It is registered as "mirai". Be aware that for this evaluator to be performant you should start up multiple persistent background processes. See mirai::daemons().

Examples

Run this code
# Use the default mirai backend by setting `async = TRUE` with a handler

pa <- api() |>
  api_get("/hello/", function(name) {
    list(
      msg = paste0("Hello ", name, "!")
    )
  }, async = TRUE)


Run the code above in your browser using DataLab