Class: Raptor::Reactor::TimeoutClient

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

Overview

Red-black tree node representing a client connection with timeout tracking.

TimeoutClient extends RedBlackTree::Node to enable efficient timeout management using the tree’s ordering properties.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#timeout_atObject

Returns the value of attribute timeout_at.



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

def timeout_at
  @timeout_at
end

Instance Method Details

#<=>(other) ⇒ Integer

Compares timeout nodes by their timeout_at values for tree ordering.

Parameters:

Returns:

  • (Integer)

    -1, 0, or 1 for ordering



61
62
63
# File 'lib/raptor/reactor.rb', line 61

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

#client_dataHash

Returns the client data stored in this timeout node.

Returns:

  • (Hash)

    the client connection state data



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

def client_data
  data
end

#timeout(now) ⇒ Float

Calculates remaining timeout duration from the current time.

Parameters:

  • now (Float)

    current monotonic timestamp

Returns:

  • (Float)

    remaining timeout in seconds, minimum 0



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

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