Class: Raptor::Reactor::TimeoutClient

Inherits:
RedBlackTree::Node
  • Object
show all
Defined in:
lib/raptor/reactor.rb,
sig/generated/raptor/reactor.rbs

Overview

A client connection node ordered by absolute expiry time so the soonest-to-expire is always at the tree's minimum.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#timeout_atObject

Returns the value of attribute timeout_at.

Returns:

  • (Object)


34
35
36
# File 'lib/raptor/reactor.rb', line 34

def timeout_at
  @timeout_at
end

Instance Method Details

#<=>(other) ⇒ Integer

Orders nodes by timeout_at so the tree minimum is the next client to expire.

Parameters:

Returns:

  • (Integer)

    -1, 0, or 1



63
64
65
# File 'lib/raptor/reactor.rb', line 63

def <=>(other)
  timeout_at <=> other.timeout_at
end

#client_dataHash

Semantic alias for the inherited data slot.

Returns:

  • (Hash)

    the client connection state



41
42
43
# File 'lib/raptor/reactor.rb', line 41

def client_data
  data
end

#timeout(now) ⇒ Float

Returns seconds until expiry, clamped to 0 so an already-expired client doesn't push the next selector wait into the future.

Parameters:

  • now (Float)

    current monotonic timestamp

Returns:

  • (Float)

    seconds until expiry, never negative



52
53
54
# File 'lib/raptor/reactor.rb', line 52

def timeout(now)
  [timeout_at - now, 0].max
end