Closed
Description
I am writing a multi-tenant front-end application which queries a back-end service. The API is authenticated via HTTP basic, which I have implemented in json_api_client using a Faraday middleware:
self.connection do |connection|
connection.use Faraday::Request::BasicAuthentication, api_key, api_secret
end
The problem is that this connection is stored as a class variable and is not thread safe. I considered just calling self.connection(true) to rebuild it on every request, but I believe race conditions will emerge. Ultimately, the design is the problem. I'd love to be able to store a connection as a Thread local variable, or worst case as an instance variable.
I'd like to open a conversation with any interested parties to discuss whether there might be a better approach, or if we should consider re-designing the storage of the connection.
Metadata
Metadata
Assignees
Labels
No labels