Class: Restate::Middleware::DeadlockDetection::Inbound

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

Overview

Inbound middleware that checks for and tracks VO locks.

Register with: endpoint.use(Restate::Middleware::DeadlockDetection::Inbound)

Examples:

endpoint = Restate.endpoint(MyVirtualObject)
endpoint.use(Restate::Middleware::DeadlockDetection::Inbound)

Instance Method Summary collapse

Instance Method Details

#call(handler, ctx) ⇒ Object



133
134
135
136
137
138
139
140
141
# File 'lib/restate/middleware/deadlock_detection.rb', line 133

def call(handler, ctx)
  previous = DeadlockDetection.held_locks
  incoming = parse_locks(ctx)
  check_and_track_lock!(handler, ctx, incoming)
  DeadlockDetection.held_locks = incoming
  yield
ensure
  DeadlockDetection.held_locks = previous
end