Class: LazyData::InternalState
- Inherits:
-
Object
- Object
- LazyData::InternalState
- Defined in:
- lib/lazy_data/internal_state.rb
Overview
A representation of the internal state of a Value.
Constant Summary collapse
- FAILED =
The FAILED state indicates that computation has failed finally and no more retries will be done. If the state is FAILED, and error will be present and the value will be nil. The expires_at time will be a CLOCK_MONOTONIC timestamp if the failure can expire, or nil if not.
:failed- SUCCESS =
The SUCCESS state indicates that computation has completed successfully, and the value is set. The error will be nil. The expires_at time will be a CLOCK_MONOTONIC timestamp if the value can expire, or nil if not.
:success- PENDING =
The PENDING state indicates the value has not been computed, or that previous computation attempts have failed but there are retries pending. The error will be set to the most recent error, or nil if no computation attempt has yet been started. The value will be nil. The expires_at time will be the CLOCK_MONOTONIC timestamp when the current retry delay will end (or has ended, so it could be in the past), or nil if there are no retry delays.
:pending- COMPUTING =
The COMPUTING state indicates that a thread is currently computing the value. The error and value will both be nil. The expires_at time will be the CLOCK_MONOTONIC timestamp when the computation had started.
:computing
Instance Attribute Summary collapse
- #error ⇒ Exception? readonly
-
#expires_at ⇒ Numeric?
readonly
The CLOCK_MONOTONIC timestamp of expiration, or the start of the current computation when in COMPUTING state.
-
#state ⇒ Symbol
readonly
The general state of the value.
-
#value ⇒ Object
readonly
The current computed value, if the state is SUCCESS, or nil for any other state.
Instance Method Summary collapse
-
#computing? ⇒ boolean
Query whether the state is computing.
-
#failed? ⇒ boolean
Query whether the state is failure.
-
#pending? ⇒ boolean
Query whether the state is pending.
-
#success? ⇒ boolean
Query whether the state is success.
Instance Attribute Details
#error ⇒ Exception? (readonly)
77 78 79 |
# File 'lib/lazy_data/internal_state.rb', line 77 def error @error end |
#expires_at ⇒ Numeric? (readonly)
The CLOCK_MONOTONIC timestamp of expiration, or the start of the current computation when in COMPUTING state.
85 86 87 |
# File 'lib/lazy_data/internal_state.rb', line 85 def expires_at @expires_at end |
#state ⇒ Symbol (readonly)
61 62 63 |
# File 'lib/lazy_data/internal_state.rb', line 61 def state @state end |
#value ⇒ Object (readonly)
The current computed value, if the state is SUCCESS, or nil for any other state
69 70 71 |
# File 'lib/lazy_data/internal_state.rb', line 69 def value @value end |
Instance Method Details
#computing? ⇒ boolean
Query whether the state is computing
119 120 121 |
# File 'lib/lazy_data/internal_state.rb', line 119 def computing? state == COMPUTING end |
#failed? ⇒ boolean
Query whether the state is failure
92 93 94 |
# File 'lib/lazy_data/internal_state.rb', line 92 def failed? state == FAILED end |
#pending? ⇒ boolean
Query whether the state is pending
110 111 112 |
# File 'lib/lazy_data/internal_state.rb', line 110 def pending? state == PENDING end |
#success? ⇒ boolean
Query whether the state is success
101 102 103 |
# File 'lib/lazy_data/internal_state.rb', line 101 def success? state == SUCCESS end |