Beethoven.Allocator.Agent (Beethoven v0.3.7)

Behaviour to define signals via the signal() macro.

This macro defines a signal that can be sent to the Beethoven.Allocator stack. Once defined, this module will have compile-time created functions to streamline the use of the signal. Each signal has an atomic name, priority weight, and type defined in it. This data is aggregated and used to generate a busy-score for a node.

Types

  • :count Counts the number of a given thing. Generates 2 functions. One to increment the counter, the other to decrement it. Both modify the counter by +/-1.0. The counter will never be lower then 0.

  • :percent Represents a float between 0.0 and >100.0. This generates 1 function. This function allows you to set a float payload in the signal. This value must be a positive float.

Examples

defmodule Signals do
  use Beethoven.Allocator.Agent

  signal(name: :ram, weight: 10.0, type: :percent)
  signal(name: :http_requests, weight: 5.0, type: :count)
end

# Generates
Signals.percent_ram(data) # Data is now the value of the metric in `:ets`
Signals.increment_http_requests_count() # +1.0
Signals.decrement_http_requests_count() # -1.0

See Beethoven.Allocator.Cruncher for information on how the signals are aggregated.

Summary

Types

Defines a single signal. Commonly used as an input for the signal() macro.

Message wrapper for sending payload to Beethoven.Allocator.Ingress.

Header for the signal metadata; when sending a signal to Beethoven.Allocator.Ingress.

Defines types of signal that can be used.

Functions

DO NOT USE THIS DIRECTLY. Please utilize the signal() macro within the Beethoven.Allocator.Agent module.

This macro defines a signal that can be sent to the Beethoven.Allocator stack. Once defined, this module will have compile-time created functions to streamline the use of the signal. Each signal has an atomic name, priority weight, and type defined in it. This data is aggregated and used to generate a busy-score for a node.

Types

signal_definition()

@type signal_definition() :: Beethoven.Allocator.Types.signal_definition()

Defines a single signal. Commonly used as an input for the signal() macro.

signal_message()

@type signal_message() :: Beethoven.Allocator.Types.signal_message()

Message wrapper for sending payload to Beethoven.Allocator.Ingress.

signal_message_header()

@type signal_message_header() :: Beethoven.Allocator.Types.signal_message_header()

Header for the signal metadata; when sending a signal to Beethoven.Allocator.Ingress.

signal_type()

@type signal_type() :: Beethoven.Allocator.Types.signal_type()

Defines types of signal that can be used.

Functions

send_signal(signal)

@spec send_signal(signal_message()) :: :ok

DO NOT USE THIS DIRECTLY. Please utilize the signal() macro within the Beethoven.Allocator.Agent module.

Sends a signal message to Allocator.Ingress.

Payload schema

{header :: {name :: atom(), weight :: integer(), type :: atom()}, payload :: signal_payload()}

signal(list)

(macro)
@spec signal(name: atom(), weight: float(), type: :count | :percent) :: tuple()

This macro defines a signal that can be sent to the Beethoven.Allocator stack. Once defined, this module will have compile-time created functions to streamline the use of the signal. Each signal has an atomic name, priority weight, and type defined in it. This data is aggregated and used to generate a busy-score for a node.

Types

  • :count Counts the number of a given thing. Generates 2 functions. One to increment the counter, the other to decrement it. Both modify the counter by +/-1.0. The counter will never be lower then 0.

  • :percent Represents a float between 0.0 and >100.0. This generates 1 function. This function allows you to set a float payload in the signal. This value must be a positive float.

Examples

defmodule Signals do
  use Beethoven.Allocator.Agent

  signal(name: :ram, weight: 10.0, type: :percent)
  signal(name: :http_requests, weight: 5.0, type: :count)
end

# Generates
Signals.percent_ram(data) # Data is now the value of the metric in `:ets`
Signals.increment_http_requests_count() # +1.0
Signals.decrement_http_requests_count() # -1.0

See Beethoven.Allocator.Cruncher for information on how the signals are aggregated.