Skip to content

Make Intercom thread safe#103

Closed
tscolari wants to merge 1 commit intointercom:masterfrom
tscolari:master
Closed

Make Intercom thread safe#103
tscolari wants to merge 1 commit intointercom:masterfrom
tscolari:master

Conversation

@tscolari
Copy link
Copy Markdown

@tscolari tscolari commented Sep 1, 2014

Removed the instance variables on modules, that would be shared between different threads, by the Thread.current hash.

Currently on driftrock.com our use case requires us to switch intercom credentials on each request, this changes will make it possible for apps using thread servers (e.g. puma) to safely switch their intercom credentials.

A best approach in my opinion would instead of a module, Intercom be a proper class and get instantiated (it's already a module with state anyway), but that would be a breaking change.

Removed the instance variables on modules, that would be shared
between different threads, by the `Thread.current` hash.
@tonydaly
Copy link
Copy Markdown

👍

@paultyng
Copy link
Copy Markdown

Alternatively you could pass the app_id/app_api_key per call, which wouldn't be breaking if it was an override, I've seen some other API libraries do that (EasyPost is another we use). But I definitely am interested in a change like this as we would like to integrate to multiple Intercom accounts.

@tonydaly
Copy link
Copy Markdown

A lot of other API libraries seem to be completely moving away from a global configuration as it's not threadsafe: http://www.rubydoc.info/gems/twitter

This would be the best option moving forward.

@josler
Copy link
Copy Markdown
Contributor

josler commented Nov 17, 2014

Agreed; we're looking at making Intercom-Ruby multi-app (and threadsafe) in the near future.

@scpike
Copy link
Copy Markdown

scpike commented Mar 3, 2015

@josler any progress here? I just set up intercom and I'm seeing an average response time of ~187ms for the event API, so I'd like to run the create inside a thread. I'm not changing anything about the Intercom configuration at runtime, so maybe it's safe as is?

@josler
Copy link
Copy Markdown
Contributor

josler commented Mar 3, 2015

No news to share about this currently. For your use case it should be fine if you're not switching credentials between threads.

@tscolari tscolari changed the title Making Intercom thread safe Make Intercom thread safe May 5, 2015
@josler
Copy link
Copy Markdown
Contributor

josler commented May 28, 2015

#159 - this is a WIP beta of v3 of this client, which does not have global credentials

@josler
Copy link
Copy Markdown
Contributor

josler commented Jun 4, 2015

This is implemented now! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants