-
Notifications
You must be signed in to change notification settings - Fork 27
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
Vladimir Ignatov
committed
Jun 16, 2020
1 parent
a8fc4e1
commit 1cd7a73
Showing
36 changed files
with
131 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import Foundation | ||
import Models | ||
|
||
public final class Ports { | ||
/// TCP ports that are expecred to be taken by the queue server. | ||
/// This port range appears to be unassigned according to IANA | ||
/// https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=131 | ||
public static let defaultQueuePortRange = 41000...41010 | ||
public static let defaultQueuePortRange: ClosedRange<Port> = 41000...41010 | ||
} |
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,41 @@ | ||
import Foundation | ||
|
||
open class NewIntType: ExpressibleByIntegerLiteral, Codable, Hashable, CustomStringConvertible, Comparable { | ||
public typealias IntegerLiteralType = Int | ||
|
||
public let value: Int | ||
|
||
public init(value: Int) { | ||
self.value = value | ||
} | ||
|
||
public required init(integerLiteral value: Int) { | ||
self.value = value | ||
} | ||
|
||
public var description: String { | ||
return "\(value)" | ||
} | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
hasher.combine(value) | ||
} | ||
|
||
public static func ==(left: NewIntType, right: NewIntType) -> Bool { | ||
return left.value == right.value | ||
} | ||
|
||
public required init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
value = try container.decode(Int.self) | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
try container.encode(value) | ||
} | ||
|
||
public static func < (left: NewIntType, right: NewIntType) -> Bool { | ||
return left.value < right.value | ||
} | ||
} |
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,11 @@ | ||
public final class Port: NewIntType, Strideable { | ||
public typealias Stride = Int | ||
|
||
public func distance(to other: Port) -> Int { | ||
other.value - self.value | ||
} | ||
|
||
public func advanced(by n: Int) -> Self { | ||
return type(of: self).init(value: value + n) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import Foundation | ||
import Models | ||
|
||
public protocol RemoteQueueDetector { | ||
func findSuitableRemoteRunningQueuePorts(timeout: TimeInterval) throws -> Set<Int> | ||
func findMasterQueuePort(timeout: TimeInterval) throws -> Int | ||
func findSuitableRemoteRunningQueuePorts(timeout: TimeInterval) throws -> Set<Models.Port> | ||
func findMasterQueuePort(timeout: TimeInterval) throws -> Models.Port | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import Foundation | ||
import Models | ||
import PortDeterminer | ||
import RESTServer | ||
|
||
extension LocalPortDeterminer: PortProvider { | ||
public func localPort() throws -> Int { | ||
public func localPort() throws -> Port { | ||
return try availableLocalPort() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import Foundation | ||
import Models | ||
|
||
public protocol PortProvider { | ||
func localPort() throws -> Int | ||
func localPort() throws -> Port | ||
} | ||
|
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import Foundation | ||
import Models | ||
|
||
public final class PortProviderWrapper: PortProvider { | ||
private let provider: () throws -> Int | ||
private let provider: () throws -> Port | ||
|
||
public init(provider: @escaping () throws -> Int) { | ||
public init(provider: @escaping () throws -> Port) { | ||
self.provider = provider | ||
} | ||
|
||
public func localPort() throws -> Int { | ||
public func localPort() throws -> Port { | ||
return try provider() | ||
} | ||
} |
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
Oops, something went wrong.