Class: Restate::Middleware::DeadlockDetection::Outbound

Inherits:
Object
  • Object
show all
Defined in:
lib/restate/middleware/deadlock_detection.rb

Overview

Outbound middleware that propagates held locks via headers.

When handler metadata is available (via Thread.current), shared handler calls are allowed through — only exclusive handlers can deadlock. When metadata is unavailable (external service called by string name), falls back to raising for any same-service call.

Register with: endpoint.use_outbound(Restate::Middleware::DeadlockDetection::Outbound)

Examples:

endpoint = Restate.endpoint(MyVirtualObject)
endpoint.use_outbound(Restate::Middleware::DeadlockDetection::Outbound)

Instance Method Summary collapse

Instance Method Details

#call(service, handler, headers) ⇒ Object



187
188
189
190
191
# File 'lib/restate/middleware/deadlock_detection.rb', line 187

def call(service, handler, headers)
  locks = DeadlockDetection.held_locks
  propagate_and_check!(service, handler, headers, locks) if locks.any?
  yield
end