Beetle.inspect_bucket

You're seeing just the function inspect_bucket, go back to Beetle module for more information.
Link to this function

inspect_bucket(id, scale_ms, limit)

View Source

Specs

inspect_bucket(id :: String.t(), scale_ms :: integer(), limit :: integer()) ::
  {:ok,
   {count :: integer(), count_remaining :: integer(),
    ms_to_next_bucket :: integer(), created_at :: integer() | nil,
    updated_at :: integer() | nil}}
  | {:error, reason :: any()}

Inspect bucket to get count, count_remaining, ms_to_next_bucket, created_at, updated_at. This function is free of side-effects and should be called with the same arguments you would use for check_rate if you intended to increment and check the bucket counter.

Arguments:

  • id: String name of the bucket. Usually the bucket name is comprised of some fixed prefix,with some dynamic string appended, such as an IP address or user id.
  • scale_ms: Integer indicating size of bucket in milliseconds
  • limit: Integer maximum count of actions within the bucket

Returns either {:ok, {count, count_remaining, ms_to_next_bucket, created_at, updated_at}, or {:error, reason}.

Example:

inspect_bucket("file_upload:2042", 60_000, 5)
{:ok, {1, 2499, 29381612, 1450281014468, 1450281014468}}
Link to this function

inspect_bucket(backend, id, scale_ms, limit)

View Source

Specs

inspect_bucket(
  backend :: atom(),
  id :: String.t(),
  scale_ms :: integer(),
  limit :: integer()
) ::
  {:ok,
   {count :: integer(), count_remaining :: integer(),
    ms_to_next_bucket :: integer(), created_at :: integer() | nil,
    updated_at :: integer() | nil}}
  | {:error, reason :: any()}

Same as inspect_bucket/3, but allows specifying a backend