-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to create multiple instances of Responsys::Api::Client #6
Comments
Hi @zhuravel, The reason why it's a singleton right now is because we didn't want to have to authenticate for every API request. We wanted to authenticate once with our credentials and then use those credentials for all subsequent API calls until we close the connection. We only have 1 interact account, does your application deal with multiple Responsys Interact accounts? |
@dandemeyere Yes, I need to hit 3 different Responsys Interact APIs. class ResponsysAccounts
class_attribute :instances
self.instances = {}
def self.set(identifier, client)
self.instances[identifier] = client
end
def self.get(identifier)
self.instances[identifier]
end
end
ResponsysAccounts.set(:first, Responsys::Api::Client.new(username: ..., password: ..., wsdl: 'xxxx'))
ResponsysAccounts.set(:second, Responsys::Api::Client.new(username: ..., password: ..., wsdl: 'yyyy'))
client = ResponsysAccounts.get(:first)
client.api_method(:list_folders) |
If you require the ability to handle multiple Responsys accounts in the near future, I would suggest either forking our gem or opening a pull request containing the code to add that functionality so we can merge it in (assuming you add tests, documentation, etc.). We're still in the onboarding phase with Responsys and we have a fair amount of functionality to build out before our integration is complete so the priority for our efforts is to build this gem such that our business (thredUP) is able to utilize Responsys Interact API functionality as soon as possible. After we have a stable version of the gem that we're confident in and we've completed our integration with Responsys, then we'll come back and think through what the next steps are for this gem. I don't have a timetable for when that would be, but we can keep this issue open and we can re-visit this topic once we reach that point. |
Hi @dandemeyere, Is the client thread-safe? |
@florrain - can you help answer that question when you have time please? |
@atomical - The client has never been inspected or thought to be thread-safe at any point. Looking at the code, the section that might come into problems with different threads is the configuration of the GEM (Responsys::Configuration ||= operation for ex) and the initialization of the SessionPool. I suggest you double check in the code, especially if you're worried about this kind of issue you might be aware of good/bad safe patterns. Any suggestions/PR will be appreciated to make the client thread-safe if it isn't enough today. |
Hi guys,
First off thank you for this gem, absolute lifesaver! :)
A great feature would be the ability to create multiple instances of Client class with different credentials.
Right now it is a singleton which unfortunately doesn't work for me and may not work for other gem users who need to call more than one Responsys API in one application.
The text was updated successfully, but these errors were encountered: