Skip to content

Commit 5ac0671

Browse files
committed
Bump to 1.2.0
1 parent 53fa726 commit 5ac0671

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CHANGELOG
22

3-
2015-05-04 1.2.0
3+
2015-06-08 1.2.0
44
* new retry logic
55
* add new parameter on the Query: setMinProximity & setHighlightingTags
66
* add new method on the Query: resetLocationParameters

Source/Client.swift

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public class Client {
7474
/// :param: apiKey a valid API key for the service
7575
/// :param: tagFilters value of the header X-Algolia-TagFilters
7676
/// :param: userToken value of the header X-Algolia-UserToken
77-
public init(appID: String, apiKey: String, tagFilters: String? = nil, userToken: String? = nil) {
77+
/// :param: hostnames the list of hosts that you have received for the service
78+
public init(appID: String, apiKey: String, tagFilters: String? = nil, userToken: String? = nil, hostnames: [String]? = nil) {
7879
if count(appID) == 0 {
7980
NSException(name: "InvalidArgument", reason: "Application ID must be set", userInfo: nil).raise()
8081
} else if count(apiKey) == 0 {
@@ -86,20 +87,25 @@ public class Client {
8687
self.tagFilters = tagFilters
8788
self.userToken = userToken
8889

89-
readQueryHostnames = [
90-
"\(appID)-DSN.algolia.net",
91-
"\(appID)-1.algolianet.com",
92-
"\(appID)-2.algolianet.com",
93-
"\(appID)-3.algolianet.com"
94-
]
95-
96-
writeQueryHostnames = [
97-
"\(appID).algolia.net",
98-
"\(appID)-1.algolianet.com",
99-
"\(appID)-2.algolianet.com",
100-
"\(appID)-3.algolianet.com"
101-
]
102-
90+
if let hostnames = hostnames {
91+
readQueryHostnames = hostnames
92+
writeQueryHostnames = hostnames
93+
} else {
94+
readQueryHostnames = [
95+
"\(appID)-DSN.algolia.net",
96+
"\(appID)-1.algolianet.com",
97+
"\(appID)-2.algolianet.com",
98+
"\(appID)-3.algolianet.com"
99+
]
100+
101+
writeQueryHostnames = [
102+
"\(appID).algolia.net",
103+
"\(appID)-1.algolianet.com",
104+
"\(appID)-2.algolianet.com",
105+
"\(appID)-3.algolianet.com"
106+
]
107+
}
108+
103109
let version = NSBundle(forClass: self.dynamicType).infoDictionary!["CFBundleShortVersionString"] as! String
104110

105111
var HTTPHeaders = [
@@ -179,7 +185,7 @@ public class Client {
179185

180186
/// Return 10 last log entries.
181187
public func getLogs(block: CompletionHandler) {
182-
performHTTPQuery("1/logs", method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
188+
performHTTPQuery("1/logs", method: .GET, body: nil, hostnames: writeQueryHostnames, block: block)
183189
}
184190

185191
/// Return last logs entries.

Source/Extension.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@
2323

2424
import Foundation
2525

26-
extension Array {
27-
/// Shuffle the array
28-
mutating func shuffle() {
29-
for i in 0..<(count - 1) {
30-
let j = Int(arc4random_uniform(UInt32(count - i))) + i
31-
swap(&self[i], &self[j])
32-
}
33-
}
34-
}
35-
3626
extension String {
3727
/// Return URL encoded version of the string
3828
func urlEncode() -> String {

0 commit comments

Comments
 (0)