1. 18 Sep, 2020 1 commit
  2. 08 Sep, 2020 1 commit
  3. 01 Sep, 2020 2 commits
    • Nathan Harris's avatar
      Update contributors · 8fb1aed7
      Nathan Harris authored
      8fb1aed7
    • Nathan Harris's avatar
      Refactor Logging implementation · 90244e32
      Nathan Harris authored
      Motivation:
      
      The original implementation of Logging was done in more haste than should have been, without proper attention given to the semantic requirements.
      
      As the Swift ecosystem has matured a bit, lessons have been learned on handling metadata and passing of external context into internal subcomponents.
      
      A mixture of the "protocol-based context passing" and "explicit context passing" patterns have been adopted.
      
      Both patterns are more fully described in the Swift forum discussion: https://forums.swift.org/t/the-context-passing-problem/39162
      
      Modifications:
      
      - Add: `RedisLogging` namespace with references to static keys and labels that are used for Logging throughout the library
      - Add: `Logger` static computed properties to access the Logger prototypes used in connection and connection pools
      - Add: `RedisClientWithUserContext` protocol and `UserContextRedisClient` types to assist with wrapping client types for custom logger contexts
      - Remove: `logger` property from `RedisClient` requirements
      - Change: Many log statements to have higher or lower log levels for their appropriate context
      - Change: `RedisConnection` and `RedisConnectionPool` to conform to `RedisClientWithUserContext`
      - Change: `logging(to:)` protocol requirement to return a `RedisClient` existential
      - Change: ConnectionPool to explicitly pass a logger instance around for pooling methods
      
      Result:
      
      Logging in RediStack will now have a stronger contract of where and how logs will be generated and which context will be used.
      
      Fixes #79 and #74
      90244e32
  4. 30 Aug, 2020 6 commits
  5. 09 Aug, 2020 1 commit
  6. 05 Aug, 2020 1 commit
    • tanner's avatar
      Add optional promise parameter to RedisConnectionPool.close · 40d1a587
      tanner authored
      Motivation:
      
      The actual process for closing a connection pool involves closing each individual connection, which is all asynchronous.
      
      There is currently no way to work off of the event when all of the connections have completed their close process.
      
      Modifications:
      
      - Add: `poolHasActiveConnections` error value to `RedisConnectionPoolError`
      - Add: `promise` parameter to the `RedisConnectionPool.close` method
      - Add: Documentation comments for the close method
      
      Result:
      
      Developers should now have a way of chaining callbacks when all connections in a pool have been closed.
      40d1a587
  7. 02 Aug, 2020 2 commits
  8. 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
  9. 04 Jun, 2020 5 commits
    • Nathan Harris's avatar
      Update contributors · 8b75ef7f
      Nathan Harris authored
      8b75ef7f
    • Nathan Harris's avatar
      Convert `RESPTranslator.ParsingError` from enum to struct · b48b4729
      Nathan Harris authored
      Motivation:
      
      Much like the change for `RedisClientError` (6471a2) any error enum that we may want to change will necessitate a major SemVer.
      
      To avoid this, we need to use the established struct-as-enum pattern.
      
      Modifications:
      
      - Change: `RESPTranslator.ParsingError` to be a struct backed by an enum
      
      Result:
      
      The library should be able to evolve to add more `RESPTranslator.ParsingError` cases without becoming a breaking change.
      b48b4729
    • George Barnett's avatar
      Add SETEX and PSETEX commands · e7b451c4
      George Barnett authored
      Motivation:
      
      The SETEX and PSETEX commands are missing.
      
      Modifications:
      
      - Add SETEX command
      - Add PSETEX command
      - Add integration tests
      
      Result:
      
      Users can atomically set a key with an expire
      e7b451c4
    • George Barnett's avatar
      Add SET options · ddfc7b0a
      George Barnett authored
      Motivation:
      
      SET has a range of options for setting expirations and conditionally
      setting a value.
      
      Modification:
      
      - Add another `set` function with a range of options. Options are
        modelled as `struct`s backed by private `enum`s to allow additional
        options to be added without breaking API.
      - Added tests
      
      Result:
      
      Options may be specified with `set`, and resolves #67
      ddfc7b0a
    • George Barnett's avatar
      Replace usage of @_specialize with @inlinable · 5749215e
      George Barnett authored
      Motivation:
      
      - Newer compilers warn that "'exported: true' has no effect in
        '_specialize' attribute"
      - Specialize is underscored so (probably) shouldn't be relied upon
        outside of the stdlib
      
      Modifications:
      
      - Replace @_specialize with @inlinable
      
      Result:
      
      Fewer warnings on more recent compilers
      5749215e
  10. 03 Jun, 2020 2 commits
    • Lukasa's avatar
      Implement a simple Redis Connection Pool. · 5dbd716a
      Lukasa authored
      Motivation:
      
      Users of Redis will frequently want to be able to run queries in
      parallel, while bounding the number of connections they use. They will
      also often want to be able to reuse connections, without having to
      arrange to manage those connections themselves. These are jobs usually
      done by a Connection Pool.
      
      This new connection pool will conform to `RedisClient` so a pool of clients and a single connection are interchangeable.
      
      Connection Pools come in a wide range of shapes and sizes. In NIO
      applications and frameworks, there are a number of questions that have
      to be answered by any pool implementation:
      
      1. Is the pool safe to share across EventLoops: that is, is its
         interface thread-safe?
      2. Is the pool _tied_ to an EventLoop: that is, can the pool return
         connections that belong on lots of event loops, or just one?
      3. If the pool is not tied to an EventLoop, is it possible to influence
         its choice about what event loop it uses for a given connection?
      
      Question 1 is straightforward: it is almost always a trivial win to
      ensure that the public interface to a connection pool is thread-safe.
      NIO makes it possible to do this fairly cheaply in the case when the
      pool is only used on a single loop.
      
      Question 2 is a lot harder. Pools that are not tied to a specific
      EventLoop have two advantages. The first is that it is easier to bound
      maximum concurrency by simply configuring the pool, instead of needing
      to do math on the number of pools and the number of event loops. The
      second is that non-tied pools can arrange to keep busy applications
      close to this maximum concurrency regardless of how the application
      spreads its load across loops.
      
      However, pools that are tied to a specific EventLoop have advantages
      too. The first is one of implementation simplicity. As they always serve
      connections on a single EventLoop, they can arrange to have all of their
      state on that event loop too. This avoids the need to acquire locks on
      that loop, making internal state management easier and more obviously
      correct without having to worry about how long locks are held for.
      
      The second advantage is that they can be used for latency sensitive
      use-cases without needing to go to the work of (3). In cases where
      latency is very important, it can be valuable to ensure that any Channel
      that needs a connection can get one on the same event loop as itself.
      This avoids the need to thread-hop in order to communicate between the
      pooled connection and the user connection, reducing the latency of
      operations.
      
      Given the simplicity and latency benefits (which we deem particularly
      important for Redis use-cases), we concluded that a good initial
      implementation will be a pool that has a thread-safe interface, but is
      tied to a single EventLoop. This allows a compact, easy-to-verify
      implementation of the pool with great low-latency performance and simple
      implementation logic, that can still be accessed from any EventLoop in
      cases when latency is not a concern.
      
      Modifications:
      
      - Add new internal `ConnectionPool` object
      - Add new `RedisConnectionPool` object
      - Add new `RedisConnectionPoolError` type
      - Add tests for new types
      
      Results:
      
      Users will have access to a pooled Redis client.
      5dbd716a
    • George Barnett's avatar
      Make `RedisKey` `ExpressibleByStringInterpolation` · 95ce2cd1
      George Barnett authored
      Motivation:
      
      `RedisKey` is `ExpressibleByStringLiteral` but not
      `ExpressibleByStringInterpolation` which is often just as useful.
      
      Modifications:
      
      - Add `ExpressibleByStringInterpolation` conformance to `RedisKey`
      
      Result:
      
      Users can create `RedisKey`s using string interpolation
      95ce2cd1
  11. 02 Jun, 2020 1 commit
    • George Barnett's avatar
      Add SETNX command · 4b06ece0
      George Barnett authored
      Motivation:
      
      The SETNX command is missing.
      
      Modifications:
      
      - Add SETNX command
      - Add integration test
      
      Result:
      
      Users can set a key only if it does not already exist
      4b06ece0
  12. 01 Jun, 2020 1 commit
    • Nathan Harris's avatar
      Change `RedisClientError` from enum to struct · 06471a2a
      Nathan Harris authored
      Motivation:
      
      The current state of Swift does not leave room for library evolution of enum types used for `Error`.
      
      To avoid having to increment Major SemVer to add a new error case that might be needed to fix a bug, the `enum-like struct` idiom should be used.
      
      Ideally this idiom will disappear, when Swift provides a way for Swift Packages to have a "library evolution" capability.
      
      See https://forums.swift.org/t/extensible-enumerations-for-non-resilient-libraries/35900
      
      Modifications:
      
      - Change: `RedisClientError` to be struct with private enum value
      
      Result:
      
      Should new error cases be necessary to add, they can be in Minor SemVer releases, rather than Major SemVer.
      06471a2a
  13. 29 May, 2020 3 commits
    • George Barnett's avatar
      Update URLs from swift-redi-stack to RediStack · 60e79b71
      George Barnett authored
      Motivation:
      
      The project was moved from Mordil/swift-redi-stack to Mordil/RediStack;
      some URLs still point to swift-redi-stack.
      
      Modifications:
      
      - Update URLs in README and CHANGELOG
      
      Result:
      
      More accurate URLs; fewer warnings from GitLab :)
      60e79b71
    • George Barnett's avatar
      Add TTL and PTTL commands · 4cd58557
      George Barnett authored
      Motivation:
      
      The TTL and PTTL commands are missing.
      
      Modifications:
      
      - Add TTL and PTTL commands
      - Add integration tests
      
      Result:
      
      - Users can query the ttl in seconds or milliseconds of a key
      4cd58557
    • George Barnett's avatar
      Add EXISTS command · 123d9c94
      George Barnett authored
      Motivation:
      
      The EXISTS command was missing.
      
      Modifications:
      
      - Add 'EXISTS' to basic commands
      - Add integration tests
      
      Result:
      
      The existence of a key can be checked.
      123d9c94
  14. 27 May, 2020 2 commits
    • Lukasa's avatar
      Detect and throw on invalid integer. · 2211dbf3
      Lukasa authored
      Motivation:
      
      parseInteger did not distinguish between not having enough bytes for an
      integer and not being able to parse the integer that was present. This
      was a bit tricky for code internally, where some call sites had extra
      code looking for spooky action at a distance in order to determine if
      the integer failed to parse.
      
      This is unnecessary: parseInteger is sufficiently aware of what's going
      on to address this problem itself.
      
      Modifications:
      
      - Added a new parser error (acceptable as we haven't tagged 1.0 yet).
      - Throw it from parseInteger if the integer is invalid.
      
      Result:
      
      parseInteger clearly communicates if the integer failed to parse.
      2211dbf3
    • Lukasa's avatar
      Clean up indexing of ByteBufferView · 638fbb07
      Lukasa authored
      Motivation:
      
      ByteBufferView is not zero indexed, but parseSimpleString assumes it is.
      
      Modifications:
      
      - Correctly compute on the distance between two indices.
      - New, somewhat contrived, test case.
      
      Result:
      
      No functional change: because RediStack assumes the remote peer will
      always correctly terminate with /r/n, there is no point at which this
      code could misbehave in the current implementation. However, with small
      changes it is possible to trigger it, as the new test demonstrates.
      638fbb07
  15. 26 May, 2020 2 commits
    • Lukasa's avatar
      Avoid creating temporary arrays · f9579373
      Lukasa authored
      Motivation:
      
      When we only want the first byte, rather than create temporary
      intermediate arrays we can just ask NIO to give us the first byte. This
      avoids unnecessary allocations.
      
      Modifications:
      
      - Replace `readBytes(length: 1).first` with `readInteger(as:
        UInt8.self)`
      
      Results:
      
      11% performance improvement in load testing due to reduced allocator
      pressure on the hot path.
      f9579373
    • Lukasa's avatar
      Avoid transient ByteBufferView · dd086855
      Lukasa authored
      Motivation:
      
      When attempting to locate a single byte, creating a transient
      ByteBufferView is an excessively heavyweight operation compared to a
      simple getInteger. In particular, a BBV requires retain/release
      operations to enforce the CoW invariants, as well as requires jumps
      through substantial amounts of generic Collection code. While this can
      be specialized, so can getInteger, and getInteger has much less code in
      the way to cause costs.
      
      Modifications:
      
      - Replace temporary view creation with getInteger.
      
      Results:
      
      5% performance improvement on raw throughput tests.
      dd086855
  16. 08 May, 2020 2 commits
  17. 24 Apr, 2020 1 commit
  18. 20 Apr, 2020 1 commit
  19. 27 Mar, 2020 2 commits
  20. 20 Mar, 2020 3 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
    • Nathan Harris's avatar
      Move GitLab CI files to .gitlab · 543e27bd
      Nathan Harris authored
      543e27bd