-
Notifications
You must be signed in to change notification settings - Fork 75
use thread local (optionally) for context setting #204
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
Conversation
|
Thanks for this WIP PR @pjfanning. I'll bring this to discussion with our team to get some input on this and your approach 👍 |
|
@pjfanning got confirmation from the team that this approach is good so do continue with some tests 👍 |
|
@thewheat does the IntercomTest class look ok? It's not very pretty, especially since I'm restricted from using the Java 8 enhancements for Futures and executor services. |
|
@pjfanning just back after a long weekend holiday here. I've not dealt with threads in Java before so will need to dig into this a bit with the team. Were there any other questions that you could have by following this current approach? May be easier to get all questions that we can discuss to prevent delays 👍 |
|
@thewheat I guess this approach has the advantage of limiting the API change but in the end I think that @xpg 's https://github.com/xgp/intercom-java approach is a better bet. |
|
I do kind of agree that being able to pass in an extra "authentication" object is nice and I don't think we'd be opposed to a breaking change so long as it is a step in the right direction. But having no breaking changes but still being able to provide new functionally is even better 😄 Just so you know, I'm still waiting on feedback from the team regarding the current approach but will update as soon as possible 👍 |
|
Hi @pjfanning, sorry for slow reply! I think this is a good approach, it should be quite useful. |
|
@mmartinic I added a clearThreadLocalContexts method. I prefer the verb |
|
@pjfanning thanks! sorry, I wasn't very clear. I was more thinking it would be useful to have something that clears thread local context for current thread, not all of them. this can then be used to clear the context in current thread before setting new values. Idea is to prevent value left over from previous request that was using that same thread. |
|
Added extra clearThreadLocalContext method. |
|
@pjfanning this is great! thanks for adding it! |
Relates to #89
If this approach of allowing the use of thread specific configuration is ok, I can add extra test coverage and tidy up the code.
My use case is my application is multi-tenanted and different threads might be handling data for different customers with different intercom API keys.
Using thread contexts has its limitations but it requires fewer code changes than the idea of having per-object configuration.