Module sprotector

This modules provides utility functions for overload protection and/or short circuiting calls to a process.

See also: sprotector_pie_meter, sprotector_server.

Description

This modules provides utility functions for overload protection and/or short circuiting calls to a process. It is designed for use with sbroker and sregulator processes using the sprotector_pie_meter meter. However any OTP process can use this module to do load balancing using the via naming format if the process is registered with and updates the sprotector_server.

To use sprotector with via use names of the form {via, sprotector, {Broker, ask | ask_r}}. Where {Broker, ...} is a tuple containing pid() | atom() | {global, any()} | {via, module(), any()} | {atom(), node()}. The lookup will succeed if the approximate queue length is less than or equal to the minimum queue length or below the the maximum and the drop probability allows. Otherwise the call exits with reason drop.

Therefore when combining with sbetter use format: {via, sprotector, {{via, sbetter, {..., ask | ask_r}, ask | ask_r}}. So the load balancing lookup is resolved first and wrapped by sprotector.

It is not possible to locally look up the pid of a process with name {atom(), node()} if the node is not the local node. Therefore a registered name on another node is not supported for use with this module.

If a chosen process is not local the call may exit with {badnode, node()}.

If a chosen process is not registered with the sprotector_server the call may exit with {noprotector, pid()}. The sdropper_pie_meter will register with the server and update it using the PIE active queue management algorithm. However other methods can be used to register and update the sprotector_server. Registering with the sdropper_server must be done with sprotector_server:register/1 and not using start_link({via, sprotector, ...}, ...).

Data Types

process()

process() = pid() | atom() | {atom(), node()} | {global, term()} | {via, module(), term()}

Function Index

send/2Sends a message to a pid if not dropped by the min, max and drop probability of the chosen queue.
whereis_name/1Lookup a pid and possibly drop the request depending on the min, max and drop probability of the chosen queue.

Function Details

send/2

send(Process::{Process, ask | ask_r}, Msg) -> ok

Sends a message to a pid if not dropped by the min, max and drop probability of the chosen queue. Returns ok if the message is sent otherwise exits.

whereis_name/1

whereis_name(X1::{Process, ask | ask_r}) -> Pid | undefined

Lookup a pid and possibly drop the request depending on the min, max and drop probability of the chosen queue. If no process is associated with the process returns undefined.


Generated by EDoc, Sep 29 2016, 17:17:28.