1. 21 Jun, 2020 1 commit
    • Nathan Harris's avatar
      Rename ELF extension `map` to `tryConverting` and make internal · c4ff3fc3
      Nathan Harris authored
      Motivation:
      
      As originally pointed out in #48, the `map` prefix alone is not enough context into what the method actually does.
      
      Since it fails the future, and isn't a mapping function, the name should reflect this.
      
      But, this method as-is currently provides little value outside of the client context, so it should not be `public`.
      
      If users provide an adequate use case for having it outside of the package, then it can be made public again.
      
      Modifications:
      
      - Rename: ELF where Value == RESPValue extension `map` to `tryConverting`
      - Change: `tryConverting` from public to internal
      
      Result:
      
      A "problematic" method should no longer be available for API users to hurt themselves with.
      c4ff3fc3
  2. 20 Mar, 2020 2 commits
    • Nathan Harris's avatar
      Reduce RESPValue initialization complexities and simplify RedisKey implementation · c1ba6710
      Nathan Harris authored
      Motivation:
      
      `RESPValue` exposes a fair amount of complexity on how to intialize a single instance with the various overloads.
      
      This aims to simplify the complexity for developers by providing a single initializer and relying on `RESPValueConvertible` to handle the complexities.
      
      In addition, the Swift complier synthesizes a lot of default conformances that `RedisKey` has manually written, which is just unnecessary code.
      
      Modifications:
      
      - Rename: `RESPValue.init(_:)` to `RESPValue.init(from:)`
      - Change: `RESPValue.init` `String?` and `FixedWidthInteger` overloads from `public` to `internal`
      - Remove: Unnecessary code for various protocol conformances for `RedisKey`
      
      Result:
      
      Developers should have a direct and guided way of making instances of `RESPValue`
      c1ba6710
    • Nathan Harris's avatar
      Refine Redis Command API · 41f9377d
      Nathan Harris authored
      Motivation:
      
      It was noticed that many of the commands are cumbersome to use with boilerplate type casting for each use that can be simplified within the library
      by doing type conversion before returning the value to an end user.
      
      Modifications:
      
      Many APIs that return a `RESPValue` now have overloads to provide a `RESPValueConvertible` type that the value will be turned into before being returned.
      
      For a few APIs that returned `RESPValue`, they did so as an Optional. Those APIs have been changed to always provide a `RESPValue` and return `.null` in cases where `nil` was returned.
      
      In addition, the `@inlinable` attribute has been removed from any non-generic command API.
      
      Result:
      
      Developers should have less code boilerplate for turning values from `RESPValue` to their desired type with many commands.
      41f9377d
  3. 20 Feb, 2020 1 commit
  4. 31 Dec, 2019 1 commit
    • Nathan Harris's avatar
      Rework SortedSet and List range APIs · 24999985
      Nathan Harris authored
      Motivation:
      
      The SortedSet and List range commands (LTRIM, LRANGE, ZRANGE, etc.) are stringly-based and not flexible with Swift syntax.
      
      Modifications:
      
      - Add overloads of LTRIM that support the gambit of Range Standard Library types
      - Rework LRANGE to mirror LTRIM method signatures
      - Rework ZScore Range based commands to be more type-safe with `RedisZScoreBound` enum
      - Rework ZLex Range based commands to be more type-safe with `RedisZLexBound` enum
      - Rework ZCOUNT, ZLEXCOUNT, ZRANGE, ZREVRANGE, ZREMRANGEBYLEX, ZREMRANGEBYRANK, ZREMRANGEBYSCORE methods to be more type-safe and support Swift Range syntax
      
      Result:
      
      Working with SortedSet ranges should be much more type safe, and expressive with Swift's Range syntax.
      24999985
  5. 28 Dec, 2019 3 commits
    • Nathan Harris's avatar
      Revisit the SortedSet `zadd` command API · 8e3d8f6f
      Nathan Harris authored
      Motivation:
      
      While reviewing the API, the current design does not read well, and still has room for misunderstanding the actual end result of a ZADD operation.
      
      Modifications:
      
      - Rename `RedisSortedSetAddOption` to `RedisZaddInsertBehavior` and update cases to match desired use site syntax.
      - Add `RedisZaddReturnBehavior` enum to define how `zadd` should calculate the return value.
      - Update `zadd` and its overloads to support the two new enums in the form of `zadd(_:to:inserting:returning:)`
      
      Result:
      
      The more "Swifty" API will make it much more clear to developers at the call site what the actual behavior of the ZADD command will be.
      8e3d8f6f
    • Nathan Harris's avatar
      Use `TimeAmount` for any `timeout` command arguments · 1ef315e2
      Nathan Harris authored
      Motivation:
      
      The goal is to have a strong-typed API for type-safety in arbitrary values, such as trying to use
      Int to represent time - as '3' could mean any unit of time, leaving many places for errors and bugs.
      
      Modifications:
      
      Switch all current APIs that accept a `timeout` argument to use `NIO.TimeAmount` instead of a plain `Int`.
      
      Result:
      
      Developers will have an easier time reasoning about their own code as to what values might mean when working with
      timeouts in Redis APIs.
      1ef315e2
    • Nathan Harris's avatar
      Add type-safe representation of Redis keys · ea6f4279
      Nathan Harris authored
      Motivation:
      
      Inspired by Swift by Sundell's article on type-safe identifers, the goal of this commit is to have the compiler
      assist in preventing incorrect Redis key values from being used in API calls.
      
      See https://www.swiftbysundell.com/articles/type-safe-identifiers-in-swift/ for the inspiration.
      
      Modifications:
      
      - Add new `RedisKey` struct that wraps around a single `String` value that conforms to several expected protocols
        (Hashable, Comparable, Codable, etc.)
      - Change all command APIs to require `RedisKey` rather than plain strings
      
      Result:
      
      When encountering an API requiring a RedisKey, it should be much more apparant at the use site what form a value should take.
      ea6f4279
  6. 27 Oct, 2019 1 commit
    • Nathan Harris's avatar
      Add variadic overloads for several commands · adcff650
      Nathan Harris authored
      Motivation:
      
      For ergonomics, users sometimes want to provide arguments as a variadic list rather than an array.
      
      Modifications:
      
      - Add variadic overloads for almost all methods that accept lists of homogenous types
      
      Result:
      
      Users should have more flexibility in the way arguments are passed to command methods
      adcff650
  7. 09 Jul, 2019 3 commits
    • Nathan Harris's avatar
      Iterate on type safety for `zadd` · 0ecb3c1e
      Nathan Harris authored
      Motivation:
      
      Issue #60 called for improving the type safety of the options available for the `zadd` command, and MR !70 made some great headway, but attempted to cram too much into a single enum.
      
      Modifications:
      
      - Break the `RedisSortedSetAddOption.returnChangedCount` value into an additional boolean param
      
      Result:
      
      Using `zadd` should now be more straight forward, while being type safe.
      0ecb3c1e
    • Nathan Harris's avatar
      7e7e3546
    • Nathan Harris's avatar
      Rename `RedisNIOError` to `RedisClientError` · 13432f0c
      Nathan Harris authored
      Motivation:
      
      To make it a little more generic, and to avoid turnover during renames (such as the planned rebranding in issue #61), `RedisClientError` more accurately reflects the source of the errors, as well as the responsibility of causing the bug.
      
      Modifications:
      
      - Rename `RedisNIOError` to `RedisClientError`
      - Rename `RedisError` file to `RedisErrors`
      - Add documentation of `RedisClientError`
      - Remove no longer used `.unsupportedOperation(method:message:)` value
      - Rename `.responseConversion(to:)` to `.failedRESPConversion(to:)`
      
      Result:
      
      Names of `RedisClientError` should be more descriptive, less prone to turnover, and more documented for users to understand the issues related to these thrown errors.
      13432f0c
  8. 04 Jul, 2019 2 commits
    • Nathan Harris's avatar
      60 -- Provide Strong Option Types in SortedSet Commands · 64232992
      Nathan Harris authored
      Motivation:
      
      While working through issue #59, it was noticed just how "stringly" the SortedSet command options for `zadd`, `zinterstore`, and `zunionstore` were, and Swift provides ways of having strong type safety for these options.
      
      Modifications:
      
      - Add `RedisSortedSetAddOption` and `RedisSortedSetAggregateMethod` to replace the String API in `zadd`, `zinterstore`, and `zunionstore`
      - Fix an implication of how `overestimatedCountBeingAdded` documentation for `Array where Element == RESPValue` for `add(contentsOf:overestimatedCountBeingAdded:_:)`
      
      Result:
      
      Users should have a more discoverable and straightforward way that isn't error prone for calling `zadd`, `zinterstore`, and `zunionstore` with Redis supported options.
      64232992
    • Nathan Harris's avatar
      59 -- Use `RESPValueConvertible` as Generic Constraint · fa227b0e
      Nathan Harris authored
      Motivation:
      
      Johannes continues to provide great insight, and correctly pointed out that `RESPValueConvertible` was being used as an "existential" in all cases.
      
      This can cause unexpected type-erasure and introduce unnecessary cost overhead with dynamic dispatch when in most cases we know the exact value we want for `RESPValue` to execute commands.
      
      Modifications:
      
      - Add new extensions to `Array where Element == RESPValue` for appending and adding elements into them
      - Change `RedisClient.send(command:with:)` to require `[RESPValue]` instead of `[RESPValueConvertible]` as the `with` argument type
      - Change all instances of `RESPValueConvertible` being an "existential" type for method arguments to instead be a generic constraint
      
      Result:
      
      The library should be safeguarded from a class of bugs, with the use of `send` being a bit more straight forward, with some new convenience methods for `[RESPValue]` types.
      fa227b0e
  9. 03 Jul, 2019 1 commit
    • Nathan Harris's avatar
      Add `fromRESP` label to `RESPValueConvertible.init` · 60d5c4ce
      Nathan Harris authored
      Motivation:
      
      During SSWG review, feedback was provided on the API design of the `RESPValueConvertible.init` signature and how it should appropriately follow Swift Design Guidelines regarding labels.
      
      Modifications:
      
      `RESPValueConvertible.init(_:` is now `RESPValueConvertible.init(fromRESP:)`.
      
      Result:
      
      There should be more clarity at the call site when initializing a type from a `RESPValue`.
      
      This contributes to #47
      60d5c4ce
  10. 25 Jun, 2019 1 commit
  11. 06 Jun, 2019 1 commit
    • Nathan Harris's avatar
      Rename `NIORedis` to `RedisNIO` · e81f9546
      Nathan Harris authored
      Motivation:
      
      The SSWG has identified a fast approaching reality of namespace clashes in SPM within the ecosystem and has proposed a rule on names that `NIORedis` no longer complies with.
      
      Modifications:
      
      All references to `NIORedis` have been switched to `RedisNIO` as this module name is unique (at least within GitHub's public repositories).
      
      The goals for this name are as follows:
      
      1. To indicate that this is a Redis client library that is built with SwiftNIO
      2. That it is a lower level library, as it directly exposes SwiftNIO as an implementation detail
          2a. The idea being that a higher level library (`Redis`) will be used, and to "go one level deeper" in the stack, you append the "deeper" `NIO` postfix
      3. It follows a naming pattern adopted by Vapor who has expressed their desire to adopt this library as their Redis implementation
      
      Result:
      
      A repository, package name, and module name that are unique across GitHub's public repositories that achives the goals outlined above.
      e81f9546
  12. 27 May, 2019 1 commit
    • Nathan Harris's avatar
      Add Blocking Sorted Set Pop Commands · 73922325
      Nathan Harris authored
      Motivation:
      
      To be a comprehensive library, all commands should be implemented, even if they are highly discouraged. Sorted Set's collection of commands were missing `bzpopmin` and `bzpopmax`.
      
      Modifications:
      
      `bzpopmin` and `bzpopmax` are supported with defaults and overloads for an easier API.
      `RedisClient.channel` is now `internal` to have access during testing for bypassing normal guards for closing connections.
      
      Result:
      
      Users now have access to `bzpopmin` and `bzpopmax` commands.
      73922325
  13. 01 May, 2019 1 commit
  14. 30 Apr, 2019 1 commit
    • Nathan Harris's avatar
      Standardize Error Handling · 46e96bd9
      Nathan Harris authored
      Motivation:
      
      `RedisError` was being used in many places in an ad-hoc fashion that made it unclear as to what source of errors it exactly represents.
      
      In addition, it doesn't follow community conventions of handling known "classes" of errors with enums rather than static struct instances.
      
      Results:
      
      All errors that are generated and thrown within the library are specified as either `RESPDecoder.Error` or `NIORedisError`.
      
      `RedisError` is simplified to represent an error message sent by a Redis instance that conforms to `LocalizedError`.
      46e96bd9
  15. 28 Mar, 2019 1 commit
    • Nathan Harris's avatar
      Simplify `RedisCommandExecutor` and `RedisConnection` · 9f049eb4
      Nathan Harris authored
      Motivation:
      
      `RedisCommandExecutor` was a complex and "wordy" name that was not 100% clear as to how it relates to other types.
      
      `RedisConnection` also has not had a strong use case shown for it to exists as a separate protocol - using up a great name for the "out of the box" implementation.
      
      Result:
      
      `RedisClient` instead of `RedisCommandExecutor` is more clear as to what it is, in Redis terminology, a communication client.
      
      `RedisConnection` as a concrete class provides an identifiable basic block for making connections to Redis.
      
      `RedisConnection` also saw some fixes to `close()` while having some names and comment blocks tweaked for updated naming.
      9f049eb4
  16. 25 Mar, 2019 1 commit
  17. 24 Mar, 2019 1 commit