412 Commits

Author SHA1 Message Date
Marius Seufzer 35f9e7aab8 Add onUnexpectedConnectionClose callback to pool
Currently there is no way to set `RedisConnection`'s `onUnexpectedClosure` for connections within a `RedisConnectionPool`. This PR adds a new closure to `RedisConnectionPool.onUnexpectedConnectionClose` which will be triggered for every pool connection that closed unexpectedly.
2023-06-04 18:10:05 +00:00
Gwynne Raskind 8ac2d742cb 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. 2.0.0-gamma.1.1 2023-05-28 02:30:15 +00:00
Nathan Harris aa185a0133 Lay groundwork for RESP3 support and flat ChannelHandler hierarchy
## Motivation

Since Redis 6.0, a new serialization protocol format (v3) is available that gives richer semantic reasoning behind the different types to enable commands to better understand the return types to provide in their programming language.

In addition, the `RESPTranslator` type is going to see more direct usage, and the current API doesn't make read well.

## Changes

- Add: Internal `RESPVersion` enum that the `RESPTranslator` will start to use
- Rename: `RESPTranslator.parseBytes` to `RESPTranslator.read(from:)`
1.3.1
2022-12-26 14:43:21 -06:00
Nathan Harris 3f7fedb6db [Misc] Update contributors 2.0.0-gamma.1 2022-12-12 20:55:08 -06:00
Nathan Harris a431ae8c6c [List] Properly map results when key has no values
Fixes #116
2022-12-12 20:38:00 -06:00
Fabian Fett e0cab21f95 Graceful connection close without sending a QUIT command first 2022-12-07 17:10:40 +01:00
Fabian Fett 4ea66c4788 Add support for graceful shutdown to the RedisCommandHandler 2022-12-07 15:51:43 +00:00
Nathan Harris b88fac059d #115 -- Remove logging(to:) method 2022-12-01 13:06:35 -06:00
Fabian Fett c366a16fe8 Explicitly depend on NIO modules 2022-12-01 13:46:41 +01:00
Fabian Fett d0f15ad55b Conform RedisByteDecoder to NIOSingleStepByteToMessageDecoder 2022-11-30 14:48:34 +01:00
Fabian Fett f6cb83ca2a Explicitly depend on Atomics 2022-11-30 04:47:37 +00:00
Nathan Harris 00eb9b5e33 Unify PubSub Handler Signature
Motivation

Right now the PubSub handlers are split into three separate closures, with the subscribe/unsubscribe handlers being optional. This won't play well with AsyncStream for being able to respond to all events that a PubSub subscription can cause.

Additionally, the current structure is very verbose in code to maintain - but also adds complexity to developers who are first getting started to understand the lifecycle of PubSub events.

Changes

- Add: New `RedisPubSubEvent` enum that captures the subscribe, unsubscribe, and message lifecycle events
- Add: New `RedisPubSubEventReceiver` that combines the previous 3 closure types
- Add: Dedicated DocC Symbol Extension file for `RedisPubSubHandler`
- Change: `RedisClient.subscribe` and `RedisClient.psubscribe` method signatures to only require a single unlabeled closure
- Rename: `RedisUnsubscribeEventSource` to `RedisPubSubEvent.UnsubscribeEventSource`
- Remove: `RedisSubscriptionMessageReceiver`, `RedisSubscriptionChangeDetails`, `RedisSubscribeHandler`, and `RedisUnsubscribeHandler` types

Result

Developers should have a much easier time getting started and understanding PubSub with assistance from the compiler with types to understand
what they're being given and what's available to them as information to make more informed decisions in their app logic.
2022-11-30 04:33:31 +00:00
Fabian Fett 459f2cc4cb Fix NIOLock warning 2022-11-17 16:05:10 +01:00
Nathan Harris 922c4f4b6e Add Code Coverage reports in Merge Requests
Motivation:

To maintain quality, automated code coverage reports should be generated and archived as build artifacts in CI pipelines.

Modifications:

Update CI config to run a job for running unit tests with code coverage, and exporting the report to GitLab.

Result:

Code coverage will be tracked and history recorded to compare individual code changes.
2022-09-25 21:06:15 +00:00
Michael Stegeman adbc2e3e16 Switch from NIOAtomic to ManagedAtomic. 2022-08-21 02:47:00 +00:00
Nathan Harris d5ed8fcebd Remove Jazzy documentation job and rely on Swift Package Index 2022-08-14 23:41:28 -05:00
Nathan Harris 0465b34ef3 Allow nightly trunks CI jobs to fail 2.0.0-beta.1 2022-08-14 22:03:26 -05:00
Nathan Harris 3ad1e26280 Update CI to only run platform tests on git push events 2022-08-14 22:03:26 -05:00
Nathan Harris 44319ea3ac Set Swift 5.5 as the minimum version 2022-08-14 22:03:26 -05:00
Nathan Harris 4e2217cffd Add support for Swift Package Index documentation hosting 2022-08-13 21:36:02 -05:00
Nathan Harris c76203c61a #103 -- Provide greater context to Pub/Sub Unsubscribe events 2022-08-13 00:22:18 -05:00
Nathan Harris 555062c62e [Docs] Fix symbol links resolution for various redis commands 2022-04-24 23:37:39 -05:00
Nathan Harris 820820d877 Significantly Improve the Configuration API for Pools and Connections
## Motivation

The API for establishing the configuration of a connection pool had a lot of jargon and properties that developers had issues keeping straight and understanding what each does.

This commit provides first-class API support for concepts such as retry strategies, and how the pool handles connection counts.

## Changes

- Add: New ConnectionCountBehavior for determining leaky / non-leaky behavior
- Add: New ConnectionRetryStrategy for allowing customization of retry behavior
- Change: RedisConnection.defaultPort to be a computed property
- Change: The logging keys of pool connection retry metadata
- Rename: Several configuration properties to drop prefixes or to be combined into new structures

## Result

Developers should have a much better experience exploring the available configuration options for pools and connections, being able to understand how each piece works with the underlying system.
2022-04-24 23:37:39 -05:00
Nathan Harris eedf1581cf Replace remaining usage of pipeline.removeHandler(_:) 2022-04-24 04:29:33 +00:00
Nathan Harris cfb99ba0f7 #100 -- Fix addPubSubHandler not checking if already added 2022-04-24 03:34:10 +00:00
Nathan Harris 284b7f09bc Add overload of ping command for nil message style 2022-04-19 23:18:26 -05:00
Nathan Harris 9da5773e7a 92 -- Accept event loop and logger in RedisClient commands
There are many times that developers want exact control over which EventLoop will be executing their chained EventLoopFuture callbacks
and which Logger will do the logging in calls deep within RediStack.

All commands will now accept an optional EventLoop and Logger to hop to, and using the logger for desired logs.
2.0.0-alpha.4 2.0.0-experimental.1
2022-04-04 00:06:47 -05:00
Nathan Harris a4aec72592 Update command symbol docs to use DocC symbol references 2022-03-15 23:51:43 -05:00
Nathan Harris 20f6c45d76 Add DocC symbol reference file for RedisCommand 2022-03-15 23:51:43 -05:00
Nathan Harris d5f38b7b92 Add basic DocC files for modules 2022-03-15 23:51:43 -05:00
Nathan Harris 2d43c71fdd Add Package manifest for Swift 5.5 users for DocC 2022-03-15 23:51:42 -05:00
Nathan Harris 498b6a5eb5 Conform RedisCommand to Equatable 2022-03-15 23:38:13 -05:00
Nathan Harris 252b0b8061 Improve KEYS command to be more type-safe 2022-03-15 23:30:30 -05:00
Nathan Harris 370ef8c4ac 101 -- Add KEYS command 2022-03-15 21:12:22 -05:00
Nathan Harris 6c4ca52f74 104 -- Add real world test case to ensure revrange bug doesn't persist 2022-03-15 04:33:35 +00:00
Daniel Ramteke b449334c8a [Commands] Add STRLEN 2022-02-21 19:10:34 +00:00
Nathan Harris 8ff8b03907 [CI] Replace rules usage with only/except to correctly run nightlies 2021-11-07 22:39:02 -08:00
Nathan Harris 1ca0e9df41 [Docs] Update test matrix in README 2021-11-03 00:19:00 -07:00
Nathan Harris fed62a64b8 [CI] Only run CI builds against nightly images 2021-11-03 00:10:28 -07:00
Nathan Harris 9def1b9aab [CI] Restructure CI to be simpler with overrides 2021-11-02 23:44:46 -07:00
Nathan Harris 5ed6375e43 Set Swift 5.3 as the minimum version 2021-11-02 23:43:25 -07:00
Nathan Harris ad316a97ac 95 -- Add callback closure on RedisConnection invoked on channel close 2021-08-16 21:47:20 -07:00
Nathan Harris 2cc63ec8f2 [Docs] Add security policy 2021-06-01 14:05:30 -07:00
Peter Adams 3ca471b226 Get pubsub numsub working 1.1.1 2.0.0-alpha.3 2021-05-04 16:26:35 +00:00
Peter Adams e08b42616b Get pubsub numpat working 2021-05-03 20:49:16 +00:00
Peter Adams 410a5b2d03 Change the scan test to accept up to 8 odd keys
This attempts to fix #23
2021-05-03 20:43:04 +00:00
Peter Adams 9958e2d13b Fix pubsub channels 2021-05-02 20:39:18 +01:00
Nathan Harris f0d123fdaa Disable scan unit tests again as they are still flaky 2021-04-29 09:31:38 -07:00
Peter Adams 0c13e4f26c Get scan working on the same as redis-cli 6.2.1 2021-04-28 13:45:06 +01:00
Nathan Harris 03a066f8f5 Audit log message severity levels
Motivation:

Following the SSWG guidelines for libraries and log levels, because much of the library's behavior is expressed in the language and NIO framework as errors and failed ELFs, logging at error is "verbose" and takes away control from developers.

Modifications:

Log messages have been adjusted to more accurately represent when and how the log message should be used, especially when ELFs are failed or errors are thrown.

Result:

Developers won't have log messages at error or critical unless they opt-in from their own code, unless the library has no way of expressing the failure condition through the language.
2021-04-08 20:22:10 -07:00