Skip to content

Commit

Permalink
fix(context): split it to make it more modular (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa committed Feb 3, 2022
1 parent 66c523c commit 0ac48f5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Sources/YData/Core/Context/EventLoopContext.swift
@@ -0,0 +1,6 @@
import Foundation
import protocol NIO.EventLoop

public protocol EventLoopContext {
var eventLoop: EventLoop { get }
}
6 changes: 6 additions & 0 deletions Sources/YData/Core/Context/LoggerContext.swift
@@ -0,0 +1,6 @@
import Foundation
import Vapor

public protocol LoggerContext {
var logger: Logger { get }
}
5 changes: 1 addition & 4 deletions Sources/YData/Core/Service.swift
@@ -1,10 +1,7 @@
import Foundation
import Vapor

public protocol ServiceContext {
var eventLoop: EventLoop { get }
var logger: Logger { get }
}
public protocol ServiceContext: EventLoopContext, LoggerContext {}

public protocol Service {
associatedtype Context: ServiceContext
Expand Down
6 changes: 6 additions & 0 deletions Sources/YData/Database/DatabaseContext.swift
@@ -0,0 +1,6 @@
import Fluent
import Foundation

public protocol DatabaseContext {
var database: Database { get }
}
5 changes: 1 addition & 4 deletions Sources/YData/Database/DatabaseServiceContext.swift
@@ -1,6 +1,3 @@
import Fluent
import Foundation

public protocol DatabaseServiceContext: ServiceContext {
var database: Database { get }
}
public protocol DatabaseServiceContext: DatabaseContext, ServiceContext {}

0 comments on commit 0ac48f5

Please sign in to comment.