Class: SolidLoop::LeaseRenewer::Registration

Inherits:
Struct
  • Object
show all
Defined in:
lib/solid_loop/lease_renewer.rb

Overview

A single registered in-flight lease. lost is the exact per-turn signal the old heartbeat exposed: set true iff a conditional renew for THIS registration touched 0 rows AND the loop is no longer ours (rotated away / reclaimed). A renew error also flips it (a dead renewer must never let a dead lease look alive). It is a Concurrent::AtomicBoolean so the write (on the renewer thread) and the read (on the main path) carry a proper memory barrier on every Ruby engine, not only under MRI's GVL.

registered_at stamps when this turn registered, used to enforce a HARD CEILING (see #ceiling_expired?): a leaked registration (a job that never deregistered) is dropped once it exceeds the OWNING AGENT'S OWN legal turn bound — max_duration + config.lease_leak_grace — so its lease finally lapses and the reaper reclaims the loop, and renewer liveness no longer depends on ensure ever running.

max_duration is the agent's already-enforced legal turn duration (see SolidLoop::Base#max_duration, default 2h): a turn longer than that is illegitimate BY THE AGENT'S OWN CONTRACT. Deriving the ceiling from it (not from lease_duration × K) means a LEGITIMATE turn — bounded by max_duration — always finishes before the ceiling and is NEVER dropped, while a genuine leak still self-expires shortly after max_duration. (The old lease_duration × K ceiling dropped healthy long turns too: an agent with a tiny read_timeout and steady chunks streams healthily for far longer than K lease-widths.)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#execution_tokenObject

Returns the value of attribute execution_token

Returns:

  • (Object)

    the current value of execution_token



92
93
94
# File 'lib/solid_loop/lease_renewer.rb', line 92

def execution_token
  @execution_token
end

#lease_durationObject

Returns the value of attribute lease_duration

Returns:

  • (Object)

    the current value of lease_duration



92
93
94
# File 'lib/solid_loop/lease_renewer.rb', line 92

def lease_duration
  @lease_duration
end

#loop_idObject

Returns the value of attribute loop_id

Returns:

  • (Object)

    the current value of loop_id



92
93
94
# File 'lib/solid_loop/lease_renewer.rb', line 92

def loop_id
  @loop_id
end

#lostObject

Returns the value of attribute lost

Returns:

  • (Object)

    the current value of lost



92
93
94
# File 'lib/solid_loop/lease_renewer.rb', line 92

def lost
  @lost
end

#max_durationObject

Returns the value of attribute max_duration

Returns:

  • (Object)

    the current value of max_duration



92
93
94
# File 'lib/solid_loop/lease_renewer.rb', line 92

def max_duration
  @max_duration
end

#registered_atObject

Returns the value of attribute registered_at

Returns:

  • (Object)

    the current value of registered_at



92
93
94
# File 'lib/solid_loop/lease_renewer.rb', line 92

def registered_at
  @registered_at
end

Instance Method Details

#lost?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/solid_loop/lease_renewer.rb', line 93

def lost?
  lost.true?
end

#mark_lost!Object



97
98
99
# File 'lib/solid_loop/lease_renewer.rb', line 97

def mark_lost!
  lost.make_true
end