Bedrock.JobQueue.Expirable (bedrock_job_queue v0.2.0)

View Source

Shared expiration helpers for lease-like structs.

Any struct with an expires_at field can use these functions.

Summary

Functions

Returns true if the struct has expired.

Returns the remaining time in milliseconds. Returns 0 if expired.

Functions

expired?(struct, opts \\ [])

@spec expired?(
  %{expires_at: non_neg_integer()},
  keyword()
) :: boolean()

Returns true if the struct has expired.

Options

  • :now - Current time in milliseconds (default: System.system_time(:millisecond))

remaining_ms(struct, opts \\ [])

@spec remaining_ms(
  %{expires_at: non_neg_integer()},
  keyword()
) :: non_neg_integer()

Returns the remaining time in milliseconds. Returns 0 if expired.

Options

  • :now - Current time in milliseconds (default: System.system_time(:millisecond))