Skip to content

Instantly share code, notes, and snippets.

@Sajjon
Created August 17, 2020 12:58
Show Gist options
  • Save Sajjon/57b3487d11f293ec1cabdb89a4def9cf to your computer and use it in GitHub Desktop.
Save Sajjon/57b3487d11f293ec1cabdb89a4def9cf to your computer and use it in GitHub Desktop.
A suite of jobs piped together.
struct Pipeline<Input, Output>: Job, CustomStringConvertible {
let description: String
private let _getOutput: (Input) throws -> Output
init(description: String, _ getOutput: @escaping (Input) throws -> Output) {
self.description = description
self._getOutput = getOutput
}
}
// MARK: Job
extension Pipeline {
func work(input: Input) throws -> Output {
return try _getOutput(input)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment