Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": false
}
20 changes: 10 additions & 10 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/vapor/vapor.git", from: "4.76.2"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.77.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.8.0")
],
targets: [
Expand Down
18 changes: 17 additions & 1 deletion Sources/YData/Core/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,32 @@ public protocol Configuration {
associatedtype Error: ConfigurationError

static func loadFromEnvironment() -> Result<Self, Error>

static func loadFromEnvironment() throws -> Self

static func loadFromEnvironment<C: Context>(context: C) -> Result<Self, Error>
static func loadFromEnvironment<C: Context>(context: C) throws -> Self
}

public extension Configuration {
static func loadFromEnvironment() -> Result<Self, Error> {
return .failure(NotImplementedError() as! Self.Error)
}

static func loadFromEnvironment() throws -> Self {
let result: Result<Self, Error> = loadFromEnvironment()
switch result {
case .success(let success): return success
case .failure(let error): throw error
}
}

static func loadFromEnvironment<C: Context>(context: C) -> Result<Self, Error> {
loadFromEnvironment()
}

static func loadFromEnvironment<C: Context>(context: C) throws -> Self {
try loadFromEnvironment()
}
}

public struct NotImplementedError: ConfigurationError {}
3 changes: 3 additions & 0 deletions Sources/YData/Core/Context/Context.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Foundation

public protocol Context {}
2 changes: 1 addition & 1 deletion Sources/YData/Core/Context/EventLoopContext.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import protocol NIO.EventLoop

public protocol EventLoopContext {
public protocol EventLoopContext: Context {
var eventLoop: EventLoop { get }
}
2 changes: 1 addition & 1 deletion Sources/YData/Core/Context/LoggerContext.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import Vapor

public protocol LoggerContext {
public protocol LoggerContext: Context {
var logger: Logger { get }
}