Skip to content

Commit 2bb74ca

Browse files
committed
Rename ExecutionModel to ThreadOwnershipModel with internal and external cases
1 parent 38dea81 commit 2bb74ca

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

Sources/DispatchRedis/Redis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public final class Redis {
99
deinit { try? driver.terminate() }
1010

1111
public init(threadCount: Int = 1) {
12-
self.driver = RedisDriver(executionModel: .spawnThreads(threadCount))
12+
self.driver = RedisDriver(ownershipModel: .internal(threadCount: threadCount))
1313
}
1414

1515
public func makeConnection(

Sources/NIORedis/RedisDriver.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ public final class RedisDriver {
66
///
77
/// Using `.eventLoopGroup` will allow an external provider to handle the lifetime of the `EventLoopGroup`,
88
/// while using `spawnThreads` will cause this `NIORedis` instance to handle the lifetime of a new `EventLoopGroup`.
9-
public enum ExecutionModel {
10-
case spawnThreads(Int)
11-
case eventLoopGroup(EventLoopGroup)
9+
public enum ThreadOwnershipModel {
10+
case `internal`(threadCount: Int)
11+
case external(EventLoopGroup)
1212
}
1313

14-
private let executionModel: ExecutionModel
14+
private let ownershipModel: ThreadOwnershipModel
1515
private let eventLoopGroup: EventLoopGroup
1616

1717
private let isRunning = Atomic<Bool>(value: true)
@@ -20,14 +20,14 @@ public final class RedisDriver {
2020

2121
/// Creates a driver instance to create connections to a Redis.
2222
/// - Important: Call `terminate()` before deinitializing to properly cleanup resources.
23-
/// - Parameter executionModel: The model to use for handling connection resources.
24-
public init(executionModel model: ExecutionModel) {
25-
self.executionModel = model
23+
/// - Parameter ownershipModel: The model to use for handling connection resources.
24+
public init(ownershipModel model: ThreadOwnershipModel) {
25+
self.ownershipModel = model
2626

2727
switch model {
28-
case .spawnThreads(let count):
28+
case .internal(let count):
2929
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: count)
30-
case .eventLoopGroup(let group):
30+
case .external(let group):
3131
self.eventLoopGroup = group
3232
}
3333
}
@@ -37,9 +37,9 @@ public final class RedisDriver {
3737
public func terminate() throws {
3838
guard isRunning.exchange(with: false) else { return }
3939

40-
switch executionModel {
41-
case .spawnThreads: try self.eventLoopGroup.syncShutdownGracefully()
42-
case .eventLoopGroup: return
40+
switch ownershipModel {
41+
case .internal: try self.eventLoopGroup.syncShutdownGracefully()
42+
case .external: return
4343
}
4444
}
4545

Tests/NIORedisTests/Commands/BasicCommandsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import XCTest
33

44
final class BasicCommandsTests: XCTestCase {
5-
private let redis = RedisDriver(executionModel: .spawnThreads(1))
5+
private let redis = RedisDriver(ownershipModel: .internal(threadCount: 1))
66
deinit { try? redis.terminate() }
77

88
private var connection: RedisConnection?

Tests/NIORedisTests/RedisDriverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ final class RedisDriverTests: XCTestCase {
66
private var connection: RedisConnection!
77

88
override func setUp() {
9-
let driver = RedisDriver(executionModel: .spawnThreads(1))
9+
let driver = RedisDriver(ownershipModel: .internal(threadCount: 1))
1010

1111
guard let connection = try? driver.makeConnection().wait() else {
1212
return XCTFail("Failed to create a connection!")

Tests/NIORedisTests/RedisPipelineTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ final class RedisPipelineTests: XCTestCase {
66
private var connection: RedisConnection!
77

88
override func setUp() {
9-
let redis = RedisDriver(executionModel: .spawnThreads(2))
9+
let redis = RedisDriver(ownershipModel: .internal(threadCount: 1))
1010

1111
guard let connection = try? redis.makeConnection().wait() else {
1212
return XCTFail("Failed to create connection!")

0 commit comments

Comments
 (0)