Class: Kiqstand::Middleware

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

Overview

This is the middleware for ensuring Moped sessions are diconnected after a worker runs, and that the identity map is cleared.

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object

Ensures that after each worker runs, the identity map is cleared in case it was accidentally enabled in this environment, and each session disconnects it’s nodes.

Examples:

Execute the worker.

worker.call

Parameters:

  • args (Array)

    The arguments for the worker.

Since:

  • 1.0.0



18
19
20
21
22
23
24
25
# File 'lib/kiqstand/middleware.rb', line 18

def call(*args)
  yield
ensure
  if defined?(::Mongoid)
    ::Mongoid::IdentityMap.clear
    ::Mongoid.disconnect_sessions
  end
end