-
Notifications
You must be signed in to change notification settings - Fork 2
eventLoopGroupProvider provider for async http client #39
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
Comments
Just because Hummingbird provides an HTTPClient, does not mean it should be shared by the WebPushManager — it may have a very different set of expectations than the one provided after all (namely HTTP/2 support, no TLS client overrides, etc…). Not to mention, pipelining will likely be tweaked in the near future, so a shared HTTP client may likely interrupt this process from working smoothly. The purpose of let manager = WebPushManager(
vapedConfiguration: config,
backgroundActivityLogger: logger,
eventLoopGroupProvider: .shared(application.eventloopGroup)
) The purpose of the deinit is to facilitate usage when swift-service-lifecycle is not used (mostly because there was a ton of boilerplate in tests, and in existing Vapor apps). If you run into any integration issues with what I mentioned above, please let me know! |
Thanks for such a detail response. Hummingbird does not provide an HTTPClient by default. It makes use of the swift service life cycle. Unless, the HTTPClient's configuration needs changes inside WebPushManager which I don't think it does today. An instance of the Client should be passed instead. I don't any strong opinions of requiring an How does one handle graceful shutdown with the current implementation? Since the eventLoopGroupProvider is not even required? |
The key piece here is that the HTTPClient itself should not be pre-configured in any special way, as that'll likely mess with functionality in a non-useful way — HTTPClients don't even need to be shared, you really can make as many of them as you want with different configurations and they'll play together just fine, because again, they share the event loop group under the hood. You really should be interpreting the HTTPClient as an implementation detail, not a hot-swappable component. If your goal for passing an HTTPClient is to mock it in tests, the WebPushTesting module provides a much more convenient
Something like this should work just fine, if you are already using swift-service-lifecycle: let manager = WebPushManager(
vapidConfiguration: vapidConfig,
backgroundActivityLogger: logger
)
try await ServiceGroup(
services: [
manager
],
logger: logger
).run() |
There is a new initializer that takes an |
Thanks for much for putting this great library together. I have been testing it for a few days now.
I come to the conclusion that
eventLoopGroupProvider
should not be a required parameter since it's only used the async-http-client. Should WebPushManager take in an instance of the http client instead? In Hummingbird one can create a single HTTPClientService that gets shared amongst all libraries that needs an instance of the http client.Please let me know if this is a welcome change as it is also a breaking change. I can a PR out if needed.
I think this deinit can be replaced with the service lifecycle. An example of the service life cycle can be seen here we would simply add WebPushManager as a service graceful shutdown would be handle cleanly
https://github.com/swift-server/swift-service-lifecycle
The text was updated successfully, but these errors were encountered: