Skip to content

Conversation

natanrolnik
Copy link
Contributor

While working on a sample project, I found it was really hard to parse the response of the SCAN and KEYS commands.

After talking to @adam-fowler, he told me about the RESPTokenDecodable protocol, which makes it really easy to implement type safe responses, so I added them.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@9b1ec4a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...Valkey/Commands/Custom/GenericCustomCommands.swift 0.00% 5 Missing ⚠️
Sources/Valkey/Commands/GenericCommands.swift 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #244   +/-   ##
=======================================
  Coverage        ?   39.51%           
=======================================
  Files           ?       93           
  Lines           ?    15721           
  Branches        ?        0           
=======================================
  Hits            ?     6212           
  Misses          ?     9509           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

```swift
let valkeyClient = ValkeyClient(.hostname("localhost", port: 6379), logger: logger)
try await withThrowingTaskgroup(of: Void.self) { group in
try await withThrowingTaskGroup(of: Void.self) { group in
Copy link

@freak4pc freak4pc Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:chefs-kiss:

Suggested change
try await withThrowingTaskGroup(of: Void.self) { group in
try await withThrowingDiscardingTaskGroup { group in

public let keys: [ValkeyKey]

public init(fromRESP token: RESPToken) throws {
let (cursor, keys) = try token.decodeArrayElements(as: (Int, [ValkeyKey]).self)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use (self.cursor, self.keys) = .... You don't need the temporary variables.

Copy link
Collaborator

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants