I am newbie to Rails… and I am trying to invoke a third party
using SOAP::RPC::Driver object. Now I can’t store that in session (it
TypeError) so the next best thing (on the suggestion by Ola
from this mailing list) I am storing it in Class variable or I can
store this rpc_driver object in global variable.
In brief my concerns are related to race conditions that may arise if I
store resusable objects in class/global variables.
I know it is very difficult to simulate and identify a race condition.
this is what I think may happen if I use class variable or even global
variable to store SOAP::RPC::Driver object.
In production each controller is loaded only once which I assume means
is only one instance of controller serving multiple requests. Now lets
assume that all the parameters needed to make the web service call are
to the action (method), which means these parameters are immune from
conditions since the are on the thread stack and each thread is unique
each request. But the class variable or global variable is shared across
multiple requests, now imagine the same class variable or global
accessed in different controllers or different actions of same
Hence there is a potential that the result of a webservice call may get
mixed up, depending on who gets the returned value first.
I may completely wrong here since I don’t know about the inner working
the CGI/FCGI/Rails request handling. Can anyone please enlighten me or
me if my fears are misplaced?