Deadline v0.7.1 Deadline View Source
Deadline is a small library for managing deadlines and for performing deadline propagation across systems. It uses process dictionary both for performance and to make the library more ergonomic.
# Set a deadline in milliseconds
Deadline.set(1_000)
# Perform some work that takes longer than a second
Deadline.work(fn ->
Service.call()
end)
# Won't be called because we've exceeded our deadline
Deadline.work(fn ->
Service.call()
end)
if Deadline.reached?() do
:cancel
else
do_some_work()
end
Link to this section Summary
Functions
Forces the calling process to exit if the deadline is reached. This will start a new process and that process will live as long as the calling process lives or until the deadline is reached. The extra processes should not present a problem in most cases, but it could present memory pressure in low memory environments.
Returns the deadline context.
Checks if a deadline has been reached or exceeded.
Sets the deadline context. If a integer is passed it is assumed to be the desired deadline in milliseconds. This function also accepts a full deadline context. This is most commonly used when a deadline has already been set and the context needs to be propagated to another BEAM process.
Returns the remaining time before the dealine is reached, in a given unit. Defaults to :millisecond
units.
If the deadline has been exceeded than the time remaining will be 0.
Link to this section Functions
Forces the calling process to exit if the deadline is reached. This will start a new process and that process will live as long as the calling process lives or until the deadline is reached. The extra processes should not present a problem in most cases, but it could present memory pressure in low memory environments.
Accepts a callback that will be executed prior to exiting the calling process.
Returns the deadline context.
Checks if a deadline has been reached or exceeded.
Sets the deadline context. If a integer is passed it is assumed to be the desired deadline in milliseconds. This function also accepts a full deadline context. This is most commonly used when a deadline has already been set and the context needs to be propagated to another BEAM process.
Returns the remaining time before the dealine is reached, in a given unit. Defaults to :millisecond
units.
If the deadline has been exceeded than the time remaining will be 0.