Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed build warnings #29

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/BenchmarkPubSub/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ try await withThrowingTaskGroup(of: Void.self) { group in
for await msg in sub {
let payload = msg.payload!
if String(data: payload, encoding: .utf8) != "\(i)" {
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8))")
let emptyString = ""
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8) ?? emptyString)")
}
guard let headers = msg.headers else {
print("empty headers!")
Expand All @@ -38,6 +39,7 @@ try await withThrowingTaskGroup(of: Void.self) { group in
if i%1000 == 0 {
print("received \(i) msgs")
}
i += 1
}
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/BenchmarkSub/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ for i in 1...numMsgs {
continue
}
if String(data: payload, encoding: .utf8) != "\(i)" {
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8))")
let emptyString = ""
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8) ?? emptyString)")
}
guard let headers = msg?.headers else {
guard msg?.headers != nil else {
print("empty headers!")
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/NatsSwift/Extensions/Data+Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ extension Data {
if let headersString = String(data: headersData, encoding: .utf8) {
let headersArray = headersString.split(separator: "\r\n")
// TODO: unused now, but probably we should validate?
let versionLine = headersArray[0]
// let versionLine = headersArray[0]

for header in headersArray.dropFirst() {
let headerParts = header.split(separator: ":")
Expand Down
2 changes: 1 addition & 1 deletion Sources/NatsSwift/NatsConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class ConnectionHandler: ChannelInboundHandler {
}

func writeMessage(_ message: ByteBuffer) throws {
channel?.write(message)
_ = channel?.write(message)
if channel?.isWritable ?? true {
channel?.flush()
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/NatsSwiftTests/Integration/ConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CoreNatsTests: XCTestCase {
expectation.fulfill()
}
}
wait(for: [expectation], timeout: 5.0)
await fulfillment(of: [expectation], timeout: 5.0)
await sub.complete()
}

Expand All @@ -67,7 +67,7 @@ class CoreNatsTests: XCTestCase {
expectation.fulfill()
}
}
wait(for: [expectation], timeout: 5.0)
await fulfillment(of: [expectation], timeout: 5.0)
await sub.complete()
}

Expand Down Expand Up @@ -170,7 +170,7 @@ class CoreNatsTests: XCTestCase {
try await client.connect()
try client.publish("msg".data(using: .utf8)!, subject: "test")
try await client.flush()
try await client.subscribe(to: "test")
_ = try await client.subscribe(to: "test")
XCTAssertNotNil(client, "Client should not be nil")


Expand Down Expand Up @@ -207,7 +207,7 @@ class CoreNatsTests: XCTestCase {
try await client.connect()
try client.publish("msg".data(using: .utf8)!, subject: "test")
try await client.flush()
try await client.subscribe(to: "test")
_ = try await client.subscribe(to: "test")
XCTAssertNotNil(client, "Client should not be nil")


Expand Down
Loading