-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from lemo-nade-room/feature/change-di-swift-dep…
…endencies swift-dependencies移行
- Loading branch information
Showing
12 changed files
with
268 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import AsyncHTTPClient | ||
import Dependencies | ||
import Fluent | ||
import NIOPosix | ||
|
||
extension DependencyValues { | ||
/// Fluent Database | ||
/// | ||
/// データベースが設定されている場合のみ使用可能 | ||
public var db: any Fluent.Database { | ||
databases.database(logger: logger, on: eventLoopGroup.any())! | ||
} | ||
|
||
/// CLIKitのlogger | ||
public var logger: Logger { | ||
get { self[LoggerKey.self] } | ||
set { self[LoggerKey.self] = newValue } | ||
} | ||
private enum LoggerKey: DependencyKey { | ||
static var liveValue: Logger { | ||
fatalError("Value of type \(Value.self) is not registered in this context") | ||
} | ||
} | ||
|
||
public var databases: Databases { | ||
get { self[DatabasesKey.self] } | ||
set { self[DatabasesKey.self] = newValue } | ||
} | ||
private enum DatabasesKey: DependencyKey { | ||
static var liveValue: Databases { | ||
fatalError("Value of type \(Value.self) is not registered in this context") | ||
} | ||
} | ||
|
||
public var eventLoopGroup: MultiThreadedEventLoopGroup { | ||
get { self[EventLoopGroupKey.self] } | ||
set { self[EventLoopGroupKey.self] = newValue } | ||
} | ||
private enum EventLoopGroupKey: DependencyKey { | ||
static var liveValue: MultiThreadedEventLoopGroup { | ||
fatalError("Value of type \(Value.self) is not registered in this context") | ||
} | ||
} | ||
|
||
public var threadPool: NIOThreadPool { | ||
get { self[ThreadPoolKey.self] } | ||
set { self[ThreadPoolKey.self] = newValue } | ||
} | ||
private enum ThreadPoolKey: DependencyKey { | ||
static var liveValue: NIOThreadPool { | ||
fatalError("Value of type \(Value.self) is not registered in this context") | ||
} | ||
} | ||
|
||
public var httpClient: HTTPClient { | ||
get { self[HTTPClientKey.self] } | ||
set { self[HTTPClientKey.self] = newValue } | ||
} | ||
private enum HTTPClientKey: DependencyKey { | ||
static var liveValue: HTTPClient { | ||
fatalError("Value of type \(Value.self) is not registered in this context") | ||
} | ||
} | ||
} |
Oops, something went wrong.