4 Commits

Author SHA1 Message Date
Fabian Fett c366a16fe8 Explicitly depend on NIO modules 2022-12-01 13:46:41 +01: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.
2022-04-04 00:06:47 -05:00
Nathan Harris 3c6713038d Refactor RedisCommand into a general use object
Motivation:

RediStack today represents a command as a temporary object for the purpose of writing to the channel.

While it is useful to have an object for that purpose, commands handled in this way require immediate execution
and aren't available for other purposes.

Commands can serve a better purpose as a lightweight object to support delayed execution,
so that pipeling as described in issue #63 could be possible.

Modifications:

- Add: `get` overloads for JSON codable interaction on `RedisClient`
- Add: New `RedisZRangeResultOption` type for better interactions with zrange operations that can optionally return scores
- Add: New `RedisHashFieldKey` for type-safety when working with Hash field keys much like `RedisKey`
- Change: A few API types from enums to structs for library evolution
- Change: `RedisCommandHandler` to operate on a tuple of `RESPValue, EventLoopPromise<RESPValue>` rather than `RedisCommand`
- Change: `RedisCommand` to be a generic struct with the keyword, arguments, and a transform closure to defer execution
- Change: Almost all `RedisClient` command extensions to be factory methods on `RedisCommand` instead
- Change: Many response types to be optional to avoid developers having to do `isNull` checks on their own
- Change: `RedisClient.send(command:arguments:)` to be generic with `send(_:)` as the signature
- Rename: RedisClient extensions for scan methods to be more discoverable and legible as `scanHashField`, etc.

Result:

It should be easier to support a clean pipelining API with deferred command execution,
with extensions being easier for 2nd party developers, and the maintenance overhead of all of the command extensions
should be a little lighter when it comes to changing HOW commands are sent such as adding a context parameter
2020-12-02 08:41:59 +00: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