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
Refactor APNS struct to be a single instance #31
Conversation
|
||
let application: Application | ||
public let eventLoop: EventLoop | ||
public let logger: Logger? |
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.
Rather than computing these properties, pass them into the init, allowing Application
and Request
to use their own versions.
This was a huge pain when I was developing with this library. This change should make it easier to pass |
@mpdifran Unfortunately, this PR would break source compatibility by changing public API with no automatic migration path - in other words, it is a semver-major change. Your change would also make properties inherent to the application-global APNS object ( |
There should still be a way to configure things to keep those methods from Yeah I realize it's a breaking change, but IMO I think the change is worth it. The problems I'm running into is passing Let me try updating my PR to hide the extra methods from |
b029fad
to
2b74dcc
Compare
nonmutating set { | ||
self.application.storage[ConfigurationKey.self] = newValue | ||
} | ||
public var apnsConfiguration: APNSwiftConfiguration? { |
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.
Moved this from the APNS
object to the root Application
.
priority: priority, | ||
collapseIdentifier: collapseIdentifier, | ||
topic: topic, | ||
public var apnsPool: EventLoopGroupConnectionPool<APNSConnectionSource> { |
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.
Moved this from the APNS
object to the root Application
.
Besides the fact that it's a breaking change, I must agree with @gwynne. I also think that I think the issues you are having stems from the fact that you're trying to do stuff at the wrong abstraction level. You'll probably want to pass Could show some concrete examples of what you are trying to do, that is causing you issues? |
Rather than having a different type for Request and Application, share the same type.
2b74dcc
to
ae2ceb6
Compare
Here's the class I've made to help me send a notification to all devices for a user (this is based off of my proposed changes here). You are right though, I can pass around Just seems like a very odd API decision to name these properties the same on both objects when they're actually different types. Definitely tripped me up compared to other properties like
|
Regardless, I can make due with your workaround, so I'll close this PR. Thanks for taking a look! |
Rather than having a different type for Request and Application, share the same type.
Migration Guide: