Skip to content

Commit

Permalink
Swift 4 (#35)
Browse files Browse the repository at this point in the history
* Provides support for Swift 4
  • Loading branch information
Aaron Liberatore authored Oct 2, 2017
1 parent b306c07 commit 7f6fe4c
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.build/*
CircuitBreaker.xcodeproj
*.xcodeproj
*.DS_Store
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ matrix:
- os: linux
dist: trusty
sudo: required
- os: linux
dist: trusty
sudo: required
env: SWIFT_SNAPSHOT=4.0
- os: osx
osx_image: xcode8.3
sudo: required
- os: osx
osx_image: xcode9
sudo: required
env: SWIFT_SNAPSHOT=4.0

before_install:
- git clone https://github.com/IBM-Swift/Package-Builder.git
Expand Down
43 changes: 43 additions & 0 deletions Package@swift-4.0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

/**
* Copyright IBM Corporation 2016, 2017
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

import PackageDescription

let package = Package(
name: "CircuitBreaker",
products: [
.library(
name: "CircuitBreaker",
targets: ["CircuitBreaker"]
)
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", .upToNextMajor(from: "1.0.0"))
],
targets: [
.target(
name: "CircuitBreaker",
dependencies: ["LoggerAPI"]
),
.testTarget(
name: "CircuitBreakerTests",
dependencies: ["CircuitBreaker"]
)
]
)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Circuit Breaker design pattern is used to increase application stability, im
* [API](#api)

## Swift version
The latest version of CircuitBreaker works with the `3.1.1` version of the Swift binaries. You can download this version of the Swift binaries by following this [link](https://swift.org/download/#releases).
The latest version of CircuitBreaker works with the `3.1.1` and newer version of the Swift binaries. You can download this version of the Swift binaries by following this [link](https://swift.org/download/#releases).

## Installation
To leverage the CircuitBreaker package in your Swift application, you should specify a dependency for it in your `Package.swift` file:
Expand All @@ -28,8 +28,11 @@ To leverage the CircuitBreaker package in your Swift application, you should spe
...

dependencies: [
// Swift 3
.Package(url: "https://github.com/IBM-Swift/CircuitBreaker.git", majorVersion: 2),

// Swift 4
.package(url: "https://github.com/IBM-Swift/CircuitBreaker.git", .upToNextMajor(from: "2.0.0")),
...

])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,11 @@ public class CircuitBreaker<A, B, C> {
resetTimer?.setEventHandler { [weak self] in
self?.forceHalfOpen()
}

resetTimer?.scheduleOneshot(deadline: .now() + delay)
#if swift(>=3.2)
resetTimer?.schedule(deadline: .now() + delay)
#else
resetTimer?.scheduleOneshot(deadline: .now() + delay)
#endif

resetTimer?.resume()
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 7f6fe4c

Please sign in to comment.