ElMassimo / request_store_rails

📦 Per-request global storage for Rails prepared for multi-threaded apps
https://github.com/ElMassimo/request_store_rails
MIT License
85 stars 6 forks source link

RequestLocals isn't accessible inside the particular code #13

Closed VedantKirveCogo closed 1 year ago

VedantKirveCogo commented 1 year ago
 Concurrent::Future.execute({ executor: $concurrent_thread_pool } ) do

       #RequestLocals.fetch(:key) -- > gives yield out of block

        organization_id = eval("partner.twin_#{account_type}_id")
      end

The RequestLocals.fetch() gives yield out of block. What can be a possible way out for this ?

ElMassimo commented 1 year ago

Hi Vedant!

Passing a block to fetch is required.

If you want to fail if the value is missing, you can raise an exception manually:

RequestLocals[:key] || raise(KeyError, ":key was not found")