A FireSale plugin
A FireSale plugin
Details
The class encapsulates the firesale functionality into a fiery plugin. You use it by creating and attaching it to a fiery server object.
Initialization
A new 'FireSale'-object is initialized using the new() method on the
generator (shown here with the environment driver):
Usage
datastore <- FireSale$new(storr::driver_environment()) |
Fiery plugin
This class is mainly intended to be used as a fiery plugin, by attaching it
to a fiery server object. It works by providing a datastore element (name
can be modified with the arg_name argument during initialization) in the
arg_list argument to request handlers. The object contains two elements,
global and session. The first contains data shared by all sessions, while
the latter is scoped to the current session. Both of these elements are
list-like, but in reality are interfaces to the underlying data store
Methods
Method new()
Initializes a new FireSale object
Usage
FireSale$new(
driver,
arg_name = "datastore",
gc_interval = 3600,
max_age = gc_interval
)Arguments
driverA storr driver to use for the backend
arg_nameA string giving the name under which the data store should appear in the
arg_listargumentgc_intervalThe interval with which the backend should be garbage collected. The value is indicative and a garbage collection may happen at longer intervals
max_ageThe maximum age in second an ID can be left unused before being purged. The value is indicative and a stale ID store may linger longer than this
Method format()
Textual representation of the plugin
Method get_mall()
Create a mall (a collection of storefronts) containing a global and a session-specific storefront
Method shiny_mall()
Create a mall from a shiny session object. If the shiny app has been launched from a plumber2 server the session id is automatically resolved. If not, you must provide an id function that extracts the session id from a reqres::Request object.
Arguments
sessionA ShinySession object
id_funA function that can extract the session ID from a
Requestobject. This is handled automatically for shiny apps launched from a plumber2 server. The default id function for fiery servers is constructed withfiery::session_id_cookie()
Method on_attach()
Method for use by fiery when attached as a plugin. Should
not be called directly.
Examples
# Create a datastore object
ds <- FireSale$new(storr::driver_environment())
# Attach it to a fiery server
app <- fiery::Fire$new()
app$attach(ds)