RateCounter

Classin erlcompute-sdk-cpp 0.7.0View source

Include fastly/erl.h to use this class.

A rate counter that can be used with an edge rate limiter or stand alone for counting and rate calculations

Constructor

explicit fastly::erl::RateCounter::RateCounter(std::string name)

Parameters

name: std::string

Methods

increment

View source
tl::expected<void, ERLError> fastly::erl::RateCounter::increment(std::string_view entry, std::uint32_t delta)

Increment an entry in the ratecounter by delta.

Parameters

entry: std::string_view
delta: std::uint32_t

Returns

tl::expected<void, ERLError>

lookup_count

View source
tl::expected<std::uint32_t, ERLError> fastly::erl::RateCounter::lookup_count(std::string_view entry, CounterDuration duration) const

Lookup the current count for entry in the rate counter for a duration.

Parameters

entry: std::string_view
duration: CounterDuration

Returns

tl::expected<std::uint32_t, ERLError>

lookup_rate

View source
tl::expected<std::uint32_t, ERLError> fastly::erl::RateCounter::lookup_rate(std::string_view entry, RateWindow window) const

Lookup the current rate for entry in the rate counter for a window.

Parameters

entry: std::string_view
window: RateWindow

Returns

tl::expected<std::uint32_t, ERLError>
std::string_view fastly::erl::RateCounter::name() const

Returns

std::string_view