1. 17 Aug, 2021 1 commit
  2. 05 May, 2021 3 commits
  3. 27 Nov, 2020 1 commit
    • Nathan Harris's avatar
      Rename RedisKeyLifetime to be nested in RedisKey · 8bf26fb6
      Nathan Harris authored
      `RedisKeyLifetime` already has "RedisKey" as a prefix so it naturally fits as a nested type.
      - Change: `RedisKeyLifetime` to be nested in `RedisKey` and named `Lifetime`
      - Rename: `RedisKeyLifetime.Lifetime` to `Duration`
      - Deprecate: `RedisKeyLifetime` and the nested type `Lifetime`
      The global namespace is a little less cluttered with the types falling naturally where they already are.
  4. 22 Nov, 2020 3 commits
  5. 18 Oct, 2020 1 commit
  6. 17 Oct, 2020 2 commits
    • Nathan Harris's avatar
      Change RedisConnection to end subscriptions when not allowed · 61cc879e
      Nathan Harris authored
      When `RedisConnection.allowSubscriptions` is set to `false`, the connection could still be in a subscription state
      leaving further commands to fail slowly from a full roundtrip to Redis, rather than succeeding as expected.
      This changes the implementation so that it triggers a full unsubscribe from patterns and channels when set to `false`.
      - Change: `RedisConnection.allowSubscriptions` to call `unsubscribe()` and `punsubscribe()` when set to `false`
      - Change: `RedisPubSubHandler` to prefix storage of all dictionary keys to avoid name clashes between pattern and channel subscriptions
      Developers should now have more deterministic and unsurprising behavior with PubSub
      in regards to subscription management and connection state.
    • Nathan Harris's avatar
      Fix [p]unsubscribe from all · e0d47f73
      Nathan Harris authored
      The methods of unsubscribing from all channels / patterns were not working as expected as they need to be special-case handled.
      - Change: `RedisPubSubHandler` to be special-case unsubscribe when no arguments are provided
      Developers should now properly be able to unsubscribe from all channels / patterns with a single method call.
  7. 15 Oct, 2020 1 commit
    • Nathan Harris's avatar
      Allow repeated commands to same connection in pool · 42e8d4b1
      Nathan Harris authored
      Some Redis commands are very connection specific that have impacts on future access that makes it difficult in the current
      checkout-use-return cycle that `RedisConnectionPool` uses.
      Developers need a way to borrow a specific connection, chain several commands together, and then return the connection to the pool.
      - Add: `leaseConnection` method to `RedisConnectionPool` which provides a connection from the pool and returns it after a provided closure's ELF resolves
      - Add: `allowSubscriptions` property to `RedisConnection` for controlling the ability to make PubSub subscriptions
      - Add: `RedisClientError.pubsubNotAllowed` case for when `RedisConnection.allowSubscriptions` is set to `false` and a subscription was still attempted
      Developers should now have an "escape hatch" with `RedisConnectionPool` to do limited exclusive chains of operations on a specific connection.
  8. 07 Oct, 2020 3 commits
    • Nathan Harris's avatar
    • Nathan Harris's avatar
      Add default buffer connectionRetryTimeout to avoid literal immediate timeouts · c8cb256b
      Nathan Harris authored
      When trying to allow users to configure the connection retry timeout offset,
      not having a value provided (deadline of `now`) caused all attempts to use the pool to fail.
      - Change: RedisConnectionPool to always have a timeout offset defined
      If users don't specify any value, then the default of 60 seconds will be used.
      If users specify "nil" (or `.none`) as the timeout, then a minimum of 10 milliseconds will be used to avoid immediate timeouts
      Otherwise, use the user's specified `TimeAmount` as the offset of the timeout
    • Nathan Harris's avatar
      Add configuration option for RedisConnectionPool lease timeout · 3e28e75b
      Nathan Harris authored
      With RedisConnectionPool a timeout is provided to prevent infinite loops of
      retrying connections, but right now it is hardcoded to 60 seconds.
      Users of downstream projects such as Vapor are noticing a "regression" of sorts, as previously
      EventLoopFutures would fail immediately if a connection was not made available.
      - Add: `connectionRetryTimeout` parameter to `RedisConnectionPool` initializer that still defaults to 60 seconds
      - Change: RedisConnectionPool to use the new parameter if available to offset a deadline from "now"
      Users can now configure the connection pool to fail immediately if connections are not available.
  9. 02 Oct, 2020 1 commit
    • Nathan Harris's avatar
      Resolve PubSub post-commit feedback · e858c0a6
      Nathan Harris authored
      To ship PubSub faster, it was merged to the master branch without a peer review. This commit is to address the critical points of feedback given in a post-commit review.
      - Add: New RedisClientError case where a "race condition" of removing a pubsub handler and subscription can happen
      - Add: New state to RedisPubSubHandler for when it has been removed from a ChannelPipeline
      - Change: RedisPubSubHandler to require an `eventLoop` in its initializer
      - Change: The subscribe and unsubscribe methods on RedisPubSubHandler to handle the EventLoop hopping to be thread-safe
      PubSub should have a more robust and thread-safe implementation.
  10. 30 Sep, 2020 1 commit
    • Nathan Harris's avatar
      Add support for PubSub · e7b597fc
      Nathan Harris authored
      One of the great features of Redis is being able to subscribe and receive messages published to specific channels
      as a way of acting as a message queue for processing jobs.
      PubSub requires a specific understanding of the connection model that can only be implemented directly in this library.
      - Add: `RedisPubSubHandler` to sit in front of `RedisCommandHandler` to manage subscription callbacks and Redis registration
      - Add: `publish` and the `pubsub` commands
      - Add: `addPubSubHandler` extension to `NIO.Channel`
      - Add: Type-safe String wrapper of `RedisChannelName` for PubSub methods
      - Add: `pubsubSubscriptionNotFound` error case
      - Add: `isSubscribed` property to `RedisConnection`
      - Add: `availableConnectionCount` and `leasedConnectionCount` properties to `RedisConnectionPool`
      - Add: Metrics for PubSub
      - Add: `makeNewPool` factory method to `RedisConnectionPoolIntegrationTestCase`
      - Change: `RedisClient` to require methods for PubSub management, as they are intrinsicly tied to the client's connection model
      - Change: Parsing of `PING` response for handling special case in PubSub mode
      - Rename: `ActiveConnectionGauge` to `RedisMetrics.IncrementalGauge`
      Developers will now be able to use Redis in PubSub mode with both connections and pools.
      This resolves #6
  11. 18 Sep, 2020 1 commit
  12. 08 Sep, 2020 1 commit
  13. 01 Sep, 2020 2 commits
    • Nathan Harris's avatar
      Update contributors · 8fb1aed7
      Nathan Harris authored
    • Nathan Harris's avatar
      Refactor Logging implementation · 90244e32
      Nathan Harris authored
      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
      - 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 `Red...
  14. 30 Aug, 2020 6 commits
  15. 09 Aug, 2020 1 commit
  16. 05 Aug, 2020 1 commit
    • tanner's avatar
      Add optional promise parameter to RedisConnectionPool.close · 40d1a587
      tanner authored and Nathan Harris's avatar Nathan Harris committed
      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.
      - Add: `poolHasActiveConnections` error value to `RedisConnectionPoolError`
      - Add: `promise` parameter to the `RedisConnectionPool.close` method
      - Add: Documentation comments for the close method
      Developers should now have a way of chaining callbacks when all connections in a pool have been closed.
  17. 02 Aug, 2020 2 commits
  18. 21 Jun, 2020 1 commit
    • Nathan Harris's avatar
      Rename ELF extension `map` to `tryConverting` and make internal · c4ff3fc3
      Nathan Harris authored
      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.
      - Rename: ELF where Value == RESPValue extension `map` to `tryConverting`
      - Change: `tryConverting` from public to internal
      A "problematic" method should no longer be available for API users to hurt themselves with.
  19. 04 Jun, 2020 5 commits
    • Nathan Harris's avatar
      Update contributors · 8b75ef7f
      Nathan Harris authored
    • Nathan Harris's avatar
      Convert `RESPTranslator.ParsingError` from enum to struct · b48b4729
      Nathan Harris authored
      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.
      - Change: `RESPTranslator.ParsingError` to be a struct backed by an enum
      The library should be able to evolve to add more `RESPTranslator.ParsingError` cases without becoming a breaking change.
    • George Barnett's avatar
      Add SETEX and PSETEX commands · e7b451c4
      George Barnett authored
      The SETEX and PSETEX commands are missing.
      - Add SETEX command
      - Add PSETEX command
      - Add integration tests
      Users can atomically set a key with an expire
    • George Barnett's avatar
      Add SET options · ddfc7b0a
      George Barnett authored and Nathan Harris's avatar Nathan Harris committed
      SET has a range of options for setting expirations and conditionally
      setting a value.
      - 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
      Options may be specified with `set`, and resolves #67
    • George Barnett's avatar
      Replace usage of @_specialize with @inlinable · 5749215e
      George Barnett authored
      - 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
      - Replace @_specialize with @inlinable
      Fewer warnings on more recent compilers
  20. 03 Jun, 2020 2 commits
    • Lukasa's avatar
      Implement a simple Redis Connection Pool. · 5dbd716a
      Lukasa authored and Nathan Harris's avatar Nathan Harris committed
      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
      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.
      - Add new internal `ConnectionPool` object
      - Add new `RedisConnectionPool` object
      - Add new `RedisConnectionPoolError` type
      - Add tests for new types
      Users will have access to a pooled Redis client.
    • George Barnett's avatar
      Make `RedisKey` `ExpressibleByStringInterpolation` · 95ce2cd1
      George Barnett authored and Nathan Harris's avatar Nathan Harris committed
      `RedisKey` is `ExpressibleByStringLiteral` but not
      `ExpressibleByStringInterpolation` which is often just as useful.
      - Add `ExpressibleByStringInterpolation` conformance to `RedisKey`
      Users can create `RedisKey`s using string interpolation
  21. 02 Jun, 2020 1 commit
    • George Barnett's avatar
      Add SETNX command · 4b06ece0
      George Barnett authored
      The SETNX command is missing.
      - Add SETNX command
      - Add integration test
      Users can set a key only if it does not already exist