-
Notifications
You must be signed in to change notification settings - Fork 228
Chore - possibility to inject URLSessionConfiguration to be used by ChatClient #2756
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
Chore - possibility to inject URLSessionConfiguration to be used by ChatClient #2756
Conversation
nuno-vieira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @mschuetz-viz!
We were actually going to work on it this week, but you beat us to it 😛
The implementation was actually what we were going to do 👍
Just added some minor comments. You don't need to change them if you don't have the time, we can do it ourselves no problem 👍
Thank you again for your time!
| /// The `URLSessionConfiguration` being used as default configuration for the `APIClient` and | ||
| /// `WebSocketClient` | ||
| public let urlSessionConfiguration: URLSessionConfiguration | ||
|
|
||
| public init( | ||
| apiKey: APIKey, | ||
| urlSessionConfiguration: URLSessionConfiguration = .default | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for consistency purposes it is better we follow the rest of the properties approach, where they are mutable with an initial value, and then you can change it whenever you create the config. 👍
| /// The `URLSessionConfiguration` being used as default configuration for the `APIClient` and | |
| /// `WebSocketClient` | |
| public let urlSessionConfiguration: URLSessionConfiguration | |
| public init( | |
| apiKey: APIKey, | |
| urlSessionConfiguration: URLSessionConfiguration = .default | |
| ) { | |
| /// The `URLSessionConfiguration` being used as the default configuration for the `APIClient` and | |
| /// `WebSocketClient` | |
| public var urlSessionConfiguration: URLSessionConfiguration = .default | |
| public init( | |
| apiKey: APIKey | |
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency is king 🤴 - fixed
| let configuration = config.urlSessionConfiguration | ||
| configuration.waitsForConnectivity = false | ||
| configuration.httpAdditionalHeaders = sessionHeaders | ||
| configuration.timeoutIntervalForRequest = config.timeoutIntervalForRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One downside here is that customers won't be able to override the waitsForConnectivity or the httpAdditionalHeaders. But for now, I think this approach is simple enough, and it should work for 99.99% of use cases. If we see the need, we can add this feature later 👍
…schuetz-viz/stream-chat-swift into feature/inject-urlsessionconfiguration
|
Thanks for the quick response & input @nuno-vieira - impressive work that you're doing with this SDK, quite enjoyed looking around in your code base and try figuring out a proposal for our problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! ✅
@mschuetz-viz Thank you again! 🙏
We will update the changelog and merge this one once we publish the 4.36.0 release 👍
|
Just to double check - some Github Checks are failing, is there anything I can do? Please let me know if you need anything further from my side. |
@mschuetz-viz It should be fine 👍 This is all permissions related things, we will handle it from here no problem 🙂 |
|
@nuno-vieira is there any estimation when this will be released? no hurry, just to plan our next sprint 😅 |
|
Hi @mschuetz-viz! The estimation is next week, worst case scenario 2 weeks max 👍 |
🔗 Issue Links
Customer Support Ticket #39734
🎯 Goal
We, at Viz.ai, are heavily using
URLProtocolbased mocks for testing our application flows in our UI tests. While transitioning to Stream Chat we found that currently there's no way of injecting a preparedURLSessionConfigurationinto theChatClientto be used with our mocking engine. This pull request contains a proposal of how we could optionally inject such a preparedURLSessionConfigurationand unblock our development of UI tests.📝 Summary
urlSessionConfigurationproperty to theChatClientConfigstructurlSessionConfigurationwill be initialised withURLSessionConfiguration.default, as beforeChatClient,ChatClientConfig.urlSessionConfigurationwill be used instead ofURLSessionConfiguration.default🛠 Implementation
The goal was to change as little code as possible while making it obvious from an API perspective.
🎨 Showcase
not applicable - no visual changes
🧪 Manual Testing Notes
not applicable - default behaviour has not changed
☑️ Contributor Checklist
🎁 Meme