Skip to content

Commit

Permalink
v++, improved Heartbeat event
Browse files Browse the repository at this point in the history
  • Loading branch information
Honza Dvorsky committed Sep 17, 2015
1 parent dc7d78d commit 62d88fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ekgclient.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "ekgclient"
s.version = "0.2.3"
s.version = "0.3.0"
s.summary = "Swift SDK for sending events to ekg."

s.description = <<-DESC
Expand Down
5 changes: 4 additions & 1 deletion ekgclient/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ public class Event: Sendable {
public class HeartbeatEvent: Event {

public let uptime: Double
public let numberOfRunningSyncers: Int

public init(uptime: Double) {
public init(uptime: Double, numberOfRunningSyncers: Int) {
self.uptime = uptime
self.numberOfRunningSyncers = numberOfRunningSyncers
super.init(eventType: "heartbeat")
}

public override func jsonify() -> JSON {
var dict = super.jsonify()
dict["uptime"] = self.uptime
dict["running_syncers"] = self.numberOfRunningSyncers
return dict
}
}
Expand Down
2 changes: 1 addition & 1 deletion ekgclientTests/EkgClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ekgclientTests: XCTestCase {
let serverInfo = ServerInfo(host: NSURL(string: "http://localhost:3000")!)
let client = EkgClient(appInfo: appInfo, serverInfo: serverInfo)

let event = HeartbeatEvent(uptime: 10)
let event = HeartbeatEvent(uptime: 10, numberOfRunningSyncers: 1)

client.sendEvent(event) { (error) -> () in
XCTAssertNil(error)
Expand Down
3 changes: 2 additions & 1 deletion ekgclientTests/EventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import XCTest
class EventTests: XCTestCase {

func testHeartbeatEvent_Creation() {
let event = HeartbeatEvent(uptime: 10)
let event = HeartbeatEvent(uptime: 10, numberOfRunningSyncers: 1)
XCTAssertEqual(event.eventType, "heartbeat")
XCTAssertEqual(event.uptime, 10)
XCTAssertEqual(event.numberOfRunningSyncers, 1)
}
}

0 comments on commit 62d88fc

Please sign in to comment.