Commit Graph

376 Commits

Author SHA1 Message Date
Joannis Orlandos 1d2a42b132 Merge branch 'main' into docs/jo/test-table 2023-06-18 14:02:39 +02:00
Joannis Orlandos cde56f6a19 Update the tests table, in accordance with CI and my local development setup 2023-06-18 14:01:30 +02:00
Fabian Fett 60021f99bc Remove codeclimate (#55) 2023-06-16 11:11:58 -07:00
Fabian Fett 4bdcd203fc Remove github funding and issue and pr template (#53) 2023-06-16 20:01:56 +02:00
Fabian Fett a0e908845e Cherry pick: Explicitly depend on Atomics (#57) 2023-06-16 19:55:58 +02:00
Fabian Fett 10a5c3949e Add soundness and api breakage CI (#58) 2023-06-16 19:50:46 +02:00
Fabian Fett 35e0d67e84 Fix crash in tests: Use explicit RedisCommand instead of tuple (#52) 2023-06-16 19:15:42 +02:00
Fabian Fett a7d196e813 Add swift-server CI (#54) 2023-06-16 18:37:34 +02:00
Marius Seufzer 43d94452a8 call onUnexpectedConnectionClose on closeFuture 1.4.1 2023-06-13 11:34:05 +02:00
Marius Seufzer 2fd4db68e9 fix compiler error for pre 5.7 swift versions 2023-06-12 13:19:09 +02:00
Nathan Harris 0862006557 [Misc] Update contributors list 1.4.0 2023-06-10 09:44:14 -05:00
Marius Seufzer 5875335e08 Add onUnexpectedConnectionClose callback to pool
Backports `onUnexpectedConnectionClose` on the pool to 1.x
2023-06-09 18:58:21 +00:00
Gwynne Raskind 3bd5940b07 Make the parameter-less RedisClientError factory statics computed properties. As stored properties, they trigger Thread Sanitizer errors when multiple connections trigger the same errors (usually connectionClosed) too close together due to lazy once-only initialization. 1.3.3 2023-05-27 21:56:49 -05:00
Nathan Harris 254e3e78b3 Add support for Swift Package Index documentation hosting
This is a cherry-pick of commit 4e2217cffd
1.3.2
2023-01-19 22:40:08 -06:00
Nathan Harris 4ed1aa5596 [Misc] Update contributors 2022-12-12 21:32:30 -06:00
Fabian Fett c85f857554 Add support for graceful shutdown to the RedisCommandHandler 2022-12-07 17:15:42 +01:00
Nathan Harris b5c0bc8e05 Bump minimum supported Swift version to 5.5
## Motivation

RediStack 1.x is going to be supported at least until 2.x is released, which is a few months away.

Developers who are on later versions of Swift will adopt later versions of NIO and other libraries, and after we merged !183 we required NIO 2.42.x which has a minimum Swift version of 5.5

## Changes

This back ports the CI config from `master` into this branch, with updates to the README to reflect the changes
2022-11-30 21:35:43 -06:00
Michael Stegeman 68ccc40414 Switch from NIOAtomic to ManagedAtomic. 2022-11-30 14:29:30 +01:00
Fabian Fett ff495ef0d8 Fix NIOLock warning
# Conflicts:
#	Package.swift
#	Sources/RediStack/RedisConnection.swift
2022-11-26 14:02:12 +01:00
Nathan Harris 5458d6476e Backdeploy #100 fix and deprecate Channel Redis pipeline APIs
This is a backdeploy of commit cfb99ba0f7.

This fixes issue #100
1.3.0
2022-04-23 22:58:39 -05:00
Nathan Harris ad435902f2 Update deprecation annotations to support "fixit" helpers in Xcode 2022-04-23 22:43:49 -05:00
Nathan Harris b277715a02 104 -- Use correct base method for zrevrange overload methods 1.2.2 2022-03-14 23:08:14 -05:00
Nathan Harris 16037bbb82 102 -- Remove usage of deprecated NIO ELF APIs 1.2.1 2022-01-03 12:42:58 -06:00
Nathan Harris 0c3beee7eb 95 -- Backport unexpected channel closure callback
This is a cherry-pick commit of ad316a97ac
1.2.0
2021-08-16 22:01:25 -07:00
Nathan Harris edadec93a1 Get pubsub numsub working
This was a cherry-pick of 3ca471b226
1.1.2
2021-05-04 20:59:50 -07:00
Nathan Harris a0af03c534 Get pubsub numpat working
This was a cherry-pick of e08b42616b

Only the unit test was needed to be back-ported
2021-05-04 20:58:33 -07:00
Nathan Harris 5f758ba866 Fix pubsub channels
This was a cherry-pick of 9958e2d13b

Only the unit test was needed to be back-ported
2021-05-04 20:57:32 -07:00
Nathan Harris 8bf26fb661 Rename RedisKeyLifetime to be nested in RedisKey
Motivation:

`RedisKeyLifetime` already has "RedisKey" as a prefix so it naturally fits as a nested type.

Modifications:

- Change: `RedisKeyLifetime` to be nested in `RedisKey` and named `Lifetime`
- Rename: `RedisKeyLifetime.Lifetime` to `Duration`
- Deprecate: `RedisKeyLifetime` and the nested type `Lifetime`

Result:

The global namespace is a little less cluttered with the types falling naturally where they already are.
2020-11-27 14:05:14 -08:00
Nathan Harris b2367ac33e 81 -- Add Configuration types for initialization 1.1.0 2020-11-22 00:17:22 -08:00
Nathan Harris ec1a38ba7f Update README to clarify Swift version support and update process 2020-11-22 03:53:14 +00:00
Nathan Harris 02ab82c1ac Update README to have latest correct information regarding versions 2020-11-22 03:45:14 +00:00
Nathan Harris 833fc33881 Fix RedisConnectionPool.leaseConnection code example 2020-10-18 18:48:46 +00:00
Nathan Harris 61cc879efe Change RedisConnection to end subscriptions when not allowed
Motivation:

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`.

Modifications:

- 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

Result:

Developers should now have more deterministic and unsurprising behavior with PubSub
in regards to subscription management and connection state.
1.0.0
2020-10-16 22:14:56 -07:00
Nathan Harris e0d47f7330 Fix [p]unsubscribe from all
Motivation:

The methods of unsubscribing from all channels / patterns were not working as expected as they need to be special-case handled.

Modifications:

- Change: `RedisPubSubHandler` to be special-case unsubscribe when no arguments are provided

Result:

Developers should now properly be able to unsubscribe from all channels / patterns with a single method call.
2020-10-16 20:41:27 -07:00
Nathan Harris 42e8d4b127 Allow repeated commands to same connection in pool
Motivation:

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.

Modifications:

- 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

Result:

Developers should now have an "escape hatch" with `RedisConnectionPool` to do limited exclusive chains of operations on a specific connection.
2020-10-15 13:39:58 -07:00
Nathan Harris 56f0ab0bc0 Add test case for RedisConnectionPool connectionRetryTimeout 2020-10-06 20:19:26 -07:00
Nathan Harris c8cb256b59 Add default buffer connectionRetryTimeout to avoid literal immediate timeouts
Motivation:

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.

Modifications:

- Change: RedisConnectionPool to always have a timeout offset defined

Result:

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
1.0.0-rc.2
2020-10-06 20:06:29 -07:00
Nathan Harris 3e28e75b6a Add configuration option for RedisConnectionPool lease timeout
Motivation:

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.

Modifications:

- 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"

Result:

Users can now configure the connection pool to fail immediately if connections are not available.
1.0.0-rc.1
2020-10-06 19:33:43 -07:00
Nathan Harris e858c0a66e Resolve PubSub post-commit feedback
Motivation:

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.

Modifications:

- 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

Result:

PubSub should have a more robust and thread-safe implementation.
2020-10-01 22:30:59 -07:00
Nathan Harris e7b597fc65 Add support for PubSub
Motivation:

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.

Modifications:

- 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`

Result:

Developers will now be able to use Redis in PubSub mode with both connections and pools.

This resolves #6
1.0.0-beta.2
2020-09-29 22:23:44 -07:00
Nathan Harris 45f665b985 [CI] -- Update to use official Swift 5.3 release images 2020-09-17 23:02:15 -07:00
Nathan Harris 6fe37cb7e4 Fix RedisCommandHandler never reaching error state 2020-09-08 10:56:44 -07:00
Nathan Harris 8fb1aed715 Update contributors 1.0.0-beta.1 2020-08-31 22:37:03 -07:00
Nathan Harris 90244e327b Refactor Logging implementation
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
2020-08-31 22:07:59 -07:00
Nathan Harris 1cf438ea2b Add Swift 5.3 testing for more platforms 2020-08-30 16:20:54 -07:00
Nathan Harris cfb02ba827 Add CI testing on CentOS 7 2020-08-30 15:27:35 -07:00
Nathan Harris 5c4fe9619b Disable logging unit tests until they are fixed 2020-08-30 14:42:52 -07:00
Nathan Harris 610915a909 Add new 'RedisTypes' module
Motivation:

Redis is written in C, so even though it has concepts of "types" such as SortedSet or List
its commands are all "free-floating" functions.

This can make it unfamiliar for those new to Redis to work within its systems and understand the relation of all of the commands.

RediStack can improve this by giving a way of having a consistent reference to a Redis type and all of its associated methods.

Modifications:

- Add: New library product called "RedisTypes"
- Add: First type to "RedisTypes", `RedisSet`

Result:

Newcomers to Redis will have an easier time getting familiar with the APIs and working with its types by having wrappers that
provide a familiar Swift Standard Library API tailored to Redis APIs.
2020-08-30 14:33:21 -07:00
Nathan Harris 85cbb614b8 Add GitHub issue template to redirect users to GitLab 2020-08-30 14:02:44 -07:00
Nathan Harris e56df0c469 Fix project logo in README 2020-08-29 21:04:40 -07:00