-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vladislav Alekseev
committed
Sep 25, 2020
1 parent
c34dfa8
commit ac7e50f
Showing
25 changed files
with
210 additions
and
150 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
12 changes: 12 additions & 0 deletions
12
Sources/QueueClient/Clients/JobStateFetcher/JobStateFetcher.swift
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,12 @@ | ||
import Dispatch | ||
import Foundation | ||
import QueueModels | ||
import Types | ||
|
||
public protocol JobStateFetcher { | ||
func fetch( | ||
jobId: JobId, | ||
callbackQueue: DispatchQueue, | ||
completion: @escaping ((Either<JobState, Error>) -> ()) | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
Sources/QueueClient/Clients/JobStateFetcher/JobStateFetcherImpl.swift
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,32 @@ | ||
import Dispatch | ||
import Foundation | ||
import QueueModels | ||
import RESTMethods | ||
import RequestSender | ||
import Types | ||
|
||
public final class JobStateFetcherImpl: JobStateFetcher { | ||
private let requestSender: RequestSender | ||
|
||
public init(requestSender: RequestSender) { | ||
self.requestSender = requestSender | ||
} | ||
|
||
public func fetch( | ||
jobId: JobId, | ||
callbackQueue: DispatchQueue, | ||
completion: @escaping ((Either<JobState, Error>) -> ()) | ||
) { | ||
let request = JobStateRequest( | ||
payload: JobStatePayload( | ||
jobId: jobId | ||
) | ||
) | ||
requestSender.sendRequestWithCallback( | ||
request: request, | ||
callbackQueue: callbackQueue | ||
) { (result: Either<JobStateResponse, RequestSenderError>) in | ||
completion(result.mapResult { $0.jobState }) | ||
} | ||
} | ||
} |
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 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 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 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 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,10 @@ | ||
import Foundation | ||
import QueueModels | ||
|
||
public final class JobStatePayload: Codable { | ||
public let jobId: JobId | ||
|
||
public init(jobId: JobId) { | ||
self.jobId = jobId | ||
} | ||
} |
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,8 @@ | ||
import Foundation | ||
import RESTInterfaces | ||
|
||
public final class JobStateRESTMethod: RESTPath { | ||
public init() {} | ||
|
||
public var pathWithLeadingSlash: String { "/jobState" } | ||
} |
Oops, something went wrong.