Commit Graph
157 Commits
Author SHA1 Message Date
Nathan Harris b0d0882ee2 Update License Notice for SwiftLog & SwiftMetrics
Motivation:

The project has adopted the `swift-log` and `swift-metrics` API packages, and the project's license needs to include attributions to their authors.

Modifications:

`NOTICE.txt` now lists `swift-log` and `swift-metrics` from Apple.

Result:

Apple has been properly attributed for the code from `swift-log` and `swift-metrics`
2019-05-27 17:02:31 -07:00
Nathan Harris f6facaa252 Merge pull request #43 from Mordil/blocking-pop
Add Blocking List Pop Commands
2019-05-27 16:44:58 -07:00
Nathan Harris eaa9d2bfd0 Add Blocking List Pop Commands
Motivation:

To be a comprehensive library, all commands should be implemented, even if they are highly discouraged. List's collection of commands were missing `brpop`, `blpop`, and `brpoplpush`.

Modifications:

`brpop`, `blpop` and `brpoplpush` are supported with defaults and overloads for an easier API.

Result:

Users now have access to `brpop`, `blpop` and `brpoplpush` commands.
2019-05-27 16:43:55 -07:00
Nathan Harris 0c4db2129a Merge pull request #42 from Mordil/blocking-zpop
Add Blocking Sorted Set Pop Commands
2019-05-27 15:02:41 -07:00
Nathan Harris 739223258c Add Blocking Sorted Set Pop Commands
Motivation:

To be a comprehensive library, all commands should be implemented, even if they are highly discouraged. Sorted Set's collection of commands were missing `bzpopmin` and `bzpopmax`.

Modifications:

`bzpopmin` and `bzpopmax` are supported with defaults and overloads for an easier API.
`RedisClient.channel` is now `internal` to have access during testing for bypassing normal guards for closing connections.

Result:

Users now have access to `bzpopmin` and `bzpopmax` commands.
2019-05-27 12:56:55 -07:00
Nathan Harris d0da3e760b Improve Redis Channel Pipeline Debugging
Motivation:

Debugging and properly handling errors was difficult as the `ChannelHandler` names were the default generic names, in addition the `RedisCommandHandler` did not pipe errors further up the pipeline.

Modifications:

`RedisCommandHandler` now calls `context.fireErrorCaught(error)` when receiving errors, and the default Redis `ChannelPipeline` handlers are added with debugging names.

Result:

It should be easier for debugging purposes to work with any Redis `ChannelPipeline`.
2019-05-27 12:09:18 -07:00
Nathan Harris 1a9f086c68 Add SwiftMetrics Dependency
This will eventually support issue #40
2019-05-17 18:34:45 -07:00
Nathan Harris d9d61bafe4 Minor comment fixes 2019-05-01 21:52:27 -07:00
Nathan Harris 3eb7608762 Tweak README formatting 2019-05-01 19:36:19 -07:00
Nathan Harris 0131fe43ba Update Readme and Tweak Redis.makeConnection(...)
Motivation:

The goal of the `Redis.makeConnection` factory method is to provide end users with a quick way to jump in and get started with Redis in Swift.

Right now, users have to provide an `EventLoopGroup` instance, when a reasonable default is available for us to define.

Modifications:

- Add: `MultiThreadedEventLoopGroup` for 1 thread as a default argument to the `using:` label in `Redis.makeConnection`
- Remove: The `with:` label for the password in `Redis.makeConnection`
- Change: The project README to reflect the current state of the project

Results:

Users should be able to create `RedisConnections` by just defining an IP Address & Port to connect to - and possibly a password.

In addition, the README should now properly direct users on how to use the latest version of the library.
0.7.0
2019-05-01 18:59:59 -07:00
Nathan Harris c7a606d8a6 Add Copyright Notices, Acknowledgements, and Contributors List 2019-05-01 16:24:05 -07:00
Nathan Harris d071bbaed6 Merge pull request #36 from Mordil/resolve-batching
Resolve `RedisPipeline` Proposal Discussion Topic
2019-05-01 15:28:16 -07:00
Nathan Harris 066a5c3dea Resolve RedisPipeline Proposal Discussion Topic
Motivation:

During the discussion thread of the NIORedis SSWG proposal, there were concerns expressed over the implementation
of `RedisPipeline` that covered the following areas:

1. Clashes with SwiftNIO concepts such as "Pipeline"
2. Misleading users on library behavior with using a Pipeline vs. a single `RedisConnection`
3. The implementation was "too clever" in that it allowed users to easily find themselves in "Undefined Behavior"
   due to lack of enough type safety in the API

However, the value in being able to control how frequently "flush" happens on a socket was discussed and considered
high - so something still needs to be in place to force flushes by users.

It was decided to leave the implementation of batching commands and their responses to library users, perhaps in
higher level frameworks while the library will provide said mechanism for controlling writing and flushing of commands.

Modifications:

- Add: `sendCommandsImmediately` bool property to `RedisConnection` to handle choice of flushing after each command
- Remove: `RedisPipeline`

Results:

Users should now have a more clear understanding on what type of control they have over the timing of when commands
are actually sent over the wire, with the greater emphasis placed on `RedisConnection`.
2019-05-01 15:26:00 -07:00
Nathan Harris 8bde6fd421 Merge pull request #39 from Mordil/cleanup-handlers
Simplify RESP Parsing and Redis Channel Handlers
2019-04-30 22:55:44 -07:00
Nathan Harris 477668e667 Simplify RESP Parsing and Redis Channel Handlers
Motivation:

As it stands, the parsing / encoding implementations for RESP was directly tied to the NIO Channel Handlers.

Unit tests were sloppily spread across multiple files and it made it difficult to explicitly separate out
the Channel Handler behavior from the RESP specification implementation.

Modifications:

- Add: `RESPTranslator` enum helper object with static methods that only handles RESP parsing / encoding
- Rename: `RESPEncoder` to `RedisMessageEncoder`
- Rename: `RESPDecoder` to `RedisByteDecoder`

Results:

It should be easier to understand what type is intended to be used as part of a NIO channel pipeline while
still having a direct way of parsing / encoding between Swift types and the RESP specification.

Unit tests should be more maintainable as well.
2019-04-30 22:54:31 -07:00
Nathan Harris a8a1fa5921 Merge pull request #38 from Mordil/namespacing
Namespace global static factory methods under `Redis`
2019-04-30 21:04:59 -07:00
Nathan Harris e446a834cd Namespace global static factory methods under Redis
Motivation:

The two provided factory methods for creating `RedisConnection` and `ClientBootstrap` were not readily discoverable or appropriately expressible.

Modifications:

- Add: `Redis` top-level namespace enum
- Move & Rename: `RedisConnection.connect` factory method to `Redis.makeConnection`
- Move & Rename: `ClientBootstrap.makeRedisDefault` factory method to `Redis.makeDefaultClientBootstrap`
- Rename: `EventLoopFuture` extension file to just `SwiftNIO` to have all framework extensions in a single file

Results:

Using NIORedis should be more discoverable and straight forward on how to create a connection with `Redis.makeConnection(...)` over `RedisConnection.connect(...)`
2019-04-30 21:01:35 -07:00
Nathan Harris d03823f27a Merge pull request #37 from Mordil/error-handling
Standardize Error Handling
2019-04-30 16:19:29 -07:00
Nathan Harris 46e96bd9cb Standardize Error Handling
Motivation:

`RedisError` was being used in many places in an ad-hoc fashion that made it unclear as to what source of errors it exactly represents.

In addition, it doesn't follow community conventions of handling known "classes" of errors with enums rather than static struct instances.

Results:

All errors that are generated and thrown within the library are specified as either `RESPDecoder.Error` or `NIORedisError`.

`RedisError` is simplified to represent an error message sent by a Redis instance that conforms to `LocalizedError`.
2019-04-30 16:18:21 -07:00
Nathan Harris f89e64decc Update unit test SetUp failures to include error messages to debug failures easier 2019-04-24 10:35:06 -07:00
Nathan Harris 76ceb6370c Fix incorrect default logger label in RedisConnection static factory method 2019-04-24 10:34:29 -07:00
Nathan Harris 864c4bcff6 Refactor RedisClient state to use enum instead of booleans
Motivation:

When later adding support for pub/sub, and potentially batching commands, a state is going to need to be defined and multiple booleans will create a large matrix that will be error prone.

Results:

Rather than using `Atomic<Bool>`, a `Lock` and `ConnectionState` enum are used to determine if a connection is open.
2019-04-24 10:33:55 -07:00
Nathan Harris ed106a943f Update to use official release of SwiftLog 2019-04-10 11:33:52 -07:00
Nathan Harris 755f6311a0 Merge pull request #34 from Mordil/bytebuffers
Rework RESPValue to use ByteBuffers for .simpleString and .bulkString
2019-04-09 16:32:31 -07:00
Nathan Harris d93511b8d0 Rework RESPValue to use ByteBuffers for .simpleString and .bulkString
Motivation:

Throughout the process of creating and using RESPValue, many unnecessary allocations happened translating ByteBuffers into [Int8] raw byte arrays.

Results:

RESPValue has a more conherent underlying data structure and computed properties, while decoding RESP is more straight forward and performant

Resolves #31
2019-04-09 16:29:24 -07:00
Nathan Harris 741482dbfb Update CI Config to test both Ubuntu Xenial & Bionic and to use official Swift images 2019-04-09 11:55:15 -07:00
Nathan Harris 4cfc326c4d Update to latest SwiftLog names 2019-04-09 11:42:52 -07:00
Nathan Harris b3c1afa27a Merge pull request #30 from Mordil/29-replace-data
Replace `Foundation.Data` with `[UInt8]` type everywhere
2019-04-01 09:25:06 -07:00
Nathan Harris 3c53d4404b Replace Foundation.Data with [UInt8] type everywhere
Motivation:

`Foundation.Data` is known to be more expensive than is necessary for this low level of a library, and has some quirks with its usage.

Results:

This library now works with byte arrays (`[UInt8]`) directly, and all references to `Foundation` now explicitly import the exact types they need.
2019-04-01 09:23:45 -07:00
Nathan Harris 51dd32dabd Add a warning log in RedisConnection deinit 2019-03-28 22:03:17 -07:00
Nathan Harris 0797c3f44a Merge pull request #27 from Mordil/remove-authorize
Remove `authorize` convenience command method
0.6.0
2019-03-27 23:08:16 -07:00
Nathan Harris 2b7b2130ca Remove authorize convenience command method
Motivation:

As this command is embedded in the creation of a `RedisConnection` and you authorize an entire connection to a Redis instance - this command serves no purpose and could make it easier for users to shoot themselves in the foot.

Results:

`authorize(with:)` convenience method is removed, and the `RedisConnection.connect` method now sends a raw command
2019-03-27 23:07:01 -07:00
Nathan Harris 152eb30fa1 Merge pull request #25 from Mordil/remove-driver
Remove `RedisDriver`
2019-03-27 23:02:07 -07:00
Nathan Harris db4a156d05 Remove RedisDriver
Motivation:

`RedisDriver` has one of the weakest use cases for existence, as its entire purpose can be solved with a static function on `RedisConnection`.

Result:

`RedisDriver` no longer is a thing, and a simpler process of creating a `RedisConnection` is available through the static method `connect(to:with:on:logger:)`.

Also, the `ClientBootstrap.makeForRedis(using:)` method has been cleaned up and renamed to `ClientBootstrap.makeRedisDefault(using:)`.
2019-03-27 22:56:40 -07:00
Nathan Harris ba6bf6d8d2 Merge pull request #26 from Mordil/redis-pipeline
Simplify `RedisPipeline`
2019-03-27 22:45:54 -07:00
Nathan Harris c4ea8f9e49 Simplify RedisPipeline
Motivation:

`RedisPipeline` has a weak use case as a protocol, as it is more than likely 98% of use cases will end up using the `NIORedisPipeline` implementation.

Result:

`RedisPipeline` is more direct in its intended usage, with comment blocks being more clear.
2019-03-27 22:44:46 -07:00
Nathan Harris 0f7b53f243 Merge pull request #24 from Mordil/redis-client
Simplify `RedisCommandExecutor` and `RedisConnection`
2019-03-27 22:39:52 -07:00
Nathan Harris 9f049eb4b5 Simplify RedisCommandExecutor and RedisConnection
Motivation:

`RedisCommandExecutor` was a complex and "wordy" name that was not 100% clear as to how it relates to other types.

`RedisConnection` also has not had a strong use case shown for it to exists as a separate protocol - using up a great name for the "out of the box" implementation.

Result:

`RedisClient` instead of `RedisCommandExecutor` is more clear as to what it is, in Redis terminology, a communication client.

`RedisConnection` as a concrete class provides an identifiable basic block for making connections to Redis.

`RedisConnection` also saw some fixes to `close()` while having some names and comment blocks tweaked for updated naming.
2019-03-27 22:36:52 -07:00
Nathan Harris 869625d47d Update to use NIO 2 2019-03-26 08:46:51 -07:00
Nathan Harris 2dd1d309c0 Merge pull request #22 from Mordil/command-audit
Command audit
0.5.0
2019-03-25 13:39:42 -07:00
Nathan Harris 16dc4ac1bf Updated unit tests to use new syntax and to remove a bunch of optional crud 2019-03-25 13:37:40 -07:00
Nathan Harris f4e646c1aa Audit convenience commands
Motivation:

Performance, clarity, and uniformity with code documentation, Swift API, and data types.
2019-03-25 13:37:40 -07:00
Nathan Harris 601431ac9e Merge pull request #21 from Mordil/sorted-set-commands
Add convenience command methods for Sorted Set with unit tests
2019-03-23 22:31:00 -07:00
Nathan Harris bcc7f71186 Add convenience command methods for Sorted Set with unit tests 2019-03-23 22:29:38 -07:00
Nathan Harris 1c5eab6030 Merge pull request #20 from Mordil/list-commands
Add list convenience commands with unit tests
2019-03-21 19:45:32 -07:00
Nathan Harris 050ad64eaa Add list convenience commands with unit tests 2019-03-21 19:41:29 -07:00
Nathan Harris 21fc0a4031 Make extension properties on RESPValue to all be public 2019-03-21 19:41:08 -07:00
Nathan Harris f3a9b321a6 Merge pull request #19 from Mordil/hash-commands
Add hash convenience commands with unit tests
2019-03-21 16:05:04 -07:00
Nathan Harris 39feecb4cb Add hash convenience commands with unit tests 2019-03-21 16:00:19 -07:00
Nathan Harris 17f77363ae Fix scan method and add unit test 2019-03-21 14:07:15 -07:00