Toxic proxies are created by the $create
method of the
toxiproxy_client
and returned by the $get
method. They are R6 methods with methods and fields, which are
name
The name of the proxy (a string). This is used in methods $get
and remove
of toxiproxy_client
. This field is read only.
listen
The address that the proxied service is available on. This will be in the form host:port
(e.g., localhost:22222
. The field listen_port
give the port number separately. Assigning to this field will update the listen address of the proxy (equivalent to using $update_proxy
).
listen_port
The port that the proxied service is available on. Assigning to this field will update the listen address of the proxy (equivalent to using $update_proxy
), but will retain the current hostname.
upstream
The address that the upstream service (that is being proxied) is found at. The toxic proxy forwards traffic here. This will in the form host:port
(e.g., localhost:80
. Assigning to this field will update the upstream address of the proxy (equivalent to using $update_proxy
).
enabled
Logical scalar, indicating if the proxy is enabled (i.e., allowing traffic). If a proxy is enabled then all toxics on that proxy are enabled. Assigning to this field enables or disables the proxy (with a value of TRUE
and FALSE
respectively), equivalent to using $update_proxy
.
describe
Query for the current information about this proxy. Returns a named list.
Usage:describe()
add
Add toxics to the proxy. Returns the name of the created toxic.
Use $list())
to see what has been added to the proxy.
Usage:add(type, stream = "downstream", toxicity = 1, attributes = list(),
name = NULL)
Arguments:
type
: Either a toxic
object (e.g., latency
) or the name of one as a scalar character.
stream
: The stream to apply the proxy to. Must be either "downstream"
(the default) or "upstream"
).
toxicity
: Scalar numeric indicating the probability of the proxy being applied to the connection.
attributes
: If type
is a character string, a named list of attributes (see the toxiproxy documentation). If type
is a toxic
object this must be empty.
name
: Name to call the toxic. If omitted, the toxiproxy server will generate a name automatically.
list
List toxics that have been added to the proxy. This will be returned as a data.frame
.
Usage:list()
remove
Remove a toxic from the proxy.
Usage:remove(name)
Arguments:
name
: Name of the toxic to remove - use names($list())
to get a list of names of toxics present for a proxy.
info
Get information about a toxic from the proxy by name. This returns a named list.
Usage:info(name)
Arguments:
name
: A single string with the name of the toxic to be retrieved. It is an error to try and get an nonexistant toxic.
update_toxic
Update attributes of a toxic
Usage:update_toxic(name, attributes)
Arguments:
name
: Name of the toxic to update.
attributes
: A named list of attributes for the toxic. Use $info()
to see what is valid for your toxic, or see the toxiproxy documentation.
update_proxy
Update attributes of the proxy. Values not provided will not be modified from their current values.
Usage:update_proxy(upstream = NULL, listen = NULL, enabled = NULL)
Arguments:
upstream
: Upstream address in the format <host>:<port>
listen
: Listen address in the format <host>:<port>
enabled
: Logical scalar indicating if the proxy should be enabled
with_down
Like $with
, this runs an R expression with the proxy temporarily down (so that no traffic can be transmitted or recieved). The state of the proxy will be restored after the expression has evaluated, even if it throws an error.
Usage:with_down(expr)
Arguments:
expr
: An R expression that will be run with the proxy disabled.