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
Migrate from Lock
to NIOLock
#2891
Conversation
The test failures seem real, but also unrelated to this PR. |
Opened an issue for the test failures: #2892 |
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.
I don't think we need to change any of the names of the application properties since they're namespaced under Application
Sources/Vapor/Application.swift
Outdated
@@ -46,13 +48,45 @@ public final class Application { | |||
} | |||
} | |||
} | |||
|
|||
public final class NIOLocks { |
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.
Since this is Application.Lock
I don't think we actually need to rename any of this
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.
can you elaborate more please?
there is rule where if public properties are name-spaced under another public property, we can make breaking changes to them?!
or do you mean I could have fit NIOLock
stuff under the same Locks
class?
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.
We only need to change the deprecated types (so Lock
to NIOLock
) rather than renaming everything that refers to them
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.
thats news to me from what I understand ... does this new commit fix the problem?
…vapor into mahdibm-move-to-NIOLock
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.
Yep this is looking good! Once last change then good to go
Sources/Vapor/Application.swift
Outdated
@@ -71,7 +72,6 @@ public final class Application { | |||
case .createNew: | |||
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) | |||
} | |||
self.locks = .init() |
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.
Let's move this back to reduce the change and make it easier to work out where it's created
Sources/Vapor/Application.swift
Outdated
public var locks: Locks | ||
public var locks = Locks() |
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.
Revert
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.
👍 had to do it before to avoid deprecation warnings
Original Comment: ChangesAll Feel free to suggest better names for |
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.
Thanks!
These changes are now available in 4.66.1 |
I've just realized that this is a source breaking change (semver major). The following code would no longer compile (instead of issuing deprecation warnings) with 4.66.1: import NIOConcurrencyHelpers
import Vapor
struct SomeStruct {
private enum _LockKey: LockKey {}
let lock: Lock
var storage = Array<String>()
init(app: Application) {
self.lock = app.locks.lock(for: _LockKey.self) // error: Cannot assign value of type 'NIOLock' to type 'Lock'
}
} I'm not sure how often this happens, though. |
Ah that's a good point. Unfortunately we've now released so there's not a huge amount to do. I'm surprised this didn't get picked up by the API Checker |
It didn't get picked up because we didn't configure the API breakage check to run for this repo until two weeks later 🤦♀️ |
In my defense, i did realize this, and that was why i sound surprised in one of the comments above 😶 |
Perfect timing... 😂
I'm not blaming anyone here. Stuff like this happens. 😉 |
No worries, it didn't sound like blaming 😅 |
Lock
has recently been deprecated in favor ofNIOLock
.Changes
All
Lock
s have been renamed toNIOLock
.